Dear Readers, Welcome to Algorithms multiple choice questions and answers with
explanation. These objective type Algorithms questions are very important for campus placement test and job interviews.

Specially developed for the Algorithms freshers and professionals, these model questions are asked in the online technical test and interview of many IT companies.

Explanation: The probability are ½,1/4, 1/8,1/16,,1/32 So, the Huffman code according to the tree is unique.

2) Algorithms: Consider a B-tree of order 4 and is built from scratch by 10 successive insertions. What would be the maximum number of node splitting operations that take place? - Published on 24 Jun 15

Explanation: A B-tree of order m contains n records and each contains b records on average then the tree will have about n/b leaves. If we split k nodes along the path from leaves then k<=1+logm/2 [n/b] here n=10,b=3,m=4 so k<=1+log4/2 [n/b] k<=1+log2 4 k<= 1+2 k<=3

3) Algorithms: From the following algorithm design techniques which one is used to find all the pairs of shortest distances in a graph? - Published on 24 Jun 15

Explanation: the no of keys given are 4 apply the formula Bn=1/(n+1)*(2n!/n!n!) where B is the binary tree and n is the number of keys. Bn=1/(4+1)*(8!/4!4!) Bn=1/5*(8*7*6*5*4!)/4!4! Bn=8*7*9*6/(4*3*2) Bn=56/4 Bn=14 Hence, the total no of binary trees with n=4 is 14.

6) From the following sorting algorithms which algorithm needs the minimum number of swaps - Published on 16 Jun 15

Explanation: First find the smallest in the array and exchange it with the element in the first position, then find the second smallest element and exchange it with the element in the second position and continue in this way until the entire array is sorted. Hence, we say that selection sort takes the minimum number of swaps.

7) From the following sorting algorithms which has the lowest worst case complexity? - Published on 16 Jun 15