Question
Part I. True or false questions instruction: Darken the circle on your answer sheet corresponding to
the single best answer for each question. (10 points)
1. A cycle in G is a simple path in which the first and last vertices are the same.
2. A loop in a graph is an edge incident on a single vertex.
3. In an undirected graph, if two edges e1 and e2 are associated with the same pair of vertices (u, V3, 9 921000
then e1 and e2 are called parallel edges.
nogiA bris г91 f9u112 6isO
4. A graph is a simple graph if it has no loops and no parallel edges.
5. The vertices u and v are connected if there is a path from u to v.
6. In an adjacency list representation, corresponding to each vertex v is a linked list such that each
node of the linked list contains the vertex u and.
7. The depth-first traversal of a graph is similar to the preorder traversal of a binary tree.
8. A sequential search of a list assumes that the list is in ascending order.
9. A binary search of a list assumes that the list is sorted.
10. A heap is a complete binary tree where every internal node should have a value greater than or
equal or less than or equal to the values in their subtrees.
п0l1392
Part II. Multiple choice Questions Instruction: Darken the circle on your answer sheet corresponding oh hi
to the single best answer for each question. (30 points)
1. The space complexity of merge sort is:
anolfouant Iciened
A) 0(1)
B) O(logn)
c) O(n)
D) O(nlogn)
2. Given the following list of numbers [14, 17, 13, 15, 19, 10, 3, 16, 9, 12]. Which option below shows
the contents of the list after the first partioning according to the quick sort algorithm (choose first
element as pivot)?
A. [10,12,13,9,8,14,15,16,19,17] sis nia arty
C. [10,12,13,9,8,14,16,19,15,17]
B. [10,12,13,9,8,14,15,19,16,17]
D. [10,12,13,9,8, 14,19,16,15,17] oy no afario arts nadia@
3. In the merge sort algorithm, the running time of the merge operation is:
(A) O(log n) oilsain (B) O(n) 2515 Tiv sitatio (C) O(n log n) b bir (D) O(n2) * ba arTist TOY siRW
Ins 1o zamora les
4. The time complexity of the following code is; 9 arts to juo og voy fling the morts rosiwe carTimaag
ФУГЕ
int i, j, k=0;
nebbichol yoiie ai lied maxe ant ni anisserla to imot yA
for (i = n / 2; i <= n; i++) {
for (j = 2; j <= n; j = ¡ * 2) ‹
k = k + n / 2;
(A) O(log n)
(B) O(n)
(C) O(n log n)
(D) 0(n2)
5. The list of keys ×[] = {25 29 38 36 32 54 44 40} is to be sorted using insertion sort algorithm. Initially
[0] = 25 is sorted set of 1 element. After iteration 4, the set of elements is:
A. 25 29 32 36 38 40 44 54
C. 25 29 36 32 38 40 44 54
B. 25 29 36 38 32 54 44 40
D. 25 29 32 36 38 54 44 40
1 | Page