Foundations of Data Structure and Algorithms Question Bank
Showing 39 questions of 39 with verified answers
(Conceptual) What is the primary purpose of Asymptotic Analysis in computer science?
(Calculation) What is the Big-O complexity of an algorithm that performs 3N² + 50N + 1000 operations?
(Scenario-Based) A developer is choosing between two search algorithms. Algorithm A is O(N) and Algorithm B is O(log N). For an input of 1,000,000 items, which is significantly more efficient?
(Code-Tracing) What is the time complexity of the following loop? for (int i = 1; i < n; i = i * 2) { // constant time operation }
(Conceptual) If an algorithm is said to have Amortized O(1) complexity for an operation, what does this mean?
(Code-Tracing) Analyze the complexity of this nested loop: for (int i = 0; i < n; i++) { for (int j = 0; j < 100; j++) { print(i, j); } }
(Conceptual) Which notation is used to describe the Best Case scenario of an algorithm's growth?
(Scenario-Based) An algorithm uses O(n) extra space to process an array of size n. If n increases from 1,000 to 1,000,000, what happens to the extra memory required?
(Calculation) What is the complexity of an algorithm that first sorts an array using Merge Sort (O(n log n)) and then performs a linear search (O(n)) on it?
(Debugging) A developer believes their algorithm is O(1) because it doesn't have any loops. However, inside the function, they call list.contains(item) on a list of size n. What is the actual complexity?
(Conceptual) In Big-O analysis, which of the following functions grows the slowest?
(Code-Tracing) What is the time complexity of a recursive function that calls itself twice with (n-1) each time? (e.g., f(n) { f(n-1); f(n-1); })
(Conceptual) When an algorithm is Θ(n log n), it means:
(Calculation) An algorithm has a complexity of O(n²). If it takes 0.1 seconds to process 1,000 items, how long will it take to process 10,000 items?
(Scenario-Based) You have an algorithm that uses a significant amount of extra RAM (O(n)) to achieve a very fast runtime (O(1)). This is a classic example of:
(Conceptual) Why is accessing an element by index in a standard Array an O(1) operation?
(Code-Tracing) Trace the result of these Stack operations: Push(10), Push(20), Pop(), Push(30), Peek().
(Scenario-Based) Which data structure is most efficient for a "Undo" feature in a text editor?
(Conceptual) What is the time complexity of deleting the first element of a standard Array of size N?
(Calculation) In a 64-bit system, a Singly Linked List node stores an int (4 bytes) and a next pointer (8 bytes). What is the total memory used by 100 nodes?
(Conceptual) Which structure uses the FIFO (First-In-First-Out) principle?
(Scenario-Based) An application needs to store 1,000,000 records. It performs millions of middle-insertions but zero random-access lookups. Which is best?
(Code-Tracing) In a Circular Queue of size 5, if front = 4 and rear = 4 (full), and one item is dequeued, what is the new front?
(Conceptual) Why are Strings often Immutable in modern languages like Java?
(Comparison) What is the primary advantage of a Doubly Linked List over a Singly Linked List?
(Debugging) A programmer implements a Queue using an array. After many enqueues and dequeues, the "Queue Full" error triggers even though the array is mostly empty. Why?
(Scenario-Based) A function needs to check if a sequence of brackets {[()]} is Balanced. Which structure should it use?
(Calculation) What is the 1D index of M[2][3] in a Row-Major array of size [5] [10]?
(Conceptual) What happens in a Null Pointer Dereference?
(Scenario-Based) You need to reverse a string. Which approach is most space- efficient?
(Conceptual) In a Linked List, what does head.next = head.next.next effectively do?
(Code-Tracing) A Queue is implemented using two Stacks (S1 for Enqueue, S2 for Dequeue). If S2 is empty, what must happen before a Dequeue?
(Comparison) Why is a Deque more versatile than a standard Queue?
(Conceptual) What is a Sentinel Node?
(Scenario-Based) An OS needs to manage a list of processes waiting for the CPU in order of arrival. Which structure is standard?
(Code-Tracing) What is the Top of the stack after: Push(A), Push(B), Pop(), Push(C)?
(Calculation) How many pointers are updated when inserting a node into the middle of a Singly Linked List?
(Conceptual) What is Cache Locality and why do Arrays have it?
(Scenario-Based) You need to store a very long string that you will frequently modify (insert/delete in the middle). Which is most efficient?