Sie sind auf Seite 1von 2

1.

15 A bit tree search visualization of the algorithm on page 320 or 341


depending on your version of Adam Drozdek Data Structures and
Algorithms in Java

I would encourage you to read 7.1.5 to gain a background before


you use this to untangle the spaghetti.

n/a 5 7 3 5
Ptr5 Ptr1 Ptr2 Ptr3 Ptr4

GIVEN V to search for find Get out calculator or umm


Binary V = 01010110 out which record ptr will google and find the binary
be used: of V which is 01010110

R is the record pointer which we want to be correctly


positioned after running the algo. For i =1 to m-1 that is we are gonna write the algorithm
checking from 5 to the last 5 in [5,7,3,5] with record pointer out in words so you
starting on R0 Ptr5. When they refer to Di bit they mean the understand me better
position i in the binary form of V 01010110 so if they say D1 u
know it’s the highlighted pos. we check if it holds a 1 or 0 if its
1 we move our record pointer to Ri we continue the process So since the first is checking 5 we check the position 5
up m-1 which is the order of the tree ofcourse and in the end in binary (starts with 0 index if anyone was wondering
we return the last record pointer that we saved why the 6th number was selected its 1 so we move our
chosen record pointer from R0 to R1 which holds Ptr1

So since the second is checking 7 we check


the position 7 in binary (starts with 0 index
if anyone was wondering why the 8th
number was selected its 0 so we skip all the
D bits after 7 that are larger until we find a
smaller one we notice 3 and 5 come after 3
is already smaller so we stop there our
record pointer remains on R1 which holds
Ptr1 in hind sight I probably should’ve
highlighted the record pointer position I
may have f… I mean messed up lemme add
arrows

So since the third is checking 3 we check the position


3 in binary (starts with 0 index if anyone was
wondering why the 4th number was selected its 1 so
we move our chosen record pointer from R1 to R3
which holds Ptr1
So since the fourth is checking 5 we check the position
5 in binary (starts with 0 index if anyone was
wondering why the 6th number was selected its 1 so
we move our chosen record pointer from R3 to R4
which holds Ptr1

Das könnte Ihnen auch gefallen