STK - Q Quiz

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 21

C – quiz

......... form of access is used to add and remove nodes


from a queue.

A. LIFO, Last In First Out

B. FIFO, First In First Out

C. Both a and b

D. None of these

2
In linked representation of stack ....... holds the
elements of the stack.

A. INFO fields

B. TOP fields

C. LINK fields

D. NULL fields

3
........ form of access is used to add remove nodes from a
stack.

A. LIFO

B. FIFO

C. Both A and B

D. None of these

4
Which one of the following is an application of Queue
Data Structure?

A When a resource is shared among multiple


consumers.
B When data is transferred asynchronously (data not
necessarily received at same rate as sent) between two
processes
C Load Balancing
D All of the above

5
How many stacks are needed to implement a queue.
Consider the situation where no other data structure like
arrays, linked list is available to you.

A 1
B 2
C 3
D 4

6
A priority queue can efficiently implemented using
which of the following data structures? Assume that the
number of insert and peek (operation to see the current
highest priority item) and extraction (remove the
highest priority item) operations are almost same.

A Array
B Linked List
C Heap Data Structures like Binary Heap, Fibonacci
Heap
D None of the above

7
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

8
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

9
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

10
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);
}

11
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

12
Consider the following operation along with Enqueue and
Dequeue operations on queues, where k is a global
parameter.
MultiDequeue(Q){
m=k
while (Q is not empty and m > 0) {
Dequeue(Q)
m=m-1
}
}
What is the worst case time complexity of a sequence of n
MultiDequeue() operations on an initially empty queue?

13
The way in which the data item or items are logically
related defines .....

A. storage structure
B. data structure
C. data relationship
D. data operation

14
Which of the following are the operations applicable an
primitive data structures?

A. create
B. destroy
C. update
D. all of the above

15
The condition ........ indicate the queue is empty.

A. Front=Null
B. Null=Front
C. Front=Rear
D. Rear=Null

16
17
18
19
20
21

You might also like