Wednesday 5 September 2012

December 2010 - Question No 24 & 25

24. Linear probing suffers from a problem known as

(A) Secondary clustering
(B) Primary clustering
(C) Both (A) and (B)
(D) None of these

Ans:-B

Explanation:- Linear probing is a term associated with hashing. Linear probing is a collision resolving technique in hashing. It suffers from a problem known as primary clustering. Any chosen hash function should uniformly distribute the records across the given available address space but sometimes clusters appear. If linear probing is used, it might spend a lot of time probing within the cluster instead of searching in the subsequent available space. One more collision resolving technique is Quadratic probing. Again we might come across the same topic depending on the nature of question encountered in future.


25. Which of the following can be the sequence of nodes examined in binary search tree while searching for key 88 ?

(A) 90, 40, 65, 50, 88
(B) 90, 110, 80, 85, 88
(C) 190, 60, 90, 85, 88
(D) 65, 140, 80, 70, 88

Ans:-C

Explanation:- Inorder to find a solution for a question like above, given the data draw a binary search tree for each one of the options. The first item is the root. Any value less than the root will form the left side of the tree and any value greater than the root will form the right side of the tree. When you draw such a tree, if you find no node has a left and right child then such a sequence would be valid. If you find that the tree has a left and right child for any node then that sequence is invalid. If you draw the tree for all the 4 options given in the question you will find that only option C does not have left and right child for any node. So option C is correct.

5 comments:

  1. hi madam thanks for giving nice explanation. ur this Blog is very helpful to me. but i have query regarding que 25. i can't understand it.
    according to ur explanation Root is 190 and the second is the 60,90,85,88 are the left side of the root as per ur explanation. but this situation also same as the option A there is a first item is 90 which is Root and the other all the item are less than root so how can u say that ANS is C??

    ReplyDelete
    Replies
    1. i have also same doubt....mam pls elaborate this...

      Delete
  2. Binary search tree is made by placing first node as the Root, Second will be checked with the Root -> if it is less then the Root then place it at left-side of the Root otherwise right-side of the Root.
    When third comes, check it with the Root.
    if (it is less then the Root) then
    {
    again check it with the left child (if any)of the Root and go on.
    if there is no child their then only you can put it their.

    }
    else
    {
    again check it with the right child (if any)of the Root and go on.
    if there is no child their then only you can put it their.
    }

    Build BST as shown above and you will be clear on the solution.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete