Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

ALGORITHMS

(Practice Session – 2)
SATYA NARAYANA KAITEPALLI (SNK)

❖ B.Tech, M.Tech, (Ph.D.)


❖ 13+ Years of Experience
❖ CS Senior Faculty
❖ Mentored 20000+ Students
❖ GATE Qualified
❖ SET Qualified
❖ CISCO Certified
❖ Areas Of Expertise : COA, CN, OS, DS, ALGORITHMS
Practice Session 2 – ALGORITHMS
Surveying

Consider a hash table that has 8 slots. If The Elements 127, 103,
Question No. 21 192, 257, 65, 73, 513, 313 has to be stored in the hash table using
linear probing. Then, The Element 313 will be stored in ______
Memory Slot.

A. 0 B. 7 C. 6 D. 1
Practice Session 2 – ALGORITHMS
Surveying

Which Of the below technique is called as Open Hashing?


Question No. 22

A. Linear Probing
B. Quadratic Probing
C. Double Hashing
D. Separate Chaining
Practice Session 2 – ALGORITHMS
Surveying

Which Of the below technique is Not an Open addressing


Question No. 23
Technique?

A. Linear Probing
B. Quadratic Probing
C. Double Hashing
D. Separate Chaining
Practice Session 2 – ALGORITHMS
Surveying

Which of the Following is Correct Representation for Quadratic


Question No. 24
Probing?

