由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问道题,binary tree里有一个有indegree 2
相关主题
find treenode with two indegrees这个check whether a binary tree is a BST 问题
amazon一道面试题转一些我blog上一些常见的二叉树面试问题和总结
non recursive binary tree traversal in O(n) time and O(1) spaceprint bst in level order dfs为什么是O(N)不应该是O(N^2)吗?
binary tree, sum of 2 nodes == given numberF家phone interview的一道题
请教find number of duplicates in a binary search tree来个原创面试题,逗大家玩
Zenefits 面经 OA+Skype+onsite这道题什么意识?
bloomberg onsite题求教一道老题
Lowest common ancestor of two nodes of Binary Tree从tree的post order traversal和pre,能否build这个tree?
相关话题的讨论汇总
话题: indegree话题: linked话题: tree话题: list话题: binary
进入JobHunting版参与讨论
1 (共1页)
y*****a
发帖数: 221
1
怎么找出这个node?
l*****a
发帖数: 14598
2
what does indegree2 mean?
thanks

【在 y*****a 的大作中提到】
: 怎么找出这个node?
y*****a
发帖数: 221
3
原题是这么说的
Suppose there is a binary tree having millions of nodes and by mistake one
node has two indegree........(i.e. There becomes a cycle/loop in that tree .
..u have to find that node which is having two indegree....
Constraint is no extra memory can be used and tree representation is in
Linked list format...

【在 l*****a 的大作中提到】
: what does indegree2 mean?
: thanks

P********l
发帖数: 452
4
depends how the "Linked list" is organised.
Basically, a tree does not need the "Linked list", which is the extra piece
of memory that can mark a node is visited or not.
So,
1) clear the linked list.
2) from root, do a dfs / bfs traversal. once visited, push it into the
linked list.
3) if a node is already in the list, it has two indegrees.
4) continue to push all nodes in.
The linked list is virtually the same but we know who has two indegrees.
1 (共1页)
进入JobHunting版参与讨论
相关主题
从tree的post order traversal和pre,能否build这个tree?请教find number of duplicates in a binary search tree
这个Binary Tree的题来看看Zenefits 面经 OA+Skype+onsite
讨论个Binary search tree的题目bloomberg onsite题
请问一个简单的面试题Lowest common ancestor of two nodes of Binary Tree
find treenode with two indegrees这个check whether a binary tree is a BST 问题
amazon一道面试题转一些我blog上一些常见的二叉树面试问题和总结
non recursive binary tree traversal in O(n) time and O(1) spaceprint bst in level order dfs为什么是O(N)不应该是O(N^2)吗?
binary tree, sum of 2 nodes == given numberF家phone interview的一道题
相关话题的讨论汇总
话题: indegree话题: linked话题: tree话题: list话题: binary