 A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

 41. Which of the following is true about linked list implementation of queue? a. In push operation, if new nodes are inserted at the beginning of linked list, then in pop operation, nodes must be removed from end. b. In push operation, if new nodes are inserted at the end, then in pop operation, nodes must be removed from the beginning. c. Both of the above d. None of the above

 42. Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operation are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are a. Full: (REAR+1) mod n == FRONT, empty: REAR == FRONT b. Full: (REAR+1) mod n == FRONT, empty: (FRONT+1) mod n == REAR c. Full: REAR == FRONT, empty: (REAR+1) mod n == FRONT d. Full: (FRONT+1) mod n == REAR, empty: REAR == FRONT

 43. A Priority-Queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-order traversal of the heap is given below: 10, 8, 5, 3, 2 Two new elements ”1‘ and ”7‘ are inserted in the heap in that order. The level-order traversal of the heap after the insertion of the elements is: a. 10, 8, 7, 5, 3, 2, 1 b. 10, 8, 7, 2, 3, 1, 5 c. 10, 8, 7, 1, 2, 3, 5 d. 10, 8, 7, 3, 2, 1, 5

 44. An implementation of a queue Q, using two stacks S1 and S2, is given below: void insert(Q, x) {    push (S1, x); }    void delete(Q){    if(stack-empty(S2)) then       if(stack-empty(S1)) then {           print(“Q is empty”);           return;       }       else while (!(stack-empty(S1))){           x=pop(S1);           push(S2,x);       }    x=pop(S2); } Let n insert and m (<=n) delete operations be performed in an arbitrary order on an empty queue Q. Let x and y be the number of push and pop operations performed respectively in the process. Which one of the following is true for all m and n? a. n+m <= x < 2n and 2m <= y <= n+m b. n+m <= x < 2n and 2m<= y <= 2n c. 2m <= x < 2n and 2m <= y <= n+m d. 2m <= x <2n and 2m <= y <= 2n

 45. Consider the following pseudo code. Assume that IntQueue is an integer queue. What does the function fun do? void fun(int n) { IntQueue q = new IntQueue(); q.enqueue(0); q.enqueue(1); for (int i = 0; i < n; i++) { int a = q.dequeue(); int b = q.dequeue(); q.enqueue(b); q.enqueue(a + b); ptint(a); } } a. Prints numbers from 0 to n-1 b. Prints numbers from n-1 to 0 c. Prints first n Fibonacci numbers d. Prints first n Fibonacci numbers in reverse order

 46. Suppose implementation supports an instruction REVERSE, which reverses the order of elements on the stack, in addition to the PUSH and POP instructions. Which one of the following statements is TRUE with respect to this modified stack? a. A queue cannot be implemented using this stack b. A queue can be implemented where ENQUEUE takes a single instruction and DEQUEUE takes a sequence of two instructions c. A queue can be implemented where ENQUEUE takes a sequence of three instructions and DEQUEUE takes a single instruction d. A queue can be implemented where both ENQUEUE and DEQUEUE take a single instruction each
 View Answer Report Discuss Too Difficult! Search Google Answer: (c).A queue can be implemented where ENQUEUE takes a sequence of three instructions and DEQUEUE takes a single instruction

 47. A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are performed efficiently. Which one of the following statements is CORRECT (n refers to the number of items in the queue)? a. Both operations can be performed in O(1) time b. At most one operation can be performed in O(1) time but the worst case time for the other operation will be Ω(n) c. The worst case time complexity for both operations will be Ω(n) d. Worst case time complexity for both operations will be Ω(log n)