CMPT 115 Lecture Notes - Lecture 14: Binary Search Tree, Tree Traversal, Binary Search Algorithm

37 views16 pages
9 May 2016
School
Course
Professor

Document Summary

Notes written by michael horsch, mark eramian, ian mcquillan, lingling jin, and dmytro dyachuk. 1: searching an unsorted list requires that we traverse each element until we nd the element searched for. Searching in sorted lists: with the list adt, we could have used either a linked list or an array for data structure. Sorted linked list: slow insertion and deletion - o(n), slow searching - o(n). Sorted arrays: slow insertion and deletion - o(n), fast searching - o(log n) (recall: binary search). Binary search is not easy to apply to linked lists because we cannot jump to the middle in one step. The list adt had several operations to insert new data. Pre: rlist :: reference to a list target :: the key of an element in rlist el :: an element. The binary tree adt had several operations to insert new data. Pre: rparent is a reference to a tree rnew is a reference to a tree.

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