Data structures and algorithms skill check
Check your data structures and algorithms: Big-O, hash tables, lists, stacks, trees and graphs, sorting, searching, and dynamic programming, with short code you reason about.
15
Questions
11 min
Timer can't pause
Multiple choice
One answer out of four
Choose a level
Topics
- Complexity
- Arrays and strings
- Hash tables
- Linked lists
- Stacks and queues
- Trees and graphs
- Sorting and searching
- Dynamic programming
Do
Use scratch paper or a notepad to work things out. Skip a question and come back to it later.
Don't
Look up answers during the check. Open the check in more than one tab or window.
Easy · 15 questions · 11 min
By starting, you agree to the Terms and Privacy Policy.
Practice checks each answer as you go, with an explanation. The exam is checked when you submit; 9 of 15 passes and earns a certificate.
Checking your levels…
Certificates come from the certified exam: pass with 9 of 15 while signed in. View a sample certificate.
Sample Data structures and algorithms questions with answers
These are never used in a check, so seeing their answers here won't give anything away.
Question 1 · Easy · Complexity
An algorithm finds the maximum value in an unsorted array of n numbers by inspecting each element once. What is its time complexity?- A.
O(n) - B.
O(n log n) - C.
O(1) - D.
O(log n)
Show answer
A.
O(n)To find the maximum element in an unsorted collection of size n, every single item must be checked at least once, requiring linear time, O(n).- A.
Question 2 · Easy · Hash tables
What is the primary performance risk when a hash function produces the same index for many distinct keys in a hash table (high collision rate)?- A.Data is permanently overwritten because buckets can only hold one element.
- B.The time complexity of calculating the hash code increases proportionally to the number of stored keys.
- C.
Lookup operations degrade from average O(1) toward O(n). - D.The hash table automatically throws an unrecoverable out-of-memory exception.
Show answer
C.
Lookup operations degrade from average O(1) toward O(n).When many keys collide, lookup requires traversing collision resolution structures such as linked chains or probing sequences, causing lookup time to degrade from O(1) on average to O(n) in the worst case.Question 3 · Moderate · Stacks and queues
When implementing a FIFO queue using two LIFO stacks (an in-stack and an out-stack), what is the amortized time complexity of the dequeue operation, and why?- A.O(log n), because elements are divided evenly between the two stacks
- B.O(1) strictly worst-case, because transfer between stacks takes constant overhead
- C.O(1), because each element is moved from in-stack to out-stack at most once across its lifetime
- D.O(n), because the out-stack must be repopulated from scratch during every dequeue call
Show answer
C. O(1), because each element is moved from in-stack to out-stack at most once across its lifetime
While an individual dequeue can take O(n) when transferring elements from the in-stack to the empty out-stack, each inserted element is pushed onto the in-stack once, popped once, pushed to the out-stack once, and popped from the out-stack once. Total operations per element across its lifetime are constant, yielding O(1) amortized time.Question 4 · Advanced · Arrays and strings
In the Knuth-Morris-Pratt (KMP) string matching algorithm, what does the failure function (often called the π or prefix table) store at index i for a pattern string P?- A.The index of the first character mismatch when aligning P against itself shifted by one.
- B.
The count of distinct characters occurring in the prefix P[0..i]. - C.The length of the longest proper prefix of P[0..i] that is also a suffix of P[0..i].
- D.The length of the longest substring of P[0..i] that matches any prefix of the target text.
Show answer
C. The length of the longest proper prefix of P[0..i] that is also a suffix of P[0..i].
By definition, π[i] stores the length of the longest proper prefix of P[0..i] that is also a suffix of P[0..i], allowing the search to skip redundant character comparisons.
How scoring and certificates work
- Each check has 15 multiple-choice questions with one correct answer, and one timer for the whole check. A question you leave unanswered scores nothing.
- Practice is free without an account and shows whether each answer is right as you go, with an explanation.
- The certified exam is scored when you submit. 60% passes, which is 9 of 15. Easy unlocks Moderate, and Moderate unlocks Advanced.
- Passing the exam while signed in earns a free certificate, valid for one year, with its own verification page. See a sample certificate.