Company: Amazon Offcampus Sde intern

Difficulty: medium

Problem Statement

Question 1

Five values are inserted in a hash table with size 20. Chaining is used to resolve the hash collisions. If the method used for insertion is uniform hashing, then what is the probability that no value is stored in the first 5 slots?

Question 2

What will be the output of the Java program calculating the height of a binary tree with 7 nodes (root 15, children 10, 20, and leaves 8, 12, 16, 25)?

Question 3

Which of the following pseudocodes implements DFS?

Question 4

The function 'solve' implements Selection Sort. Given the array {33, 54, 65, 34, 79, 23, 13, 19}, what is the array obtained after the 2nd iteration (i=1)?

Question 5

What is the output of tm.entrySet() for a TreeMap containing (X,1), (Y,2), (Z,3)?

Question 6

Find out the time complexity of given recurrence relation: T(n)={1 if n=1 ; 8T(n/2)+n² if n>1 }

Question 7

Consider statements: S1 (Bellman-Ford finds negative cycles), S2 (Dijkstra works for negative cycles), S3 (Dijkstra works for positive cycles). Which are true?

Question 8

Find the longest common subsequence Z of X = {A,A,A,C,B,B,C,D} and Y = {A,B,C,D,A,B}.

Question 9

Match sorting complexities: a. Best case Selection Sort, b. Best case Insertion Sort, c. Insertion in heap, d. Worst case Heap-sort.

Question 10

Find the Huffman code for 'M5' from the binary heap for the provided frequency data.

Question 11

How should you assign an I/O scheduling class and priority to PID 8765 to resolve latency using ionice?

Question 12

Which command will you include in a backup script to create a compressed archive of the root filesystem while excluding the backup directory?

More Amazon Offcampus Sde intern OA questionsInterview experiences