Amazon Interview Question for SDE-3s


Country: United States




Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Select a control/master server. Probably the one with the least IP addr. Standard protocol, not a big deal.[something similar to the spaning tree protocol would do]
2. Control/master server selects a pivot from its own array and broadcasts the value to the est
3. Each slave server partitions its own array based on this pivot value and sends the left , central and right count to the master server.
4. Based on the total number of elements in each slave server and those that the master itself has, master selects one of the left, or right partitions to work on . Each of the slave servers will now be working on this partition.
5. if total_left_count>=n/2: work on left partitions;repeat 2 to 4
else If total_left_count+total_central_count<=n/2: pivot is the median;
Else work on right partition; repeat 2 to 4

- nitsal August 15, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Select a control/master server. Probably the one with the least IP addr. Standard protocol, not a big deal.[something similar to the spaning tree protocol would do] 
2. Control/master server selects a pivot from its own array and broadcasts the value to the est 
3. Each slave server partitions its own array based on this pivot value and sends the left , central and right count to the master server. 
4. Based on the total number of elements in each slave server and those that the master itself has, master selects one of the left, or right partitions to work on . Each of the slave servers will now be working on this partition. 
5. if total_left_count>=n/2: work on left partitions;repeat 2 to 4 
else If total_left_count+total_central_count<=n/2: pivot is the median; 
Else work on right partition; repeat 2 to 4

- nits August 15, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Server Set = {s1, s2, ... sn}
Data almost evenly distributed

Take a random number r1 from any server and broadcast to all the servers.
Each server partition their dataset into two parts

where => partition 1 > r1 and parition 2 < r1

For each set get the size of partition1 and partition2
S1=> p11 and p12
S1=> p21 and p22
.
.
Sn=> pn1 and pn2

Location of mediam = sum (P11,P12...pn1,pn2)/2 = k

if sum(pi1) < k then k k - sum(pi1)-k

- anshuman101 February 12, 2020 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More