Comp 314 - 2017
Comp 314 - 2017
KATHMANDU UNIVERSITY
End Semester Examination
August/September, 2017
Level : B. E./B. Sc. Course : COMP 314
Year : III Semester : II
Exam Roll No. : Time: 30 min F. M. : 10
2. Each array declaration need not give, implicitly or explicitly, the information about:
a. The name of the array b. The data type of the array
c. The first data from the set to be stored d. The index set of the array
4. The indirect change of the values of a variable in one module by another module is
called:
a. Internal change b. Inter-module change
c. Side effect d. Side-module update
5. What is the worst-case time for a binary search finding a single item in an array?
a. Constant time b. Logarithmic time c. Linear time d. Quadratic time
If the above tree is used for sorting, then a new number 8 should be placed as the:
a. Left child of the node labeled 30 b. Right child of the node labeled 5
c. Right child of the node labeled 30 d. Left child of the node labeled 10
7. Traversing a binary tree first root and then left and right subtrees is called:
a. Postorder traversal b. Preorder traversal
c. Inorder traversal d. Depth-First traversal
8. The condition Top = -1 indicates that:
a. Stack is empty b. Stack is full
c. Stack has only one element d. None of these
9. An algorithm must be generic enough to solve all problems of a particular class. Which
of the following relates to this property of algorithms?
a. Finiteness b. Definiteness c. Generality d. Effectiveness
10. A mathematical model with a collection of operations defined on that model is called:
a. Data structure b. Abstract Data Type
c. Primitive Data Type d. Algorithm
11. In case of a chained hash table of n elements with b buckets, assuming that a worst case
resulted in all the n elements getting mapped to the same bucket, then the worst case time
complexity of a search on the hash table would be given by:
a. O(1) b. O(n/b) c. O(n) d. O(b)
13. A balanced binary tree is a binary tree in which the heights of the two subtrees of every
node never differ by more than:
a. 2 b. 1 c. 0 d. None of the above
18. In a heap with n elements and with the smallest elements at the root, the 7’th smallest
element can be found in:
a. Ө(n lg n) b. Ө(n) c. Ө( lg n) d. Ө(1)
1. How does one measure the efficiency of algorithms? Distinguish between best, worst and
average case complexities of an algorithm.
2. Discuss insertion sort algorithm. Illustrate the working mechanism of insertion sort for
the given array input <31, 41, 59, 26, 41, 58>. What are the time complexities of
insertion sort in the best and the worst cases?
3. Compare and contrast “Divide and Conquer” algorithm design strategy with “Dynamic
Programming”. Provide examples where each of the methods are used.
4. Find the shortest path distances for each of the vertices in the graph provided below using
Dijkstra’s algorithm. Show the different steps involved in the process.
5. Explain “greedy” algorithms in the context of the Activity Scheduling Problem. What is
the greedy strategy employed in selecting the activities?
SECTION “C”
[2 Q. × 10 = 20 marks]
Attempt ANY TWO questions.
6. Explain Depth-First Search Traversal method and its working mechanism. Apply DFS in
the following topological sort problem. Show the final order of dressing. [5 + 5]
7. Write short notes on [2 × 5=10]
a) Backtracking algorithms and the 4 queen problem
b) Binary search tree and the operations on the search tree (querying and modification
operations)
8. Define Flow networks. State and explain the three properties of a flow. Compute the net
flow across and capacity of the cut (S,T), where S ={ s, v1, v2} and T = { v3, v4, t}. [5 + 5]