Contents

Which of the following array element will return the top-of-the-stack-element for a stack of size N elements(capacity of stack > N)?
a) S[N-1]                               
b) S[N]
c) S[N-2]                               
d) S[N+1]

a

Explanation: Array indexing start from 0, hence N-1 is the last index.


What is the best case time complexity of deleting a node in a Singly Linked list?
a) O (n)                                 
b) O (n2)
c) O (nlogn)                          
d) O (1)

d

Explanation: Deletion of the head node in the linked list is taken as the best case. The successor of the head node is changed to head and deletes the predecessor of the newly assigned head node. This process completes in O(1) time.


Which of the following properties is associated with a queue?
a) First In Last Out
b) First In First Out
c) Last In First Out
d) Last In Last Out

b

Explanation: Queue follows First In First Out structure.


In a circular queue, how do you increment the rear end of the queue?
a) rear++
b) (rear+1) % CAPACITY
c) (rear % CAPACITY)+1 
d) rear–

b

Explanation: Ensures rear takes the values from 0 to (CAPACITY-1).


What is the term for inserting into a full queue known as?
a) overflow                         
b) underflow
c) null pointer exception
d) program won’t be compiled

a

Explanation: Just as stack, inserting into a full queue is termed overflow.


What is the time complexity of enqueue operation?
a) O(logn)                             
b) O(nlogn)
c) O(n)                                   
d) O(1)

d

Explanation: Enqueue operation is at the rear end, it takes O(1) time to insert a new item into the queue.