Language Bar

Wednesday, December 12, 2012



1. What is function of length () method in the Queue
Answer: (page 111)
In Queue length() method, has a single statement i.e.
return size ;
This method returns the size of the queue, reflecting the number of elements in the queue. It is not the size of the array used internally to store the elements of the queue.

2. Explain the two cases in which we apply double rotation in An Avl tree
Answer: (Page 229)
Sometimes a single rotation is not sufficient to balance an unbalanced tree.
The two cases are following:
1.   Insertion into the right subtree of the left child of X node (RL)
2.   Insertion into the left subtree of the right child of X node (LR)

3. How can we perform level-order traversal on a tree? Answer:- (For More detail and code see Page 161 )
We can print a binary tree level by level by employing recursive or non-recursive method.
The idea of a level-order traversal is to visit the root, then visit all nodes "1 level away" (depth 2) from the root (left to right), then all nodes "2 levels away" (depth 3) from the root, etc. For the example tree, the goal is to visit the nodes in the following order:

A level-order traversal requires using a queue (rather than a recursive algorithm, which implicitly uses a stack). A queue is a FIFO structure, which can make the level-order traversal easier.

4. How can the dangling reference problem be avoided? Answer:- ( Page 200 )
To avoid dangling reference, dont return the reference of a local variable (transient) from a function.


1 comment:

  1. I waѕ recommended thіs web site vіa mу cοusin.
    I am no lоnger ѕuгe whеther or not this ρut up is wrіtten via hіm as nο one elsе recognize
    suсh unique аppгoхimatelу my trouble.

    You're amazing! Thanks!

    Stop by my homepage :: haarausfall Kreisrund
    Also see my web site ::




comments powered by Disqus