



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




This quiz is designed for exam preparation, concept revision, and academic practice in Data Structures and Algorithms.
(Based on Arrays, Linked Lists, Stacks, and Queues)
Q1. What is the time complexity of accessing an element in an array using index? A. O(n) B. O(log n) C. O(1) D. O(n log n)
Answer: C. O(1)
Q2. Which data structure is most suitable for implementing recursion? A. Queue B. Array C. Stack D. Linked List
Answer: C. Stack
Q3. In a queue, insertion and deletion take place at: A. Same end B. Front only C. Rear only D. Rear and front respectively
Answer: D. Rear and front respectively
Q4. Which of the following is NOT a type of linked list? A. Singly linked list B. Doubly linked list C. Circular linked list D. Binary linked list
Answer: D. Binary linked list
Q5. Which data structure allows insertion and deletion from both ends? A. Stack B. Queue C. Deque D. Array
Answer: C. Deque
Q6. Define stack. A stack is a linear data structure that follows the Last In First Out (LIFO) principle, where insertion and deletion occur at the same end called the top.
Q7. What is a circular queue? A circular queue is a queue in which the last position is connected back to the first position to efficiently utilize memory.
Q8. What is the difference between linear search and binary search? Linear search checks elements one by one, whereas binary search divides the sorted list into halves to search efficiently.
Q9. Write the algorithm for deleting an element from a stack.
Q10. Write the algorithm for dequeue operation in a queue.
#include <stdio.h>
#define SIZE 5
int queue[SIZE];
int front = -1, rear = -1;
void enqueue(int x) {
if(rear == SIZE - 1)
return;
if(front == -1) front = 0;
queue[++rear] = x;
}
void dequeue() {
if(front == -1 || front > rear)
return;
front++;
}
int main() {
enqueue(10);
enqueue(20);
dequeue();
printf("Front element: %d", queue[front]);
return 0;
}
Q13. Why are linked lists preferred over arrays in certain situations? Linked lists allow dynamic memory allocation and efficient insertion and deletion operations without shifting elements.
Q14. Explain overflow and underflow conditions. Overflow occurs when insertion is attempted on a full data structure, while underflow occurs when deletion is attempted on an empty data structure.