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 
View Answer Report Discuss Too Difficult! Search Google 
Answer: (c).Both 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 
View Answer Report Discuss Too Difficult! Search Google 
Answer: (a).Full: (REAR+1) mod n == FRONT, empty: REAR == FRONT

43.  A PriorityQueue is implemented as a MaxHeap. Initially, it has 5 elements. The levelorder 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 levelorder 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 
View Answer Report Discuss Too Difficult! Search Google 
Answer: (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(stackempty(S2)) then if(stackempty(S1)) then { print(“Q is empty”); return; } else while (!(stackempty(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 
View Answer Report Discuss Too Difficult! Search Google 
Answer: (a).n+m <= x < 2n and 2m <= y <= n+m

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 n1 
b.  Prints numbers from n1 to 0 
c.  Prints first n Fibonacci numbers 
d.  Prints first n Fibonacci numbers in reverse order 
View Answer Report Discuss Too Difficult! Search Google 
Answer: (c).Prints first n Fibonacci numbers

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) 
View Answer Report Discuss Too Difficult! Search Google 
Answer: (a).Both operations can be performed in O(1) time

48.  Suppose you are given an implementation of a queue of integers. The operations that can be performed on the queue are:
i. isEmpty (Q) — returns true if the queue is empty, false otherwise. ii. delete (Q) — deletes the element at the front of the queue and returns its value. iii. insert (Q, i) — inserts the integer i at the rear of the queue. Consider the following function: void f (queue Q) { int i ; if (!isEmpty(Q)) { i = delete(Q); f(Q); insert(Q, i); } } What operation is performed by the above function f ? 
a.  Leaves the queue Q unchanged 
b.  Reverses the order of the elements in the queue Q 
c.  Deletes the element at the front of the queue Q and inserts it at the rear keeping the other elements in the same order 
d.  Empties the queue Q 
View Answer Report Discuss Too Difficult! Search Google 
Answer: (b).Reverses the order of the elements in the queue Q

49.  The following C declarations
struct node { int i; float j; }; struct node *s[10] ; define s to be 
a.  An array, each element of which is a pointer to a structure of type node 
b.  A structure of 2 fields, each field being a pointer to an array of 10 elements 
c.  A structure of 3 fields: an integer, a float, and an array of 10 elements 
d.  An array, each element of which is a structure of type node 
View Answer Report Discuss Too Difficult! Search Google 
Answer: (a).An array, each element of which is a pointer to a structure of type node

50.  The most appropriate matching for the following pairs
X: m=malloc(5); m= NULL; 1: using dangling pointers Y: free(n); n>value=5; 2: using uninitialized pointers Z: char *p; *p = ’a’; 3. lost memory is: 
a.  X—1, Y—3, Z 2 
b.  X—2 ,Y—1, Z 3 
c.  X—3, Y—2 ,Z1 
d.  X—3 ,Y—1, Z2 
View Answer Report Discuss Too Difficult! Search Google 
Answer: (d).X—3 ,Y—1, Z2
