由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 这个Binary Tree的题来看看
相关主题
请教find number of duplicates in a binary search tree判断 bst 疑问
recovery BST 不考虑相同值的情况么?recover binary search tree 常数空间
EPI 题目binary tree, sum of 2 nodes == given number
Lowest common ancestor of two nodes of Binary TreeFind the node with given value in binary tree in in-order
Unique Binary Search Trees II的复杂度怎么算啊?多谢!F电面
求教一道老题amazon一道面试题
讨论个Binary search tree的题目求教balanced binary tree的准确定义
谁有较好的iterative后序遍历binary tree的代码?Lowest Common Ancestor of multiple nodes in a binary tree
相关话题的讨论汇总
话题: stack话题: tree话题: binary话题: largest话题: subtree
进入JobHunting版参与讨论
1 (共1页)
H*M
发帖数: 1268
1
1. given a binary tree ,find the largest sub-tree which is a BST...(largest
mea
ns subtree having largest no of nodes in it)
我的理解是subtree就是说是一个子树,比如要到原来树的leaf,而不能把原来树的inter
nal nodes做leaf.也就是不能中间截一块,是这样的吗?
有什么好方法.我写的特别繁琐.if else 很多,用recursion.
2. 第二题说,design n stacks in an array of N. 这个我想愿意肯定不是让一个
stack分派固定的.感觉是要综合调配的,比如,如果array还有空,就不能说某个stack不
能加入了.我
想法是keep一个free list,,每个stack元素都要有个Next的指针,指向下个元素,stack
push的时候,就从freelist里面取.这样stack的元素就不连续了.
有什么其它的好办法么?
S****X
发帖数: 507
2
1. 可以看一下 Subtree 的定义
2. 意思是用 N array 来设计一个 Stack 算法, 很简单的

largest
inter
stack

【在 H*M 的大作中提到】
: 1. given a binary tree ,find the largest sub-tree which is a BST...(largest
: mea
: ns subtree having largest no of nodes in it)
: 我的理解是subtree就是说是一个子树,比如要到原来树的leaf,而不能把原来树的inter
: nal nodes做leaf.也就是不能中间截一块,是这样的吗?
: 有什么好方法.我写的特别繁琐.if else 很多,用recursion.
: 2. 第二题说,design n stacks in an array of N. 这个我想愿意肯定不是让一个
: stack分派固定的.感觉是要综合调配的,比如,如果array还有空,就不能说某个stack不
: 能加入了.我
: 想法是keep一个free list,,每个stack元素都要有个Next的指针,指向下个元素,stack

t********e
发帖数: 25
3
2. Let's say n == 3;
n1->head, n1++
n2->tail, n2--
n3->tail - length/3, n3--.
Move n3 if n2 overflow.
Assume equal probability to be used.
1 (共1页)
进入JobHunting版参与讨论
相关主题
Lowest Common Ancestor of multiple nodes in a binary treeUnique Binary Search Trees II的复杂度怎么算啊?多谢!
请教一个Leetcode付费题求教一道老题
Google Front-end Software Engineer Phone Interview讨论个Binary search tree的题目
两个有点难度很有意思的题谁有较好的iterative后序遍历binary tree的代码?
请教find number of duplicates in a binary search tree判断 bst 疑问
recovery BST 不考虑相同值的情况么?recover binary search tree 常数空间
EPI 题目binary tree, sum of 2 nodes == given number
Lowest common ancestor of two nodes of Binary TreeFind the node with given value in binary tree in in-order
相关话题的讨论汇总
话题: stack话题: tree话题: binary话题: largest话题: subtree