Why is inserting an element near the beginning or middle of a dynamic array typically ?
10 Data Structure and Algorithm Trade-offs Online Quiz Questions
Use this free practice quiz with 20 questions to review 10 Data Structure and Algorithm Trade-offs, test your knowledge, and prepare for your next test or exam.
True or false: In a linked list, inserting at a known node can be O(1), even though finding that node may take O(n).
- A
True
- B
False
What structure should be used when a program needs efficient insertion and removal at both the front and the rear?
Binary search requires data and takes comparisons in the usual analysis.
A program must repeatedly perform range queries and produce keys in sorted order. Which structure is the best general choice?
- A
A hash table, because it naturally maintains sorted order and supports range queries.
- B
A linked list, because range queries require scanning nodes in insertion order.
- C
A balanced tree, because it maintains sorted order, supports range queries, and has typical O(logn) search, insertion, and deletion.
- D
A stack, because its LIFO ordering provides efficient predecessor and successor queries.
True or false: A stable sorting algorithm preserves the relative order of records that have equal sort keys.
- A
True
- B
False
A task-processing system must add and remove tasks efficiently at either end of a sequence. What structure is most appropriate?
An LRU cache commonly combines a for key lookup with a for recency ordering.
A collection of n items is sorted once, followed by m binary searches. What is the total asymptotic time complexity?
- A
O(mn)
- B
O(n+m) in every implementation
- C
O(nlogm+mlogn)
- D
O(nlogn+mlogn)
A service stores records by unique identifier. Most requests look up one exact identifier, but some requests require sorted iteration and range queries. Explain when a hash table is preferable, when a balanced tree is preferable, and what trade-offs should guide the final choice.
A scheduler repeatedly needs to retrieve the task with the highest priority. Which structure is the most appropriate primary choice?
- A
A linked list, because it provides constant-time access to every priority value.
- B
A heap or priority queue, because it is designed to retrieve the next highest- or lowest-priority item efficiently.
- C
A hash table, because hashing automatically returns the numerically smallest key.
- D
A stack, because LIFO order is equivalent to priority order.
A program sorts an array of n items once and then performs m binary searches on it. What is the total asymptotic time complexity?
- A
O(mn)
- B
O(nlogn+mlogn)
- C
O(n+m) in the worst case
- D
O(nlogm)
A program needs fast exact lookup by record ID and efficient sequential processing of all records. Which combined design best fits these requirements, assuming records may move within the main storage?
- A
A stack and a queue
- B
A balanced tree and a heap
- C
A dynamic array and a hash table mapping IDs to indices
- D
A linked list and a binary search tree
A system must repeatedly retrieve all keys within specified ranges and iterate through the keys in sorted order. Which structure is the best primary choice?
- A
A balanced tree
- B
A hash table
- C
A stack
- D
A basic array
A singly linked list must insert an item after a node that is identified only by its value. Which complexity statement is most accurate for the complete insertion task?
- A
The entire operation is always O(1) because linked lists never move elements.
- B
The entire operation is always O(logn) because links provide direct access.
- C
The operation is always O(n2) because each node has a link.
- D
The link update is O(1) after locating the node, but locating it may make the total O(n).
True or false: A recursive binary search on a sorted array has recurrence T(n)=T(n/2)+O(1), so its running time is O(logn).
- A
True
- B
False
What is the worst-case time complexity of a linear search through an unsorted collection of n items?
What is the usual complexity description for appending to a dynamic array over a long sequence of append operations?
Select all statements that accurately describe hash-table trade-offs.
- A
Lookup is guaranteed O(1) even when all keys collide.
- B
A hash table always maintains keys in sorted order.
- C
Expected lookup, insertion, and deletion can be O(1) with a good hash function and controlled load factor.
- D
The worst case can be O(n), and sorted-order operations are not naturally supported.
Which properties are required for a correct recursive function? Select all that apply.
- A
A base case that can return without another recursive call
- B
Progress toward the base case on each recursive call
- C
A rule for combining recursive results into the final result
- D
A hash table for storing every previously visited input
Related study packs and tools
03 — Python Programming Fundamentals
A focused set of flashcards covering Python variables, data types, expressions, control flow, functions, input, output, and common programming practices.
04 Conditionals and Boolean Logic
Learn how Boolean expressions, logical operators, and conditional structures let programs make reliable decisions, including how to handle boundaries, branch order, and testing.
05 — Data Structures: Concepts, Operations, and Trade-Offs
A structured guide to the main data structures, their operations, efficiency trade-offs, representations, and practical selection criteria.
6 Trees and Binary Search Trees
A 14-question quiz on trees, binary trees, traversals, recursive algorithms, and binary search trees. The questions progress from foundational concepts to applied reasoning about structure, complexity, and BST operations.
9 Sorting Algorithms
A structured guide to comparison-based sorting algorithms, their complexity, stability, memory use, and practical selection criteria.
10 — Data, Systems, and Applications
A progression through how data is organized, searched, exposed through software interfaces, and managed through abstraction layers in modern computer systems.
12 — Foundations Capstone
A medium-difficulty quiz on integrating problem definition, representation, algorithms, complexity analysis, testing, correctness, ethical evaluation, and documentation in a computer science capstone.
12 — Foundations Capstone: Integrating Computer Science
A practical guide to integrating problem definition, data representation, modular programming, algorithms, complexity analysis, testing, correctness, and ethical evaluation into a responsible computer science capstone.
OS Processes
This quiz covers process management, context switching and scheduling, multitasking, traps and interrupts, and RISC-V privilege transitions.