# Algorithm engineer Interview Questions

# 443

Algorithm Engineer interview questions shared by candidates### If I have a jar with 1000 coins and one is double headed and I pick one coin randomly and flip 10 heads what is the probability it is the double headed coin?

4 Answers↳

You can use Bayes to get the real number, which is close to 0.5 (which you can see intuitively) . They wanted the exact number. Less

↳

@ Feb 4, You formula is correct, looks like typo. because 2^10=1024 so 1/(1+999/1024) ~= 1/2 (1*1/1000)/(1*1/1000+(1/2^10)*999/1000) Less

↳

Bayes. 10^-3/(10^-3 + 1/2^10 * (1-10^-3))

### Pretty much the same thing as the Microsoft one in this link. I wasted too much time on question 2 and didn't get a chance to submit an answer but I finished it for fun after the test. https://webcache.googleusercontent.com/search?q=cache:KocTw550s_UJ:https://leetcode.com/discuss/interview-question/760379/Microsoft-or-OA-2020-or-Word-Machine+&cd=1&hl=en&ct=clnk&gl=ru&client=safari

4 Answers↳

what was your aggregated total score? it shows on the codility report page like 30min after you finish Less

↳

37 aggregated total score

↳

yea codility is such bullcrap, i got all of them right on the surface, but i ended up with 78 agg score. they need to use hackerrank or something, codility just hides too much and we can't even see what we're doing wrong smh Less

### Asked how to find the kth largest element of a sequence of n elements.

3 Answers↳

First algorithm: sort the sequence in O(n log n) time and select the kth element. Second algorithm: construct a max-heap out of the n elements, which can be done in O(n) time and then repeatedly remove the largest element until you reach the kth element. This step takes O(k log n) time and so overall the algorithm runs in O(n + k log n) time. Third algorithm: Use quick select: partition the sequence using a random element as the pivot and recurse on the partition that contains the kth element, which you can determine based on the sizes of the two partitions. This runs in expected time O(n) and runs with high probability in O(n) time. It is also possible to extend this algorithm to run deterministically in O(n) time (see Deterministic Selection algorithm). Less

↳

The third algo is O(n)

↳

we can maintain a min-heap of size k, each time if new element is larger than min element in the heap, remove the root and heapify, otherwise don't update Less

### How do you find the pdf of the sum of two independent random variables?

3 Answers↳

Two integrals along the joint distribution of the the two random variables.

↳

Computing the convolution of the pdf of both random variables.

↳

Hey! Thanks for sharing your experience. I have this interview at the location, can you please tell more about the onsite questions? It will be great if you could kindly tell about the questions focusing on coding(was it all in C?), DSP, image processing and ML. Less

### Homework: Derive group delay of a non linear phase filter Write a program to shuffle cards in a particular manner until original order of cards has been reinstated.

2 Answers### Spaghetti in a bowl question. (Pick up one end of a spaghetti and you can either join it to the other end of the spaghetti you are holding which created a loop or you can pick any other end in the bowl and join it to that. Find the expected number of loops.) Another spaghetti question (I think the interviewer loved spaghetti): You have a plate of spaghetti in front of you (no sauce!). You pick two ends and tie them together. Then you pick two more ends and tie them together. Continue until there are no free ends left. If there were n spaghettis originally, what is the probability that you now have a single giant loop consisting of all the spaghettis?

2 Answers↳

^ how does this comment help anyone?

↳

Standard question. Just google it. I had seen this question while practicing some questions on the internet before the interview. Less

### What is the result of sampling and reconstructing a 2 khz tone with 3 khz sampling frequency?

2 Answers↳

You're re-sampling below the Nyquist frequency (4khz for a 2khz tone) and therefore would have aliasing in your signal. Less

↳

Hey! Thanks for sharing your experience. I have this interview at the location, can you please tell more about the onsite questions? It will be great if you could kindly tell about the questions focusing on coding(was it all in C?), DSP, image processing and ML. Less

### How would you design a program to calculate and store records for a paid parking lot

2 Answers↳

Did you do white board coding during onsite interview?

↳

Open-ended question that analyzed your expertise in OOP

### The multiplier is broken. Write a function in C to multiply two 16-bit integers.

2 Answers↳

Easiest bit shifts + addition. There are indeed better algorithms (Karatsuba, Tom-Cook), but not likely to write an implementation in 10 minutes or such. Less

↳

Hey! Thanks for sharing your experience. I have this interview at the location, can you please tell more about the onsite questions? It will be great if you could kindly tell about the questions focusing on coding(was it all in C?), DSP, image processing and ML. Less