A. h (k , i) = (h' (k) + c1i+ c2) mod m


B. h (k , i) = (h' (k) + c1+ c2i) mod m
C. h (k , i) = (h' (k) + c1i2+ c2i) mod m
D. h (k , i) = (h' (k) + c1i1+ c2i2) mod m
Practice Session 2 – ALGORITHMS
Surveying

The Recurrence Relation for Binary Search Algorithm is __


Question No. 25

A. T(n) = 2T(n) + 1
B. T(n) = T(n/2) + 1
C. T(n) = 2T(n/2) + 1
D. T(n) = T(n) + 1
Practice Session 2 – ALGORITHMS
Surveying

The Recurrence Relation for Merge Sort Algorithm is __


Question No. 26

A. T(n) = 2T(n) + O(n)


B. T(n) = T(n/2) + O(n)
C. T(n) = 2T(n/2) + O(n)
D. T(n) = T(n) + O(n)
Practice Session 2 – ALGORITHMS
Surveying

The Recurrence Relation for Quick Sort Algorithm in Worst Case


Question No. 27
is __

A. T(n) = T(n-2) + O(n)


B. T(n) = T(n-1) +O(n)
C. T(n) = 2T(n - 1) + O(n)
D. T(n) = 2T(n) + O(n2)
Practice Session 2 – ALGORITHMS
Surveying

The Recurrence Relation for Quick Sort Algorithm in Best Case


Question No. 28
is __

A. T(n) = T(n-2) + O(n)


B. T(n) = 2T(n/2) +O(n)
C. T(n) = T(n /2) + O(n)
D. T(n) = 2T(n/2) + O(n2)
Practice Session 2 – ALGORITHMS
Surveying

Consider a Hash Table of size 15 Slots having 12 elements in it.


The Load factor is ______
Question No. 29

A. 1.25
B. 0.8
C. 0.6
D. 1.5
Practice Session 2 – ALGORITHMS
Surveying

The Towers Of Hanoi problem with ‘n’ disks can be solved using
Question No. 30 _____ Steps.
A. 2n
B. n2
C. 2n-1
D. n2-1
Practice Session 2 – ALGORITHMS
Surveying

The Time Complexity Of Fibonacci Series Using recursion method


Question No. 31 is _____

A. O(2n)
B. O(logn)
C. O(nlogn)
D. O(n)
Practice Session 2 – ALGORITHMS
Surveying

The Time Complexity Of Fibonacci Series Using Dynamic


Question No. 32 Programming is _____

A. O(2n)
B. O(logn)
C. O(nlogn)
D. O(n)
Practice Session 2 – ALGORITHMS
Surveying

Bellman – Ford Algorithm is Solved Using __________ technique.

Question No. 33
A. Dynamic Programming
B. Divide and Conquer
C. Greedy Method
D. Branch and Bound
Dynamic Programming
Surveying

Applications Of ✓ FIBONACCI NUMBERS


DP
✓ 0/1 KNAPSACK PROBLEM
✓ MATRIX CHAIN MULTIPLICATION
✓ COIN CHANGE PROBLEM
✓ TRAVELLING SALES MAN PROBLEM
✓ SUBSET SUM PROBLEM
✓ LONGEST COMMON SUBSEQUENCE
✓ FLOYD-WARSHALL ALGORITHM
✓ BELLMAN-FORD ALGORITHM
Greedy Method
Surveying

Applications of
Greedy Method ✓ ACTIVITY SELECTION PROBLEM
✓ JOB SEQUENCING PROBLEM
✓ HUFFMAN CODING
✓ FRACTIONAL KNAPSACK PROBLEM
✓ MINIMUM SPANNING TREE
✓ COIN CHANGE PROBLEM …
Surveying
Divide and Conquer

Divide & Conquer


Applications ✓ MERGE SORT
✓ QUICK SORT
✓ STRASSEN’S MATRIX MULTIPLICATION
✓ MAXIMUM SUB ARRAY SUM PROBLEM
✓ TOWERS OF HANOI PROBLEM
✓ BINARY SEARCH
Branch and Bound
Surveying

Applications Of
Branch and Bound ✓ 0/1 Knapsack Problem
✓ Job Scheduling with Deadlines Problem
✓ N Queen Problem
✓ Travelling Salesman Problem
✓ 8 Puzzle Problem …
Practice Session 2 – ALGORITHMS
Surveying

_______ Algorithm technique can be used to Solve only


Question No. 34 minimization problems.

A. Dynamic Programming
B. Greedy Method
C. Branch and Bound
D. Backtracking
Practice Session 2 – ALGORITHMS
Surveying

The algorithm like Quick sort does not require extra memory for
Question No. 35 carrying out the sorting procedure. This technique is called
_______

A. in-place
B. stable
C. unstable
D. in-partition
Practice Session 2 – ALGORITHMS
Surveying

Given the following input (4322, 1334, 1471, 9679, 1989, 6171, 6173,
Question No. 36 4199) and the hash function “x mod 10”, which of the following
statements are true?

i. 9679, 1989, 4199 hash to the same value


ii. 1471, 6171 hash to the same value
iii. All elements hash to the same value
iv. Each element hashes to a different value

A. i only B. ii only
C. i and ii only D. i and iii only
Practice Session 2 – ALGORITHMS
Surveying

Given below are some algorithms, and some algorithm design


paradigms.
Question No. 37
List-I
A. Dijkstra’s Shortest Path
B. Floyd-Warshall algorithm to compute all pairs shortest path
C. Binary search on a sorted array
D. Backtracking search on a graph Codes:
ABCD
List-II (a) 3 2 1 4
1. Divide and Conquer (b) 1 2 3 4
2. Dynamic Programming (c) 3 1 2 4
3. Greedy design (d) 4 2 1 3
4. Depth-first search

Match the above algorithms on the left to the corresponding design


paradigm they follow
Practice Session 2 – ALGORITHMS
Surveying

Consider a hash table of size seven, with starting index zero, and a
Question No. 38 hash function (3x + 4)mod7. Assuming the hash table is initially
empty, which of the following is the contents of the table when the
sequence 1, 3, 8, 10 is inserted into the table using closed
hashing? Note that ‘_’ denotes an empty location in the table.

A. 8, _, _, _, _, _, 10
B. 1, 8, 10, _, _, _, 3
C. 1, _, _, _, _, _,3
D. 1, 10, 8, _, _, _, 3
Practice Session 2 – ALGORITHMS
Surveying

From the following algorithm design techniques which one is used


Question No. 39 to find all the pairs of shortest distances in a graph?

A. Dynamic programming
B. Greedy Method
C. Backtracking
D. Divide and Conquer
Practice Session 2 – ALGORITHMS
Surveying

In binary heap, whenever the root is removed then the rightmost


Question No. 40 element of last level is replaced by the root. Why?

A. It is the easiest possible way.


B. To make sure that it is still complete binary tree.
C. Because left and right subtree might be missing.
D. None of the above
Practice Session
Quick2Sort
– ALGORITHMS
Surveying

Next Class
ALGORITHMS
(Practice Session - 3)

You might also like