1) If the element “A”, “B”. “C”, & “D” are Placed in a queue and are deleted one at a time, in what order they will be removed?
Ans: ABCD
2) Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?
Ans: Merge sort
3) What is the output of following function for start pointing to first node of following linked list?
1->2->3->4->5->6
Ans: 1 3 5 5 3 1
4) Which of the following can be the base case for the recursive implementation used to find the length of linked list?
Ans: if(current_node == 0) return 0
5) Which of the following is true about linked list implementation of queue?
Ans: Both a and b
6) What is the time complexity of the following iterative implementation used to find the length of a linked list?
Ans: o(n)
7) Above function takes a Queue as an argument and uses a stack S to do processing.
What does the above function do in general?
Ans: Reverses the Q
8) Is it possible to create a doubly linked list using only one pointer with every node?
Ans: Yes, possible by storing XOR of addresses of previous and next nodes
9) What are the time complexities of finding 8th element from beginning and 8th element from end in a singly linked list?
Let n be the number of nodes in linked list, you may assume that n > 8
Ans: o(1) and o(n)
10) A normal QUEUE, if implemented using an array of size MAX-SIZE, gets full when
Ans: Rear = MAX-SIZE - 1
11) Which of the following is not an application of Priority QUEUE?
Ans: BFS algorithm
12) New elements are added to the……… of the QUEUE?
Ans: Rear
13) Consider the following statements:
i. First-in-first out types of computations are efficiently supported by STACKS.
ii. Implementing LISTS on linked lists is more efficient than implementing LISTS on an array for almost all the basic LIST operations.
iii. Implementing QUEUES on a circular array is more efficient than implementing QUEUES on a linear array with two indices.
iv. Last-in-first-out type of computations are efficiently supported by QUEUES.
Which of the following is correct
Ans: (ii) and (iii) are true
14) The following C function takes a single-linked list of integers as a parameter and rearranges the elements of the list. The function is called with the list containing the integers 1, 2, 3, 4, 5, 6, 7 in the given order. What will be the contents of the list after the function completes execution?
struct node{int value;struct node *next;};void rearrange(struct node *list){struct node *p, * q;int temp;if ((!list) || !list->next)return;p = list;q = list->next;while(q){temp = p->value;p->value = q->value;q->value = temp;p = q->next;q = p?p->next:0;}}(code-box)
Ans: 2,1,4,3,6,5,7
15) What does the following Piece of code do?
Public object function ()
{
If (isEmphy ())
return –999;
else
{
Object high;
high = Queue[front]
return high;
{
{(code-box)
Ans:
Return of the Front element