CMPT 225 Lecture Notes - Lecture 9: Binary Tree

64 views3 pages

Document Summary

Intuition: to insert i: look for where i belongs. Assum t is note empty, and i is not already in t. Note: if we do a bunch of inserts in a row, and they are in order. Will get a bst that goes straight down in a right diagonal line. For bst with n nodes and height h, insert and search each: Do o(1) work at each node visited. Worst case, visit h+1 nodes therefore, work is theta h logn<= h <=n-1 therefore is also omega n. Claim: for every set of n keys, it is possible to construct a bst of height <= logn. Key(v) denotes key of node v. node (k) denotes node with key k. Suppose target is k at node v, 3 cases: Case1: if node is a leaf, delete it relative orders among remaining nodes are unchanged, order invariant maintained if v is not a leaf, need to restructure the tree.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions