CS 225 Lecture Notes - Lecture 21: Binary Tree, Longest Path Problem, Null Pointer

54 views4 pages

Document Summary

Binary tree is a discrete structure right now. A binary tree t is either empty. or null. Or root together with a left or right subtrees, each of which are binary trees, {root, T_l, t_r} tree left, tree right root without left or right {r,{},{}} An (important) example of a function on a binary tree: height(t) -- length of longest path from root to a leaf. Most common definition of height is the length of the longest path from root to a leaf. Given a tree t, write a recursive defn of the height of t, height(t): An empty tree with no root, the tree has height -1, this is base case. If the tree is not empty, then t={r,t_l. t_r} and height(t) = 1. Full binary tree: a tree in which every node has 2 or 0 children. F is a full binary tree if and only if:

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents