X


Payment

Question

If we are using a binary search on a list of size 1024 what isthe worst case number of operations we will use to find ourtarget?

If we are searching a linked list of items for a specific itemthat is not in the list, how many comparisons will we use in theworst case? How many comparisons will we use
on average? How many in the best case? Be exact with youranswer.

If we are searching a list of items for a specific item we knowis in the list, how many comparisons will we use in the worst case?How many comparisons will we use on
average? Be exact with your answer.

Solution

xxxxxy Search

As xxxxxx search, xxx xxxxx xxxx for xxxxxy search xx xxxx xxxxxxxx x xx not xx xxx xxx L xx then xxx xxxxxxxxx xxx to xxxxxxxxxx maximum xxxxxxxx xxxxxx xx recursive xxxxx, and xxxxx xxxxxxxxxx xxxxxxxx number xx operations

Suppose x(x) xxxx xx time xxxxxxxx to xxxxxx xxx xxxxy of xxxxxxxxx. Now, xx xxx xxx iteration xxxxy is xxxxxx. xx, xx the xxxxxxxxxxxx T(n/2) xxxx xx xxxxxxxx and xx on. xxxxx xx xxx thefollowing xxxxxxxxxx relation.

T(n)= x+x(x/x) x=xxxx xxxxx. time xxxxxxxx to xxxx xxxxxxxxxxxxx.= x+x(x/x)x&#xxx;&#xxx; ....................

=kc+T(n/2k)

   = c xxxx+x(x) [xxx xx = x. So, x = xxxx]xxxxxxxxx, T(n) = O(log x)xxxx x= xxxx so xx operations xxxx xx xxxxxxxx.xxxxxx List

xxxxx xxxx:xxxxxxx xxxxx are x number xx xxxxxxx.xxx xx unsuccessful xxxxxx the xxxx xxxx xx visited xxxx thelast xxxxxx.xxxxxxxxx x(x) = O(n)

Average xxxx:xxx element xxx xx xxxxx in xxy position xx xxx xxxx and xxxxxxxxxxxxxy is x/x. xxx xx the xxxxxxx is xxxxx xx xxx firstposition xxxy one xxxxxxxxxx xxxxxxx,xxx xxx second xxxxxxxx twocomparisons xxx xxxxxxxx xxx so xx. Hence,

f(n) = x/x+x/x+.......+x/x=(x+x+.....+x)/x=x(x+x)/xx=(x+x)/xxxxxxxxxx, x(x) = x(x)&#xxx;&#xxx;

Payment



Payment