Professional Documents
Culture Documents
2) Direct generation of a cross reference listing can use an ordered symbol table
Disadvantage
For example assume that a variable count is to be inserted in an ordered symbol table, then
it needs that all the records or names lexically larger than count must be moved down in the
table. Thus inserting a variable in an ordered symbol table with linear search requires n-m
comparisons followed by m moves.
BinarySearch
Binary Search divides the table into two halves with only one element in between these
halves called as Middle Element. The element in the left half are lexically less than the
middle element while the elements in the right half are lexically greater than middle element.
If the search element lies in the left half then that half acts as sub table and it is again divided
into two halves with one middle element in it and the procedure continues.
n-1
n+(1-)(n+1)/2
2