Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

[INTERVIEW] Quicksort #17

Open
Nanodesy opened this issue Apr 25, 2021 · 0 comments
Open

[INTERVIEW] Quicksort #17

Nanodesy opened this issue Apr 25, 2021 · 0 comments
Assignees
Labels
interview questions Interview questions from Algorithms course

Comments

@Nanodesy
Copy link
Owner

Quicksort

Question 1. Nuts and bolts.

A disorganized carpenter has a mixed pile of n nuts and n 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 to n log(n) compares (probabilistically).

Question 2. Selection in two sorted arrays.

Given two sorted arrays a[] and b[], of lengths n1 and n2 and an integer 0 ≤ k < (n1+n2), design an algorithm to find a key of rank k. The order of growth of the worst case running time of your algorithm should be n log(n), where n = (n1+n2).

  • Version 1: n1= n2 (equal length arrays) and k=n/2 (median).
  • Version 2: k=n/2 (median).
  • Version 3: no restrictions.

Question 3. Decimal dominants.

Given an array with n keys, design an algorithm to find all values that occur more than n/10 times. The expected running time of your algorithm should be linear.

@Nanodesy Nanodesy added the interview questions Interview questions from Algorithms course label Apr 25, 2021
@Nanodesy Nanodesy added this to the Algorithms, Part I milestone Apr 25, 2021
@Nanodesy Nanodesy self-assigned this Apr 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
interview questions Interview questions from Algorithms course
Projects
None yet
Development

No branches or pull requests

1 participant