Company: Amazon Offcampus Sde intern
Difficulty: medium
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?
What will be the output of the following program? class Node{ int key; Node left = null, right = null; Node(int key) { this.key = key; } } class Main { public static int height(Node root) { if (root == null) { return 0; } return 1 + Math.max(height(root.left), height(root.right)); } public static void main(String[] args){ Node root = null; root = new Node(15); root.left = new Node(10); root.right
Which of the following pseudocodes implements DFS?
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)?
Consider the following Java code using TreeMap: import java.util.*; class Maps { public static void main(String args[]) { TreeMap tm = new TreeMap(); tm.put("X", new Integer(1)); tm.put("Y", new Integer(2)); tm.put("Z", new Integer(3)); System.out.println(tm.entrySet()); } } What will be the correct output?
Find out the time complexity of given recurrence relation: T(n)={1 if n=1 ; 8T(n/2)+n² if n>1 }
Consider statements: S1 (Bellman-Ford finds negative cycles), S2 (Dijkstra works for negative cycles), S3 (Dijkstra works for positive cycles). Which are true?
Find the longest common subsequence Z of X = {A,A,A,C,B,B,C,D} and Y = {A,B,C,D,A,B}.
Match sorting complexities: a. Best case Selection Sort, b. Best case Insertion Sort, c. Insertion in heap, d. Worst case Heap-sort.
Find the Huffman code for 'M5' from the binary heap for the provided frequency data.
How should you assign an I/O scheduling class and priority to PID 8765 to resolve latency using ionice?
Which command will you include in a backup script to create a compressed archive of the root filesystem while excluding the backup directory?