Skip to content
The Lumenary

Practice · Early undergraduate

Algorithm design and analysis

Algorithm design and analysis

Warm-upHuman

Two sorted lists have lengths 55 and 77. What is the largest number of comparisons the merging procedure can need to merge them?

Algorithm design and analysis

Warm-upHuman

What is the decision-tree lower bound ⌈log⁡2n!⌉\lceil \log_2 n! \rceil on the worst-case number of comparisons needed to sort n=5n = 5 distinct items?

Algorithm design and analysis

CoreHuman

Mergesort's worst-case comparison count satisfies C(1)=0C(1) = 0 and C(n)=2C(n/2)+n−1C(n) = 2C(n/2) + n - 1 for nn a power of two. Compute C(8)C(8).

Algorithm design and analysis

CoreHuman

The network of towns in the Explore section has these cable costs: AB=4AB = 4, AC=1AC = 1, BC=2BC = 2, BD=5BD = 5, CD=8CD = 8, CE=10CE = 10, DE=3DE = 3. Run Kruskal's algorithm. What is the total cost of the minimum spanning tree?

Algorithm design and analysis

CoreHuman

Run Dijkstra's algorithm from ss on the directed graph with edges s→as \to a (weight 11), s→bs \to b (weight 22) and b→ab \to a (weight −2-2). What does it report for aa?

Choose one

Algorithm design and analysis

CoreHuman

In the proof of Theorem 5 (Dijkstra), which step uses the hypothesis that all edge weights are non-negative?

Choose one

Algorithm design and analysis

CoreHuman

Suppose a currency has coins worth 11, 44 and 55. For which amount does the greedy method (always use the largest coin that fits) not use the fewest coins?

Choose one

Algorithm design and analysis

CoreHuman

What is the length of a longest common subsequence of AGGTAB and GXTXAYB?

Algorithm design and analysis

CoreFormal

Which specification correctly says that a Lean function sort : List ℕ → List ℕ is a sorting function? (Sorted l means each entry is ≤ the later ones; l₁ ~ l₂ means l₁ is a permutation of l₂.)

Choose one

Algorithm design and analysis

StretchComputational

Write lcs_length(x, y) that returns the length of a longest common subsequence of the strings x and y, by filling the dynamic-programming table of Theorem 6 in O(mn)O(mn) time.

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.