![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Chapter 4 Trees and Graphs
u011846211
这个作者很懒,什么都没留下…
展开
-
4.1
Topic:Implement a function to check if a binary tree is balanced. For the purposes of this question, a balanced tree is defined to be a tree such that the heights of the two subtrees of any node nev翻译 2013-09-15 10:09:22 · 491 阅读 · 0 评论 -
4.8
Topic 4.8 You have two very large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of T1. A tree T2 is a subtree of T1 if th翻译 2013-09-29 05:08:00 · 494 阅读 · 0 评论 -
4.7
Topic 4.7 Design an algorithm and write code to find the first common ancestor of two nodes in a binary tree. Avoid storing additional nodes in a data structure. NOTE: This is not necessarily a bina翻译 2013-09-27 16:48:54 · 417 阅读 · 0 评论 -
4.0
Topic: For Trees, inserInOrder and judge whether isBST public class TreeNode { public int data; public TreeNode left; public TreeNode right; public TreeNode parent; publ翻译 2013-09-15 10:20:49 · 394 阅读 · 0 评论 -
4.6
Topic 4.6 Write an algorithm to find the ‘next’ node (i.e.,in-order successor)of a given node in a binary search tree. You may assume that each node has a link to its parent. 方法: If n has a ri翻译 2013-09-24 12:17:30 · 398 阅读 · 0 评论 -
4.5
Topic 4.5:Implement a function to check if a binary tree is a binary search tree. 方法0:Do an in-order traversal, copy the elements to an array, check to see if the array is sorted. Takes up a bit of翻译 2013-09-24 09:43:51 · 401 阅读 · 0 评论 -
4.4
Topic:Given a binary search tree, design an algortithm which creates a linked list of all the nodes at each depth (e.g. if you have a tree with depth D, you’ll have D linked lists).翻译 2013-09-16 06:11:53 · 389 阅读 · 0 评论 -
4.3
Topic:Given a sorted (increasing order) array, write an algorithm to create a binary search tree with minimal height. public class TreeNode { public int data; public TreeNode left;翻译 2013-09-16 06:08:36 · 543 阅读 · 0 评论 -
4.2
Topic:Given a directed graph, design an algorithm to find out whether there is a route between two nodes. // 方法:Do graph traversal, DFS or BFS. Start from one node, and check if the other can be翻译 2013-09-16 05:21:35 · 495 阅读 · 0 评论 -
4.9
Topic 4.9 You are given a binary tree in which each node contains a value. Design an algorithm to print all paths which sum to a given value. Note that a path can start or end anywhere in the tree.翻译 2013-09-29 10:53:00 · 468 阅读 · 0 评论