Twa kɔ nsɛm atitiriw so
Log in
Sign up for FREE
arrow_back
Laabri

exam Algorithm

star
star
star
star
star
Last updated about 1 year ago
59 Nsɛmmisa
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

1
1
1

Algorithms I (CS214) - Final Exam

Exam Date: Saturday 20/5/2023    Allowed Time: 2 hours

Dr. Salwa Osama

Asemmisa {{asɛmmisaAhyɛnsode}}
1.

What is a hash table?

Asemmisa {{asɛmmisaAhyɛnsode}}
2.

If several elements are competing for the same bucket in the hash table, what is it called?

Asemmisa {{asɛmmisaAhyɛnsode}}
3.

What is the hash function used in the division method?

Asemmisa {{asɛmmisaAhyɛnsode}}
4.

What can be the value of m in the division method?

Asemmisa {{asɛmmisaAhyɛnsode}}
5.

Using division method, in a given hash table of size 157, the key of value 172 is placed at position

Asemmisa {{asɛmmisaAhyɛnsode}}
6.

What is the table size when the value of p is 7 in multiplication method of creating hash functions?

Asemmisa {{asɛmmisaAhyɛnsode}}
7.

What is the average retrieval time when k has the same slot?

Asemmisa {{asɛmmisaAhyɛnsode}}
8.

Collisions can be reduced by choosing a hash function randomly in a way that is independent of the keys that are actually to be stored.

Asemmisa {{asɛmmisaAhyɛnsode}}
9.

What is indirect addressing?

Asemmisa {{asɛmmisaAhyɛnsode}}
10.

What is the search complexity in direct addressing?

Asemmisa {{asɛmmisaAhyɛnsode}}
11.

What is a hash function?

Asemmisa {{asɛmmisaAhyɛnsode}}
12.

Which of the following is not a technique to avoid a collision?

Asemmisa {{asɛmmisaAhyɛnsode}}
13.

What is the load factor?

Asemmisa {{asɛmmisaAhyɛnsode}}
14.

What is simple uniform hashing?

Asemmisa {{asɛmmisaAhyɛnsode}}
15.

In simple chaining, what data structure is appropriate?

Asemmisa {{asɛmmisaAhyɛnsode}}
16.

A hash table of length 10 uses open addressing with hash function h(k)=k mod 10, and linear probing. After inserting 6 values into an empty hash table, the table is as shown below.

0:

1: 42

2:

3:

4: 23

5: 52

6:

7: 33

8: 34

9:

Which one of the following choices gives a possible order in which the key values could have been inserted in the table?

Asemmisa {{asɛmmisaAhyɛnsode}}
17.

Maximum number of nodes in a binary tree with height k, where root is height 0, is

Asemmisa {{asɛmmisaAhyɛnsode}}
18.

Quick sort algorithm is an example of

Asemmisa {{asɛmmisaAhyɛnsode}}
19.

The minimum number of edges required to create a cyclic graph of n vertices is

Asemmisa {{asɛmmisaAhyɛnsode}}
20.

Which of the following is example of not in-place algorithm?

Asemmisa {{asɛmmisaAhyɛnsode}}
21.

Time required to sort "n" identical items of size m and n, is

Asemmisa {{asɛmmisaAhyɛnsode}}
22.

Which of the following uses memorization?

Asemmisa {{asɛmmisaAhyɛnsode}}
23.

Heap is an example of

Asemmisa {{asɛmmisaAhyɛnsode}}
24.

Access time of a binary search tree may go worse in terms of time complexity up to

Asemmisa {{asɛmmisaAhyɛnsode}}
25.

What will be the Huffman code for the letters a,b,c,d,e? If the probability are ½,1/4, 1/8,1/16,1/32

Asemmisa {{asɛmmisaAhyɛnsode}}
26.

From the following sorting algorithms which algorithm needs the minimum number of swaps

Asemmisa {{asɛmmisaAhyɛnsode}}
27.

From the following sorting algorithms which has the lowest worst case complexity?

Asemmisa {{asɛmmisaAhyɛnsode}}
28.

Match the following pairs

  • I. O(\log\ n)     (M) Heap sort

  • II. O(n)     (N) DFS

  • III. n\log(n)     (O) Binary search

  • IV. O(n^2)     (P) Selecting kth smallest elements

Asemmisa {{asɛmmisaAhyɛnsode}}
29.

What shall be value of x in the following pseudocode? x = 0; For (t = t; t <= N; t++) For p = l; p <= t; p++) x = x+1; EndFor EndFor

Asemmisa {{asɛmmisaAhyɛnsode}}
30.

Time complexity on merging three sorted lists of sizes m, n and p is

Asemmisa {{asɛmmisaAhyɛnsode}}
31.

