This repository has been archived by the owner on Sep 6, 2024. It is now read-only.
[INTERVIEW] Quicksort #17
Labels
interview questions
Interview questions from Algorithms course
Milestone
Quicksort
Question 1. Nuts and bolts.
A disorganized carpenter has a mixed pile of
n
nuts andn
bolts. The goal is to find the corresponding pairs of nuts and bolts. Each nut fits exactly one bolt and each bolt fits exactly one nut. By fitting a nut and a bolt together, the carpenter can see which one is bigger (but the carpenter cannot compare two nuts or two bolts directly). Design an algorithm for the problem that uses at most proportional ton log(n)
compares (probabilistically).Question 2. Selection in two sorted arrays.
Given two sorted arrays
a[]
andb[]
, of lengthsn1
andn2
and an integer0 ≤ k < (n1+n2)
, design an algorithm to find a key of rankk
. The order of growth of the worst case running time of your algorithm should ben log(n)
, wheren = (n1+n2)
.n1
=n2
(equal length arrays) andk=n/2
(median).k=n/2
(median).Question 3. Decimal dominants.
Given an array with
n
keys, design an algorithm to find all values that occur more thann/10
times. The expected running time of your algorithm should be linear.The text was updated successfully, but these errors were encountered: