You are on page 1of 3

University of Sargodha, Lahore Campus

Final Term Examinations (Spring-2016)


BSCS Semester 4th Section All
Program
Course Design and Analysis of Instructor Sir Zeeshan, Ms Eisha Time allowed 30 min
Algorithm
Roll No. Date Total Marks 18
Objective Part

Instructions:

 Attempt all questions in this sheet. Over writing will be marked as incorrect.
 There is zero tolerance towards PLAGARISM.

Question # 1:
Choose the correct options. (1.5*12=18 marks)
1. In quick sort, the number of partitions into which the file of size n is divided by a
selected record is
a) 2 b)N-1
c) N d)None of the above
2. Heap is defined to be a
a) Binary Tree b)Complete binary tree

c)Full binary tree d)Tree structure

3. Suppose we need to sort a list of employee records in ascending order, using ID as the
key. If we need to guarantee that the running time will be no longer worse than nlogn,
which sorting method could we use?
a) Merge sort b)Quick sort
c)Insertion sort d)Either merge sort or quick sort
4. In stable algorithm
a) One array is used b)Repeating elements are not handled
c) Repeating elements remain in the same relative position after sorting
d)More than one arrays are used
There are 5 items as follow:

Item(i) Weight(i) in pounds Value(i) in dollar


Item 1 10 $ 30
Item 2 10 $ 20
Item 3 20 $ 100
Item 4 30 $ 90
Item 5 40 $ 160

5. The Knapsack can hold 60 pounds, find the solution, assuming it is 0/1:
a)

b) 250$ c) 260$
University of Sargodha, Lahore Campus
Final Term Examinations (Spring-2016)
d) 270$ e) 280$

6. The Knapsack can hold 60 pounds, find the solution, assuming it is fractional:

a) 250$ c) 270$
b) 260$ d) 280$

7. Consider the string ‘ABACDAACAC’ if the string is coded with ASCII codes using
Huffman encoding scheme, the message length would be?

a) 8 bits c) Less than 50 bits


b) 80 bits d) More than 50 bits

8. The 0/1 knapsack problem is called a 0/1 because


a) Each item must be entirely accepted or rejected
b) Each item may be entirely accepted or rejected
c) Each item must be partially accepted
d) Each item may be partially rejected

9. Dijkstra algorithm is used for


a) Calculating multiple source shortest path problems
b) Calculating Minimum spanning tree
c) Shortest and Minimum Spanning tree both can be calculated by it
d) Single source shortest path problems

10. The greedy part of the Huffman encoding algorithm is to first find two nodes with
……… frequency

a) Larger c) Balance
b) Smallest d) Character

11. Mr. A wanted to sort the words COW,DOG,SEA,RUG,MOB,BOX alphabetically


using radix sort. In what order will the words appear after the second stage.
a) SEA,MOB,DOG,RUG,COW,BOX
b) COW,MOB,RUG,DOG,SEA,BOX
c) SEA,MOB,DOG,RUG,BOX,COW
d) SEA,MOB,DOG,COW,BOX,RUG

12. We employ dynamic programming approach when


a). It gives optimal solution
University of Sargodha, Lahore Campus
Final Term Examinations (Spring-2016)
b). The solution has optimal substructure
c) It is faster than Greedy technique
d) The given problem can be reduced to the 3-SAT problem.

You might also like