1.
In linked lists, there are no NULL links in
Correct Answer
C. Circular linked list
Explanation
Circular linked lists do not have NULL links because the last node in the list points back to the first node, creating a circular structure. This means that there is no end of the list and traversal can continue indefinitely. Unlike single linked lists and linear doubly linked lists, where the last node points to NULL, circular linked lists provide a way to iterate through the list in a continuous loop.
2.
In a balanced binary tree, the height of two sub-trees of every node can not differ by more than
Correct Answer
B. 1
Explanation
In a balanced binary tree, the height of two sub-trees of every node cannot differ by more than 1. This means that the heights of the left and right sub-trees of any given node should have a difference of at most 1. This property ensures that the tree is balanced and allows for efficient searching, insertion, and deletion operations. If the height difference exceeds 1, the tree is considered unbalanced, which can lead to slower performance and inefficient operations. Therefore, the correct answer is 1.
3.
In the array representation of the binary tree, the right child of the root will be at the location of
Correct Answer
C. 3
Explanation
In the array representation of a binary tree, the right child of the root will be at the location of 3. This is because in a binary tree, the left child is typically represented at index 2*i+1 and the right child is represented at index 2*i+2, where i is the index of the parent node. In this case, the root is at index 0, so the right child will be at index 2*0+2 = 2. Therefore, the right child of the root will be at the location of 3 in the array.
4.
The number of possible ordered trees with 3 nodes A, B, and C is 11.
Correct Answer
B. False
Explanation
The number of possible ordered trees with 3 nodes A, B, and C is not 11. In fact, the number of possible ordered trees with 3 nodes is only 5. This can be determined by listing out all the possible arrangements of the nodes and counting them. Therefore, the given statement is false.
5.
Write the output of the following program:int a[ ] = {1,2,3,} *p;
Correct Answer
B. Junk value
Explanation
The given program declares an integer array 'a' with 3 elements and initializes them with the values 1, 2, and 3. It then declares a pointer variable 'p'. However, the program does not assign any address to the pointer 'p'. Therefore, when the program tries to access the value pointed by 'p', it will result in a junk value because 'p' does not point to a valid memory location.
6.
If the out-degree of every node is exactly equal to M or 0 and the number of nodes at level K is Mk-1 [con sider root at level 1], then the tree is called as (i) Full m-ary try(ii) Com plete m-ary tree(iii)Positional m-ary tree
Correct Answer
C. Both (i) and (ii)
Explanation
A tree where every node has either M children or no children at all is called a full m-ary tree. Additionally, if the number of nodes at level K is Mk-1, then the tree is also a complete m-ary tree. Therefore, the correct answer is Both (i) and (ii) because the given conditions satisfy both the definitions of a full m-ary tree and a complete m-ary tree.
7.
A queue has configuration a,b,c,d. If you want to get the configuration d,c,b,a, you need a minimum of 2 deletions and 3 additions.
Correct Answer
B. False
Explanation
To get the configuration d,c,b,a from the configuration a,b,c,d, we need to reverse the order of the elements. However, in a queue, we can only remove elements from the front and add elements to the back. Therefore, we would need to remove all elements from the queue and add them back in reverse order. This would require a minimum of 4 deletions and 4 additions, not 2 deletions and 3 additions. Therefore, the statement is false.
8.
In the following tree: If post-order traversal generates sequence XY-zw*+, then label of nodes 1234567 will be
Correct Answer
A. +, -, *, x, y, z, w
Explanation
The given post-order traversal sequence is XY-zw*+. In a post-order traversal, the left subtree is visited first, then the right subtree, and finally the root node. Therefore, the label of the root node is the last element in the post-order traversal sequence, which is +. The label of the left subtree's root node is the element before the root node in the post-order traversal sequence, which is -. The label of the right subtree's root node is the element before the left subtree's root node, which is *. The labels of the remaining nodes can be determined in a similar manner, resulting in the sequence +, -, *, x, y, z, w.
9.
On which principle does stack work?
Correct Answer
D. Both a and c above
Explanation
The stack works on the principle of FILO or LIFO, which stands for "First In, Last Out" and "Last In, First Out" respectively. LIFO means, in a stack, the last element added is the first one to be removed. FILO means that the first item inserted into the stack will be the last one to be removed. In other words, the most recently added item is the first one to be removed from the stack. This principle is commonly used in computer science and data structures, where a stack is a collection of elements with a specific order of operations.
10.
The order of the binary search algorithm is
Correct Answer
C. N log n
Explanation
The order of the binary search algorithm is n log n. This means that the time complexity of the algorithm is proportional to the logarithm of the input size multiplied by the input size itself. In other words, as the size of the input increases, the time taken to perform the binary search also increases, but at a slower rate compared to a linear search algorithm. This is because binary search divides the search space in half with each iteration, making it more efficient than linear search.