页面顶部 Top
文件:  root - text - article - 2019 - 10 - floor-and-ceiling-of-a-binary-search-tree.txt
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Problem, Data Structures and Algorithms, | 英文 | 主页 | 类别: 计算机科学 | 307 次阅读, 20683 次搜索 | 119 个单词

定阅此目录的博客 | 浏览 | 博客存档
Hi, here's your problem today. This problem was recently asked by Apple:

Given an integer k and a binary search tree, find the floor (less than or equal to) of k, and the ceiling (larger than or equal to) of k. If either does not exist, then print them as None.

Here is the definition of a node for the tree.


class Node:
def __init__(self, value):
self.left = None
self.right = None
self.value = value

def findCeilingFloor(root_node, k, floor=None, ceil=None):
# Fill this in.

root = Node(8)
root.left = Node(4)
root.right = Node(12)

root.left.left = Node(2)
root.left.right = Node(6)

root.right.left = Node(10)
root.right.right = Node(14)

print findCeilingFloor(root, 5)
# (4, 6)
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Problem, Data Structures and Algorithms, | 英文 | 主页 | 类别: 计算机科学 | 307 次阅读, 20683 次搜索 | 119 个单词 定阅此目录的博客

猜您喜欢...

  1. Algorithm Interview: Lowest Common Ancestor of 2 Nodes in Binary Tree
  2. Daily Interview Problem: Merge List Of Number Into Ranges
  3. Daily Interview Problem: Full Binary Tree
  4. YES!!
  5. [Daily Problem] Angles of a Clock
  6. Daily Interview Problem: Reverse Words in a String
  7. Batch Programming in XP
  8. Daily Interview Problem: Room scheduling
  9. Patterns for breaking down questions you haven
  10. Skip the readings, focus on problems. And use all the hints!

评论 (0)

您的邮件 (不公开域名部分):

您的评论:

悄悄话(发邮件) 颜色 更多笑脸 S x y @

验证码 (点击图片更新):

    当前页暂时没有评论。


最后更新: October 30 2020 14:21:12 | RSS Subscription
牛排怎么做才好吃? | <meta name="机器人" content="不索引, 跟踪" />