ICC Data Structures and Algorithms 2 — Questions and Answers
Question 1: Which data structure operates on a Last-In-First-Out (LIFO) principle?
- Queue
- Stack (Correct answer)
- Deque
- Priority Queue
Correct answer: Stack
A stack follows LIFO, meaning the last element added is the first one removed.
Question 2: What is the time complexity of accessing an element by index in an array?
- O(n)
- O(log n)
- O(1) (Correct answer)
- O(n²)
Correct answer: O(1)
Array elements are stored in contiguous memory, so index-based access is O(1) (constant time).
Question 3: In a singly linked list, each node contains:
- Only the data value
- Data and a pointer to the previous node
- Data and a pointer to the next node (Correct answer)
- Two pointers: next and previous
Correct answer: Data and a pointer to the next node
A singly linked list node stores data and a single pointer to the next node in the sequence.
Question 4: Which operation removes and returns the front element of a queue?
- Push
- Pop
- Enqueue
- Dequeue (Correct answer)
Correct answer: Dequeue
Dequeue removes and returns the element at the front of the queue, following FIFO order.
Question 5: What is the worst-case time complexity of searching for an element in an unsorted array?
- O(1)
- O(log n)
- O(n) (Correct answer)
- O(n log n)
Correct answer: O(n)
In the worst case, you must examine every element before finding the target or confirming its absence.
Question 6: A circular linked list differs from a standard linked list because:
- It has no head node
- The last node points back to the first node (Correct answer)
- Each node has two data fields
- It stores elements in sorted order
Correct answer: The last node points back to the first node
In a circular linked list, the last node's next pointer points back to the head, forming a loop.
Question 7: Which data structure is most appropriate for implementing function call management in a program?
- Queue
- Graph
- Stack (Correct answer)
- Hash Table
Correct answer: Stack
A call stack uses the stack structure to track active function calls, returning control in LIFO order.
Which data structure operates on a Last-In-First-Out (LIFO) principle?