
























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

























































*typedef struct tnode ptnode; typedef struct node { short int key; ptnode right, left; } ;
ļ§ (^) Nodes are organize in levels (indexed from 0). ļ§ (^) Level (or depth) of a node : number of edges in the path from the root to that node. ļ§ (^) Height of a tree h : #levels = L (some books define h as number of levels-1). ļ§ (^) Full tree: every node has exactly two children and all the leaves are on the same level. not full!
What is the max number of nodes at any level l? 0 ⤠2 1 ⤠2 2 ⤠2 3 ⤠2 where l=0,1,2, ...,L-
l
What is the height h of a full tree with N nodes? 2 1 2 1 log( 1) (log ) h h N N h N O N ā = ā = + ā = + ā
ļ§ (^) Suppose DATA is an array which is sorted in increasing numerical order and we want to find the location LOC of a given ITEM in DATA. Then there is an extremely efficient searching algorithm called Binary Search.
ļ§ (^) Consider that you want to find the location of some word in a dictionary. ļ§ (^) I guess you are not fool enough to search it in a linear way or in other words apply linear search. That is no one search page by page from the start to end of the book. ļ§ (^) Rather, I guess you will open or divide the dictionary in the middle to determine which half contains the word. ļ§ (^) Then consider new probable half and open or divide that half in the middle to determine which half contains the word. This process goes on. ļ§ (^) Eventually you will find the location of the word and thus you are reducing the number of possible locations for the word in the dictionary.
How to search a binary search tree?
How to search a binary search tree?