Algorithms

Intermediate Test - Algorithms

Assess your command of merge sort, quicksort, hash tables, binary search trees, recursion, and BFS and DFS graph traversal.

Duration

Complete at your own pace or within the time limit

Questions

Multiple choice with one correct answer

Accuracy

Expert-reviewed questions with clear answer keys

Results

Instant detailed breakdown by topic area

Algorithms
Question 1/of
0%
00:00
Category
Difficulty:Medium

Loading Questions...

Preparing your assessment. This will only take a moment.

About This Algorithm Test

Assess your command of efficient algorithms and core data structures

This intermediate assessment covers advanced sorting (merge, quick, heap), BFS and DFS graph traversal, hash tables, stacks and queues, and introductory dynamic programming.

Questions test both time and space complexity reasoning and the ability to choose the right approach for a problem.

Results include a breakdown by topic area, helping you target the concepts that need more work.

What This Intermediate Test Assesses

Efficient Sorting

Questions cover merge sort at O(n log n) in all cases and quicksort, which averages O(n log n) but degrades to O(n^2) on poor pivots.

Hash Tables

You will be tested on hashing, collision handling with chaining or open addressing, and average O(1) lookup, insertion, and deletion.

Binary Search Trees

Items assess BST insertion, search, and in-order traversal, plus how an unbalanced tree can degrade operations toward O(n).

Recursion and Graph Traversal

This section evaluates recursive thinking and base cases alongside breadth-first and depth-first search over graphs and their queue or stack roles.

Sample Questions

A few real questions from this test, with answers and explanations. Take the full test above for the complete set.

Merge Sort divides the array into halves recursively. How many levels of recursion are there for an array of n elements?

Answer: log n

Each level halves the array. Starting with n, then n/2, n/4, ... down to 1. The number of halving steps is log2(n). At each level, the total merge work is O(n), giving O(n log n) overall.

Which problem is best solved using dynamic programming?

Answer: Computing the Fibonacci sequence efficiently

Fibonacci has overlapping subproblems: fib(5) calls fib(4) and fib(3), but fib(4) also calls fib(3). Dynamic programming stores computed values, reducing time from O(2^n) to O(n).

BFS finds the shortest path in an unweighted graph because it:

Answer: Explores all nodes at distance d before distance d+1

BFS uses a queue to process nodes level by level. All nodes at distance 1 are visited before distance 2, and so on. The first time BFS reaches a node, it has found the shortest path to that node.

Quick Sort's worst case occurs when:

Answer: The pivot is always the smallest or largest element

When the pivot is always the extreme value, one partition has n-1 elements and the other has 0. This creates n levels of recursion instead of log n, degrading to O(n^2). Randomized pivot selection avoids this.

A hash table has average-case O(1) lookup. Its worst case is:

Answer: O(n)

In the worst case, all keys hash to the same bucket, creating a chain of length n. Lookup then requires scanning this chain, taking O(n). Good hash functions and resizing minimize collisions.

Frequently Asked Questions

Find answers to common questions about this assessment

Merge sort guarantees O(n log n) time in every case and is stable, but needs O(n) extra space. Quicksort averages O(n log n) and sorts in place, yet can hit O(n^2) with bad pivots. Randomized or median pivots make quicksort reliably fast in practice.

A hash function maps a key directly to a bucket index, so on average you reach the value in constant time. Performance depends on a good hash and a low load factor. When many keys collide into one bucket, lookups can degrade toward O(n) in the worst case.

Use breadth-first search when you need the shortest path in an unweighted graph or the nearest nodes first, since it explores level by level using a queue. Use depth-first search for exploring full branches, detecting cycles, or topological ordering, since it dives deep using a stack or recursion.

A binary search tree gives O(log n) operations only when it stays balanced. If keys are inserted in sorted order, the tree becomes a long chain resembling a linked list, and search, insert, and delete degrade to O(n). Self-balancing trees prevent this worst case.

Scores are based on the number of correct answers divided by total questions, with a breakdown by topic category.

Yes, questions are randomly selected and ordered from our question bank to ensure each attempt is unique.

No account is required. You can take the test immediately. Optionally provide an email to save your results.

There is no pass/fail threshold. The test measures your knowledge level and provides detailed feedback for improvement.

For knowledge tests, we recommend answering without external help to get an accurate assessment. Practice exercises are designed for learning, so references are acceptable.

Our questions are written for structured educational practice and can give a useful snapshot of your current knowledge in the tested topics.

Ready to Test Your Knowledge?

Start the assessment now and discover your strengths