Which of the algorithm design approach is used by Mergesort

Asemmisa {{asɛmmisaAhyɛnsode}}
32.

Which of the following shortest path algorithm cannot detect presence of negative weight cycle graph?

Asemmisa {{asɛmmisaAhyɛnsode}}
33.

For the figure below, starting at vertex A, which is a correct order for Prim's minimum spanning tree algorithm to add edges to the minimum spanning tree?

Asemmisa {{asɛmmisaAhyɛnsode}}
34.

Graph Algorithms Questions

For the figure below, which is a correct order for Kruskal's minimum spanning tree algorithm to add edges to the minimum spanning tree? ∑ ∧ | B

Asemmisa {{asɛmmisaAhyɛnsode}}
35.

If G is an directed graph with 20 vertices, how many boolean values will be needed to represent G using an adjacency matrix?

Asemmisa {{asɛmmisaAhyɛnsode}}
36.

What is the special property of red-black trees and what root should always be?

Asemmisa {{asɛmmisaAhyɛnsode}}
37.

Why do we impose restrictions like . root property is black . every leaf is black . children of red node are black . all leaves have same black

Asemmisa {{asɛmmisaAhyɛnsode}}
38.

What are the operations that could be performed in O(logn) time complexity by red-black tree?

Asemmisa {{asɛmmisaAhyɛnsode}}
39.

Why Red-black trees are preferred over hash tables though hash tables have constant time complexity?

Asemmisa {{asɛmmisaAhyɛnsode}}
40.

Pseudo Code

What is the below pseudo code trying to do, where pt is a node pointer an l root pointer?

redblack(Node root, Node pt) : if (root == NULL) return pt if (pt.data < root.data) { root.left = redblack(root.left, pt); root.left.parent = root; } else if (pt.data > root.data) { root.right = redblack(root.right, pt); root.right.parent = root; } return root

Asemmisa {{asɛmmisaAhyɛnsode}}
41.

Dijkstra’s Algorithm is used to solve problems.

Asemmisa {{asɛmmisaAhyɛnsode}}
42.

What is the time complexity of Dijkstra’s algorithm?

Asemmisa {{asɛmmisaAhyɛnsode}}
43.

Dijkstra’s Algorithm cannot be applied on

Asemmisa {{asɛmmisaAhyɛnsode}}
44.

How many priority queue operations are involved in Dijkstra's Algorithm?

Asemmisa {{asɛmmisaAhyɛnsode}}
45.

How many times the insert and extract min operations are invoked per vertex

Asemmisa {{asɛmmisaAhyɛnsode}}
46.

The maximum number of times the decrease key operation performed in Dijkstra's algorithm will be equal to

Asemmisa {{asɛmmisaAhyɛnsode}}
47.

What is running time of Dijkstra's algorithm using Binary min- heap method?

Asemmisa {{asɛmmisaAhyɛnsode}}
48.

Why Red-black trees are preferred over hash tables though hash tables have constant time complexity?

Asemmisa {{asɛmmisaAhyɛnsode}}
49.

What will be the below pseudo code trying to do, where pt is a node pointer and root pointer?

redblack(Node root, Node pt) { if (root == NULL) return pt; if (pt.data < root.data) { root.left = redblack(root.left, pt); root.left.parent = root; } else if (pt.data > root.data) { root.right = redblack(root.right, pt); root.right.parent = root; } return root; }

Asemmisa {{asɛmmisaAhyɛnsode}}
50.

Dijkstra's Algorithm is used to solve the following problems.

Asemmisa {{asɛmmisaAhyɛnsode}}
51.

What is the time complexity of Dijkstra's algorithm?

Asemmisa {{asɛmmisaAhyɛnsode}}
52.

Dijkstra's Algorithm cannot be applied on

Asemmisa {{asɛmmisaAhyɛnsode}}
53.

How many priority queue operations are involved in Dijkstra's Algorithm?

Asemmisa {{asɛmmisaAhyɛnsode}}
54.

How many times the insert and extract min operations are invoked per vertex?

Asemmisa {{asɛmmisaAhyɛnsode}}
55.

The maximum number of times the decrease key operation performed in Dijkstra's algorithm will be equal to

Asemmisa {{asɛmmisaAhyɛnsode}}
56.

What is running time of Dijkstra's algorithm using Binary min-heap method?

Asemmisa {{asɛmmisaAhyɛnsode}}
57.

If b is the source vertex, what is the minimum cost to reach vertex f?

Asemmisa {{asɛmmisaAhyɛnsode}}
58.

Identify the shortest path having minimum cost to reach vertex E if A is the source vertex

Asemmisa {{asɛmmisaAhyɛnsode}}
59.

Dijkstra's Algorithm is the prime example for