quantitative researcher interview questions shared by candidates
Minimize the number of comparisons for finding minimum and maximum of a given set of numbers.
Given n numbers, the optimal number of comparison should be 3n/2 Pairwise compare all numbers = n/2 comparisons It is easy to see that the max, min lies among the n/2 elements which are greater, smaller respectively. Pairwise compare the n/2 greater elements = n/4 comparisons. Again pairwise compare the n/4 greater elements obtained in previous step = n/8 comparions. ... You get max(min) in n/4+n/8+...1 = n/2 comparisons. initial comparisons = n/2 comparisons to get max number = n/2 comparisons to get min number = n/2 Total = 3n/2
Here is matlab code according to the suggested algorithm : clear; clc; vec=[3,8,7,2,1,6,5,4]; [max12,min12]=max_min(vec(1),vec(2)); [max34,min34]=max_min(vec(3),vec(4)); [max56,min56]=max_min(vec(5),vec(6)); [max78,min78]=max_min(vec(7),vec(8)); [max1234,~]=max_min(max12,max34); [max5678,~]=max_min(max56,max78); [max12345678,~]=max_min(max1234,max5678); fprintf('max=%d\n',max12345678); % Find Min [~,min1234]=max_min(min12,min34); [~,min5678]=max_min(min56,min78); [~,min12345678]=max_min(min1234,min5678); fprintf('min=%d\n',min12345678);
More on the above analytic solution: The resulting sequence is geometric with missing first two terms, n + n/2. Sum of a geometric sequence n + n/2 + n/4 + ... + 1 = 2n So for the present sequence: sum = 2n - n - n/2 = n/2 Thus the minimum number of steps required for finding BOTH the minimum and maximum of the set of numeric values is 3n/2. However, to calculate only minimum or maximum, the minimum number of steps would be (n-1) by pairwise comparison.
The interviewer first asked me to briefly introduce myself...Then went on to my resume and told me to tell about one of my projects....Then i had like 3 coding questions ....i was asked to tell the algorithm and the pesudo code...Others was a simple check on the basics and then a few probability questions
If there consist of two pipes connected to a tank in which one pipe is used to inject water to the tank at the rate of 2L/hr and the other pipe is used to eject water at the rate of 3L/hr.when do the tank completely fill?
See Interview Questions for Similar Jobs
- Software Engineer
- Business Analyst
- Research Analyst
- Senior Software Engineer
- Data Analyst
- Software Developer
- Product Manager
- Technology Analyst
- Management Trainee
- Data Scientist
- Research Associate