cs502 full material

116
FINALTERM EXAMINATION Spring 2010 Question No: 1 ( Marks: 1 ) - Please choose one An optimization problem is one in which you want to find, Not a solution An algorithm Good solution The best solution Question No: 2 ( Marks: 1 ) - Please choose one Although it requires more complicated data structures, Prim's algorithm for a minimum spanning tree is better than Kruskal's when the graph has a large number of vertices. True False Question No: 3 ( Marks: 1 ) - Please choose one If a problem is in NP, it must also be in P. True False unknown Question No: 4 ( Marks: 1 ) - Please choose one What is generally true of Adjacency List and Adjacency Matrix representations of graphs? Lists require less space than matrices but take longer to find the weight of an edge (v1,v2) Lists require less space than matrices and they are faster to find the weight of an edge (v1,v2) Lists require more space than matrices and they take longer to find the weight of an edge (v1,v2) Lists require more space than matrices but are faster to find the weight of an edge (v1,v2) Question No: 5 ( Marks: 1 ) - Please choose one If a graph has v vertices and e edges then to obtain a spanning tree we have to delete v edges. v – e + 5 edges v + e edges. None of these Question No: 6 ( Marks: 1 ) - Please choose one Maximum number of vertices in a Directed Graph may be |V 2 | True False

Upload: sami-signs

Post on 11-Mar-2015

669 views

Category:

Documents


11 download

TRANSCRIPT

Page 1: CS502 Full Material

FINALTERM EXAMINATION

Spring 2010 Question No: 1 ( Marks: 1 ) - Please choose one An optimization problem is one in which you want to find, ► Not a solution ► An algorithm ► Good solution ► The best solution Question No: 2 ( Marks: 1 ) - Please choose one Although it requires more complicated data structures, Prim's algorithm for a minimum spanning tree is better than Kruskal's when the graph has a large number of vertices. ► True ► False Question No: 3 ( Marks: 1 ) - Please choose one If a problem is in NP, it must also be in P. ► True ► False ► unknown Question No: 4 ( Marks: 1 ) - Please choose one What is generally true of Adjacency List and Adjacency Matrix representations of graphs? ► Lists require less space than matrices but take longer to find the weight of an edge (v1,v2) ► Lists require less space than matrices and they are faster to find the weight of an edge (v1,v2) ► Lists require more space than matrices and they take longer to find the weight of an edge (v1,v2) ► Lists require more space than matrices but are faster to find the weight of an edge (v1,v2) Question No: 5 ( Marks: 1 ) - Please choose one If a graph has v vertices and e edges then to obtain a spanning tree we have to delete ► v edges. ► v – e + 5 edges ► v + e edges. ► None of these Question No: 6 ( Marks: 1 ) - Please choose one Maximum number of vertices in a Directed Graph may be |V2| ► True ► False

Page 2: CS502 Full Material

Question No: 7 ( Marks: 1 ) - Please choose one The Huffman algorithm finds a (n) _____________ solution. ► Optimal ► Non-optimal ► Exponential ► Polynomial Question No: 8 ( Marks: 1 ) - Please choose one The Huffman algorithm finds an exponential solution ► True ► False Question No: 9 ( Marks: 1 ) - Please choose one The Huffman algorithm finds a polynomial solution ► True ► False Question No: 10 ( Marks: 1 ) - Please choose one The greedy part of the Huffman encoding algorithm is to first find two nodes with larger frequency. ► True ► False Question No: 11 ( Marks: 1 ) - Please choose one The codeword assigned to characters by the Huffman algorithm have the property that no codeword is the postfix of any other. ► True ► False Question No: 12 ( Marks: 1 ) - Please choose one Huffman algorithm uses a greedy approach to generate a postfix code T that minimizes the expected length B (T) of the encoded string. ► True ► False Question No: 13 ( Marks: 1 ) - Please choose one Shortest path problems can be solved efficiently by modeling the road map as a graph. ► True ► False Question No: 14 ( Marks: 1 ) - Please choose one Dijkestra’s single source shortest path algorithm works if all edges weights are non-negative and there are negative cost cycles. ► True ► False

Page 3: CS502 Full Material

Question No: 15 ( Marks: 1 ) - Please choose one Bellman-Ford allows negative weights edges and negative cost cycles. ► True ► False Question No: 16 ( Marks: 1 ) - Please choose one The term “coloring” came form the original application which was in architectural design. ► True ► False Question No: 17 ( Marks: 1 ) - Please choose one In the clique cover problem, for two vertices to be in the same group, they must be adjacent to each other. ► True ► False Question No: 18 ( Marks: 1 ) - Please choose one Dijkstra’s algorithm is operates by maintaining a subset of vertices ► True ► False Question No: 19 ( Marks: 1 ) - Please choose one The difference between Prim’s algorithm and Dijkstra’s algorithm is that Dijkstra’s algorithm uses a different key. ► True ► False Question No: 20 ( Marks: 1 ) - Please choose one Consider the following adjacency list:

Which of the following graph(s) describe(s) the above adjacency list?

Page 4: CS502 Full Material

► Question No: 21 ( Marks: 1 ) - Please choose one We do sorting to, ► keep elements in random positions ► keep the algorithm run in linear order

Page 5: CS502 Full Material

► keep the algorithm run in (log n) order ► keep elements in increasing or decreasing order Question No: 22 ( Marks: 1 ) - Please choose one After partitioning array in Quick sort, pivot is placed in a position such that ► Values smaller than pivot are on left and larger than pivot are on right ► Values larger than pivot are on left and smaller than pivot are on right ► Pivot is the first element of array ► Pivot is the last element of array Question No: 23 ( Marks: 1 ) - Please choose one Merge sort is stable sort, but not an in-place algorithm ► True ► False Question No: 24 ( Marks: 1 ) - Please choose one In counting sort, once we know the ranks, we simply _________ numbers to their final positions in an output array. ► Delete ► copy ► Mark ► arrange Question No: 25 ( Marks: 1 ) - Please choose one Dynamic programming algorithms need to store the results of intermediate sub-problems. ► True ► False Question No: 26 ( Marks: 1 ) - Please choose one A p × q matrix A can be multiplied with a q × r matrix B. The result will be a p × r matrix C. There are (p . r) total entries in C and each takes _________ to compute. ► O (q) ► O (1) ► O (n2) ► O (n3) Question No: 27 ( Marks: 2 ) Give a detailed example for 2-d maxima problem. Let took a point p in 2-dimensional space given by its integer coordinates, p = (p.x, p.y). A point p is said to dominated by point q if p.x ≤ q.x and p.y ≤ q.y.

Page 6: CS502 Full Material

Given a set of n points, P = {p1, p2, . . . , pn} in 2-space a point is said to be maximal if it is not dominated by any other point in P. The problem is to output all the maximal points of P. A brute-force algorithm that ran in Θ(n2) time is used in it. It operated by comparing all pairs of points. the brute-force algorithm uses no intelligence in pruning out decisions. For example, once we know that a point pi is dominated by another point pj, we do not need to use pi for eliminating other points. This follows from the fact that dominance relation is transitive. If pj dominates pi and pi dominates ph then pj also dominates ph; pi is not needed. Question No: 28 ( Marks: 2 ) Differentiate between back edge and forward edge. For directed graphs edges r classified as: Back edge: (u, v) where v is an ancestor of u in the tree. Forward edge: (u, v) where v is a proper descendent of u in the tree. Cross edge: (u, v) where u and v are not ancestor or descendent of one another. In fact, the edge may go between different trees of the forest. Question No: 29 ( Marks: 2 ) How the generic greedy algorithm operates in minimum spanning tree? Ans: In undirected, connected graph whose edges have numeric weights are G = (V, E) Here’s applying generic greedy algorithm operates in minimum spanning tree is simple. we maintain a subset of edges E of the graph . ∪This subset is A. Initially, A is empty. We will add edges one at a time until A equals the MST. A subset A ⊆ E is viable if A is a subset of edges of some MST. An edge (u, v) ∈ E − A is safe if A ∪ {(u, v)} is viable. In other words, the choice (u, v) is a safe choice to add so that A can still be extended to form a MST. if A is viable, it cannot contain a cycle. A generic greedy algorithm operates by repeatedly adding any safe edge to the current spanning tree. Question No: 30 ( Marks: 2 )

What are two cases for computing ( )kijd

assuming we already have the previous

matrix( )1−kd using Floyed-Warshall algorithm?

Page 7: CS502 Full Material

Ans:

The two cases for computing ( )kijd

assuming we already have the previous matrix( )1−kd

using Floyed-Warshall algorithm are: 1. Don’t go through vertex k at all. 2. Do go through vertex k

Question No: 31 ( Marks: 3 ) Describe Minimum Spanning Trees Problem with examples. Question No: 32 ( Marks: 3 ) What is decision problem, also explain with example? Ans: A problem is called a decision problem if its output is a simple

• yes or no • true/false, • 0/1, • Accept/reject.)

For example: The MST decision problem would be a decision problem, Given a weighted graph G and an integer k, does G have a spanning tree whose weight is at most k? Question No: 33 ( Marks: 3 ) Prove that the generic TRAVERSE (S) marks every vertex in any connected graph exactly once and the set of edges (v, parent (v)) with parent (v) ¹ F form a spanning tree of the graph. Ans: Proof: it should be sured that no vertex is marked more than once. The algorithm marks s. Let v = s be a vertex and let s → · · · → u → v be a path from s to v with the minimum number of edges. Since the graph is connected, such a path always exists. If the algorithm marks u, then it must put (u, v) into the bag, so it must take (u, v) out of the bag at which point v must be marked. Thus, by induction on the shortest path distance from s, the algorithm marks every vertex in the graph. Call an edge (v, parent(v)) with parent(v) = ∅, a parent edge. For any node v, the path of parent edges v → parent(v) → parent(parent(v)) → . . . eventually leads back to s. So the set of parent edges form a connected graph. both end points of every parent edge are marked, and the number of edges is exactly one less than the number of vertices. Thus, the parent edges form a spanning tree. Question No: 34 ( Marks: 5 ) Suppose you could reduce an NP-complete problem to a polynomial time problem in polynomial time. What would be the consequence?

Page 8: CS502 Full Material

Question No: 35 ( Marks: 5 ) Prove the following lemma, Lemma: Given a digraph G = (V, E), consider any DFS forest of G and consider any edge (u, v) ∈ E. If this edge is a tree, forward or cross edge, then f[u] > f[v]. If this edge is a back edge, then f[u] ≤ f[v] Ans: Proof: For the non-tree forward and back edges the proof follows directly from the parenthesis lemma. For example, for a forward edge (u, v), v is a descendent of u and so v’s start-finish interval is contained within u’s implying that v has an earlier finish time. For a cross edge (u, v) the two time intervals are disjoint. When we were processing u, v was not white (otherwise (u, v) would be a tree edge), implying that v was started before u. Because the intervals are disjoint, v must have also finished before u. Question No: 36 ( Marks: 5 ) What is the cost of the following graph?

Pseudo code of DFS 5 Ans: DFS procedure can be written

Page 9: CS502 Full Material

1. recursively or 2. non-recursively.

RECURSIVEDFS(v) if (v is unmarked ) then mark v for each edge (v,w) do RECURSIVEDFS(w) ITERATIVEDFS(s) PUSH(s) while stack not empty do v ← POP() if v is unmarked then mark v for each edge (v,w) do PUSH(w) and prove the DFS algorithm 5 Total 36 Questions, 26 MCQ’s Using ASCII standard the string abacdaacac will be encoded with __________ bits. 80 160 320 100 Using ASCII standard the string abacdaacac will be encoded with 160 bits. True False Using ASCII standard the string abacdaacac will be encoded with 320 bits. True False Using ASCII standard the string abacdaacac will be encoded with 100 bits. True

Page 10: CS502 Full Material

False Please choose oneConsider the following Huffman Tree The binary code for the string TEA is

10 00 010 011 00 010 10 00 110 11 10 110 The book written by Al-Khwarzami Hisab al-jabr w'al mugabalah The Huffman algorithm finds a (n) _____________ solution. ► Optimal ► Non-optimal ► Exponential ► Polynomial Huffman algorithm uses a greedy approach to generate a postfix code T that minimizes the expected length B (T) of the encoded string. ► True ► False The difference between Prim’s algorithm and Dijkstra’s algorithm is that Dijkstra’s algorithm uses a different key. ► True ► False

Page 11: CS502 Full Material

4 Questions of 2 Marks 1. Difference between Prim’s algorithm and Dijikstra’s algorithm.

Ans: The difference between Prim’s algorithm and Dijkstra’s algorithm is that Dijkstra’s algorithm uses a different key.

2. What is coloring problem? 3. Is it better that we using brute force approach to solve knap sack

problem, can we do better. 3 Questions of 3 Marks

1. following is the list of adjacency vertex, Identify that is any vertex have isolated property.

a------- b-- c b------ d-- e e------ f-- d c----- b--- f f---- b g 2. How Dijikstra’s algorithm operate, give an example.

3 Questions of 5 Marks. 1. What is the reduction, Explain with example. (From Last chapter of handsout) 2. Describe the Minimum spanning Tree with example. 3. What is the cost of following Graph.

Page 12: CS502 Full Material

1: What is the time complexity to extract a vertex from the priority queue in Prim’s algorithm?

• log (v) • v.v • e.e • log(e)

2: Which statement is true?

• If a dynamic-programming problem satisfies the optimal-substructure property, then a locally optimal solution is globally optimal.

• If a greedy choice property satisfies the optimal-substructure property, then a locally optimal solution is globally optimal.

• both of above • none of above

3: Kruskal's algorithm (choose best non-cycle edge) is better than Prim's (choose best tree edge) when the graph has relatively few edges.

• True • False

4: You have an adjacency list for G, what is the time complexity to compute Graph transpose G^T ?

• V+e • v.e • v

Page 13: CS502 Full Material

• e 5: What general property of the list indicates that the graph has an isolated vertex?

• There is Null pointer at the end of list. • The Isolated vertex is not handled in list. • Only one value is entered in the list. • There is at least one null list.

6: Which is true statement.

• Breadth first search is shortest path algorithm that works on un-weighted graphs. • Depth first search is shortest path algorithm that works on un-weighted graphs. • Both of above are true. • None of above are true.

7: A dense undirected graph is:

• A graph in which E = O(V^2) • A graph in which E = O(V) • A graph in which E = O(log V) • All items above may be used to characterize a dense undirected graph.

8: What is generally true of Adjacency List and Adjacency Matrix representations of graphs?

• Lists require less space than matrices but take longer to find the weight of an edge (v1,v2)

• Lists require less space than matrices and they are faster to find the weight of an edge (v1, v2)

• Lists require more space than matrices and they take longer to find the weight of an edge (v1, v2).

9: Suppose that a graph G = (V,E) is implemented using adjacency lists. What is the complexity of a breadth-first traversal of G?

• O(|V |^2) • O(|V | |E|) • O(|V |^2|E|) • O(|V | + |E|)

10: The relationship between number of back edges and number of cycles in DFS is,

• Both are equal • Back edges are half of cycles • Back edges are one quarter of cycles

Page 14: CS502 Full Material

• There is no relationship between no. of edges and cycles 11: Using ASCII standard the string “abacdaacacwe” will be encoded with __________ bits

• 64 • 128 • 96 • 120

12: What is the time complexity to extract a vertex from the priority queue in Prim’s algorithm?

• log (V) • v.v • e.e • log

13: the analysis of selection algorithm shows the total running time is indeed------------in n.

• arithmetic • geometric • linear • orthogonal

14: back edge is (1) In Prim’s algorithm, the additional information maintained by the algorithm is the length of the shortest edge from vertex v to points already in the tree. A) TRUE B) FALSE C) UNKNOWN (2) Although it requires more complicated data structures, Prim's algorithm for a minimum spanning tree is better than Kruskal's when the graph has a large number of vertices. A) TRUE. B) FALSE C: UNKNOWN (3) If a problem is NP-complete, it must also be in NP. A) TRUE. B) FALSE

Page 15: CS502 Full Material

C) UNKNOWN (4) What is the worst-case runtime complexity of the following C function int function(int n){ int i, j, k; k = n; for(i=-100; i<10*log(n);i++){ k = k/2; } for(j=i; j> n; j--){ k=j/2; }r return k; } What order is the execution of this code a) O(log n) b) O(n) c) O(n log n) d) O(n2) e) O(n2 log n) (4) Which statement is true (I) The running time of Bellman-Ford algorithm is T (VE) (II) Both Dijkstra’s algorithm and Bellman-Ford are based on performing repeated relaxations (III) The 0-1 knapsack problem is hard to solve • Only I • Only III • Both I and III • All of these 5) Which of the following arrays represent descending (max) heaps? I. [10,7,7,2,4,6] II. [10,7,6,2,4,7] III. [10,6,7,2,4,6] IV. [6,6,7,2,4,10] • Only II • Only IV • Both II and IV • Both I and III 6. Which of the following statement(s) is/are correct? (a) O(n log n + n2) = O(n2). (b) O(n log n + n2) = O(n2 log 2n)

Page 16: CS502 Full Material

(c) O(c n2) = O(n2) where c is a constant. (d) O(c n2) = O(c) where c is a constant. (e) O(c) = O(1) where c is a constant.

• Only (a) & (e) • Both (c) and (e)

7. Which of the shortest path algorithms would be most appropriate for finding paths in the graph with negative edge weights and cycles? I.Dijkstra’s Algorithm II. Bellman-Ford Algorithm III. Floyd Warshall Algorithm

• Only II • Only III • Both II & III

8. Which of the following orders is not a possible order in which Depth First Search can visit the vertices of the directed graph shown below?

• ABCEFD • ACEBFD • ADFEBC • ADFBCE • ABFECD 9. Suppose we have two problems A and B .Problem A is polynomial-time reducible and problem B is NP-complete. If we reduce problem A into B then problem A becomes NP-complete • Yes • No 10. How can the number of strongly connected components of a graph change if a new edge is added?

• The number of strongly connected components can be increased. • The number of strongly connected components can be reduced. • No change will occur.

Page 17: CS502 Full Material

• None of these. 11. The recurrence relation of Tower of Hanoi is given below ? 1 if n =1 T n =? -133( ) 2 (T n- +1) 1if n>1 In order to move a tower of 6 rings from one peg to another, how many moves are required?

• 15 • 7 • 63 • 32

12. Edge (u, v) is a forward edge if

• u is a proper descendant of v in the tree • v is a proper descendant of u in the tree • None of these

13. Is 22n= O? 2n -26? ?

• Yes it is possible • No it is not possible • None of these

14. If, in a DFS forest of digraph G = (V, E), f[u] = f[v] for an edge (u, v) ? E then the edge is called

• Back edge • Forward edge • Cross Edge • Tree Edge • None of these

15. How can the number of strongly connected components of a graph change if a new edge is added?

• The number of strongly connected components can be increased. • The number of strongly connected components can be reduced. • No change will occur. • None of these.

Page 18: CS502 Full Material

16. Best and worst case times of an algorithm may be same. • True • False

17. Can an adjacency matrix for a directed graph ever not be square in shape?

• Yes • No

18. If an algorithm has a complexity of 2n2+ 4n + 3 for some model of computation (some set of assumptions) and some complexity measures (such as number of comparison operations) we could say that it has complexity (a) O(log2n) (b) O(n2) (c) O(2 + 4 + 3) (d) all of the above (e) none of the above

Page 19: CS502 Full Material

1. In which order we can sort?

• increasing order only • decreasing order only • increasing order or decreasing order • both at the same time

2. heap is a left-complete binary tree that conforms to the ___________

• increasing order only • decreasing order only • heap order • (log n) order

3. In the analysis of Selection algorithm, we make a number of passes, in fact it could be as many as,

• T(n) • T(n / 2) • log n • n / 2 + n / 4

4. How much time merge sort takes for an array of numbers?

• T(n^2) • T(n) • T( log n) • T(n log n)

5. One of the clever aspects of heaps is that they can be stored in arrays without using any _______________.

• pointers • constants • variables • functions

6. the analysis of Selection algorithm, we eliminate a constant fraction of the array with each phase; we get the convergent _______________ series in the analysis

• linear • arithmetic • geometric • exponent

7:. Sieve Technique applies to problems where we are interested in finding a single item from a larger set of _____________

• n items • phases • pointers • constant

Page 20: CS502 Full Material

8. The sieve technique works in ___________ as follows • phases • numbers • integers • routines

9. For the heap sort, access to nodes involves simple _______________ operations. • arithmetic • binary • algebraic • logarithmic

10. The analysis of Selection algorithm shows the total running time is indeed ________in n,

• arithmetic • geometric • linear • orthogonal

11. Divide-and-conquer as breaking the problem into a small number of

• pivot • Sieve • smaller sub problems • Selection

12. Slow sorting algorithms run in,

• T(n^2) • T(n) • T( log n) • T(n log n)

13. A heap is a left-complete binary tree that conforms to the

• increasing order only • decreasing order only • heap order • (log n) order

14. For the heap sort we store the tree nodes in

• level-order traversal • in-order traversal • pre-order traversal • post-order traversal

15. The reason for introducing Sieve Technique algorithm is that it illustrates a very important special case of,

• divide-and-conquer,

Page 21: CS502 Full Material

• decrease and conquer • greedy nature • 2-dimension Maxima

16. We do sorting to, Select correct option:

• keep elements in random positions • keep the algorithm run in linear order • keep the algorithm run in (log n) order • keep elements in increasing or decreasing order

17. Sorting is one of the few problems where provable ________ bonds exits on how fast we can sort, Select correct option:

• upper • lower • average • log n

For the heap sort we store the tree nodes in Select correct option:

• level-order traversal • in-order traversal • pre-order traversal • post-order traversal

18: For the Sieve Technique we take time

• T(nk) • T(n / 3) • n^2 • n/3

20: In Sieve Technique we do not know which item is of interest Select correct option:

• True • False

21: Slow sorting algorithms run in,

• T(n^2) • T(n) • T( log n) • T(n log n)

22: Divide-and-conquer as breaking the problem into a small number of

• pivot • Sieve

Page 22: CS502 Full Material

• smaller sub problems • Selection

23: For the sieve technique we solve the problem,

• recursively • mathematically • precisely • accurately

24: we do sorting to, • keep elements in random positions

• keep the algorithm run in linear order • keep the algorithm run in (log n) order • keep elements in increasing or decreasing order

25: The reason for introducing Sieve Technique algorithm is that it illustrates a very important special case of,

• divide-and-conquer • decrease and conquer • greedy nature • 2-dimension Maxima

26: In Sieve Technique we do not know which item is of interest

• true • false

27: In the analysis of Selection algorithm, we make a number of passes, in fact it could be as many as,

• T(n) • T(n / 2) • log n • n / 2 + n / 4

28: Divide-and-conquer as breaking the problem into a small number of

• pivot • Sieve

Page 23: CS502 Full Material

• smaller sub problems • Selection

29: A heap is a left-complete binary tree that conforms to the ___________

• increasing order only • decreasing order only • heap order • (log n) order

30: Slow sorting algorithms run in,

• T(n^2) • T(n) • T( log n) • T(n log n)

31: One of the clever aspects of heaps is that they can be stored in arrays without using any _______________.

• pointers • constants • variables • functions

32: Sorting is one of the few problems where provable ________ bonds exits on how fast we can sort,

• upper • lower • average • log n

33: For the sieve technique we solve the problem,

• mathematically • precisely • accurately • recursively

34: Sieve Technique can be applied to selection problem?

• True • False

Page 24: CS502 Full Material

35: How much time merge sort takes for an array of numbers?

• (n^2) • T(n) • T( log n) • T(n log n)

36; : For the Sieve Technique we take time

• T(nk) • T(n / 3) • n^2 • n/3

37: Heaps can be stored in arrays without using any pointers; this is due to the ____________ nature of the binary tree,

• left-complete • right-complete • tree nodes • tree leaves

38: How many elements do we eliminate in each time for the Analysis of Selection algorithm?

• n / 2 elements • (n / 2) + n elements • n / 4 elements • 2 n elements

39: We do sorting to,

• keep elements in random positions • keep the algorithm run in linear order • keep the algorithm run in (log n) order • keep elements in increasing or decreasing order

40: In which order we can sort?

• increasing order only • decreasing order only • increasing order or decreasing order • both at the same time

41: : In the analysis of Selection algorithm, we make a number of passes, in fact it could be as many as,

Page 25: CS502 Full Material

• T(n) • T(n / 2) • log n • n / 2 + n / 4

42: The sieve technique is a special case, where the number of sub problems is just

• 5 • Many • 1 • few

Question No: 1 ( Marks: 1 ) - Please choose one Random access machine or RAM is a/an ► Machine build by Al-Khwarizmi ► Mechanical machine ► Electronics machine ► Mathematical model Question No: 2 ( Marks: 1 ) - Please choose one _______________ is a graphical representation of an algorithm ► Σ notation ► Θ notation ► Flowchart ► Asymptotic notation Question No: 3 ( Marks: 1 ) - Please choose one A RAM is an idealized machine with ______________ random-access memory. ► 256MB ► 512MB ► an infinitely large ► 100GB Question No: 4 ( Marks: 1 ) - Please choose one What type of instructions Random Access Machine (RAM) can execute? Choose best answer ► Algebraic and logic ► Geometric and arithmetic ► Arithmetic and logic ► Parallel and recursive Question No: 5 ( Marks: 1 ) - Please choose one

Page 26: CS502 Full Material

What will be the total number of max comparisons if we run brute-force maxima algorithm with n elements?

► 2n

► 2n

n ► n

► 8n

Question No: 6 ( Marks: 1 ) - Please choose one What is the solution to the recurrence T(n) = T(n/2)+n . ► O(logn) ► O(n) ► O(nlogn) ► O(n2) Question No: 7 ( Marks: 1 ) - Please choose one Consider the following code: For(j=1; j<n;j++) For(k=1; k<15;k++) For(l=5; l<n; l++) { Do_something_constant(); } What is the order of execution for this code. ► O(n) ► O(n3) ► O(n2 log n) ► O(n2) Question No: 8 ( Marks: 1 ) - Please choose one Consider the following Algorithm: Factorial (n){ if (n=1) return 1 else return (n * Factorial(n-1))

{ Recurrence for the following algorithm is: ► T(n) = T(n-1) +1 ► T(n) = nT(n-1) +1 ► T(n)= T(n-1) +n ► T(n)=T(n(n-1)) +1 Question No: 9 ( Marks: 1 ) - Please choose one

Page 27: CS502 Full Material

What is the total time to heapify? ► Ο(log n) ► Ο(n log n) ► Ο(n2 log n) ► Ο(log2 n) Question No: 10 ( Marks: 1 ) - Please choose one When we call heapify then at each level the comparison performed takes time ► It will take Θ (1) ► Time will vary according to the nature of input data ► It can not be predicted ► It will take Θ (log n) Question No: 11 ( Marks: 1 ) - Please choose one In Quick sort, we don’t have the control over the sizes of recursive calls ► True ► False ► Less information to decide ► Either true or false Question No: 12 ( Marks: 1 ) - Please choose one Is it possible to sort without making comparisons? ► Yes ► No Question No: 13 ( Marks: 1 ) - Please choose one If there are Θ (n2) entries in edit distance matrix then the total running time is ► Θ (1) ► Θ (n2) ► Θ (n) ► Θ (n log n) Question No: 14 ( Marks: 1 ) - Please choose one For Chain Matrix Multiplication we can not use divide and conquer approach because, ► We do not know the optimum k ► We use divide and conquer for sorting only ► We can easily perform it in linear time ► Size of data is not given Question No: 15 ( Marks: 1 ) - Please choose one The Knapsack problem belongs to the domain of _______________ problems. ► Optimization ► NP Complete ► Linear Solution ► Sorting

Page 28: CS502 Full Material

Question No: 16 ( Marks: 1 ) - Please choose one Suppose we have three items as shown in the following table, and suppose the capacity of the knapsack is 50 i.e. W = 50.

Item Value Weight1 60 102 100 203 120 30

The optimal solution is to pick ► Items 1 and 2 ► Items 1 and 3 ► Items 2 and 3 ► None of these

3. ______________ graphical representation of algorithm.

> asymptotic

>. flowchart

4. who invented the quick sort

C.A.R. Hoare

5. function is given like 4n^4+ 5n^3+n what is the run time of this

• Θ (n^4) • Θ (n^3) • Θ (4n^4+ 5n^3) • Θ (4n^4+ 5n^3)

6. main elements to a divide-and-conquer

Divide---->conquer---------->combine

7. T(n)={4 if n=1, otherwise T(n/5)+3n^2

what is the answer if n=5

answer is 79

Page 29: CS502 Full Material

8. Merge sort is a stable algorithm but not an in-place algorithm.

>True

>false

_______________ is a graphical representation of an algorithm • notation • Flowchart • Asymptotic notation

• ∑ notation

Question No: 2 ( Marks: 1 ) - Please choose one Which of the following is calculated with Big o notation?

• Lower bounds • Upper bounds • Both upper and lower bound • Medium bounds

Question No: 3 ( Marks: 1 ) - Please choose one Merge sort makes two recursive calls. Which statement is true after these recursive calls finish, but before the merge step?

• The array elements form a heap • Elements in each half of the array are sorted amongst themselves • Elements in the first half of the array are less than or equal to elements in the second half of the array • None of the above

Question No: 4 ( Marks: 1 ) - Please choose one Who invented Quick sort procedure?

• Hoare • Sedgewick • Mellroy • Coreman

Question No: 5 ( Marks: 1 ) - Please choose one What is the solution to the recurrence T(n) = T(n/2)+n, T(1) = 1

• O(logn) • O(n) • O(nlogn) • O(2n)

FINALTERM EXAMINATION Fall 2008

Page 30: CS502 Full Material

CS502- Fundamentals of Algorithms (Session - 1) Marks: 75 Question No: 1 ( Marks: 1 ) - Please choose one _______________ is a graphical representation of an algorithm notation Flowchart Asymptotic notation notation Question No: 2 ( Marks: 1 ) - Please choose one Which of the following is calculated with Bigo notation? Lower bounds Upper bounds Both upper and lower bound Medium bounds Question No: 3 ( Marks: 1 ) - Please choose one Merge sort makes two recursive calls. Which statement is true after these recursive calls finish, but before the merge step? The array elements form a heap Elements in each half of the array are sorted amongst themselves Elements in the first half of the array are less than or equal to elements in the second half of the array None of the above Question No: 4 ( Marks: 1 ) - Please choose one Who invented Quick sort procedure? Hoare Sedgewick Mellroy Coreman Question No: 5 ( Marks: 1 ) - Please choose one What is the solution to the recurrence T(n) = T(n/2)+n, T(1) = 1 O(logn) O(n) O(nlogn) O(2n) Question No: 6 ( Marks: 1 ) - Please choose one(Huffman tree is missing) Consider the following Huffman Tree The binary code for the string TEA is 10 00 010

Page 31: CS502 Full Material

011 00 010 10 00 110 11 10 110 Question No: 7 ( Marks: 1 ) - Please choose one If a graph has v vertices and e edges then to obtain a spanning tree we have to delete v edges. v e + 5 edges v + e edges. None of these Question No: 8 ( Marks: 1 ) - Please choose one Can an adjacency matrix for a directed graph ever not be square in shape? Yes No Question No: 9 ( Marks: 1 ) - Please choose one One of the clever aspects of heaps is that they can be stored in arrays without using any _______________. Pointers constants variables functions Question No: 10 ( Marks: 1 ) - Please choose one Merge sort requires extra array storage, True False Question No: 11 ( Marks: 1 ) - Please choose one Non-optimal or greedy algorithm for money change takes____________ O(k) O(kN) O(2k) O(N) Question No: 12 ( Marks: 1 ) - Please choose one The Huffman codes provide a method of encoding data inefficiently when coded using ASCII standard.

Page 32: CS502 Full Material

True False Question No: 13 ( Marks: 1 ) - Please choose one Using ASCII standard the string abacdaacac will be encoded with __________ bits. 80 160 320 100 Question No: 14 ( Marks: 1 ) - Please choose one Using ASCII standard the string abacdaacac will be encoded with 160 bits. True False Question No: 15 ( Marks: 1 ) - Please choose one Using ASCII standard the string abacdaacac will be encoded with 320 bits. True False Question No: 16 ( Marks: 1 ) - Please choose one Using ASCII standard the string abacdaacac will be encoded with 100 bits. True False Question No: 17 ( Marks: 1 ) - Please choose one Using ASCII standard the string abacdaacac will be encoded with 32 bytes True False Question No: 18 ( Marks: 1 ) - Please choose one The greedy part of the Huffman encoding algorithm is to first find two nodes with smallest frequency. True False Question No: 19 ( Marks: 1 ) - Please choose one The greedy part of the Huffman encoding algorithm is to first find two nodes with

Page 33: CS502 Full Material

character frequency True False Question No: 20 ( Marks: 1 ) - Please choose one Huffman algorithm uses a greedy approach to generate an antefix code T that minimizes the expected length B (T) of the encoded string. True False Question No: 21 ( Marks: 1 ) - Please choose one Depth first search is shortest path algorithm that works on un-weighted graphs. True False Question No: 22 ( Marks: 1 ) - Please choose one Dijkestra s single source shortest path algorithm works if all edges weights are nonnegative and there are no negative cost cycles. True False Question No: 23 ( Marks: 1 ) - Please choose one Dijkestra s single source shortest path algorithm works if all edges weights are negative and there are no negative cost cycles. True False hb Question No: 24 ( Marks: 1 ) - Please choose one Floyd-Warshall algorithm is a dynamic programming algorithm; the genius of the algorithm is in the clever recursive formulation of the shortest path problem. True Flase Question No: 25 ( Marks: 1 ) - Please choose one Floyd-Warshall algorithm, as in the case with DP algorithms, we avoid recursive evaluation by generating a table for k ij d True

Page 34: CS502 Full Material

Flase Question No: 26 ( Marks: 1 ) - Please choose one The term coloring came form the original application which was in map drawing. True False Question No: 27 ( Marks: 1 ) - Please choose one In the clique cover problem, for two vertices to be in the same group, they must be _______________each other. Apart from Far from Near to Adjacent to Question No: 28 ( Marks: 1 ) - Please choose one In the clique cover problem, for two vertices to be in the same group, they must be apart from each other. True False Question No: 29 ( Marks: 1 ) - Please choose one The difference between Prim s algorithm and Dijkstra s algorithm is that Dijkstra s algorithm uses a different key. True False Question No: 30 ( Marks: 1 ) - Please choose one The difference between Prim s algorithm and Dijkstra s algorithm is that Dijkstra s algorithm uses a same key. True False Question # 1 of 10 ( Start time: 06:18:58 PM ) Total Marks: 1 We do sorting to, Select correct option: keep elements in random positions keep the algorithm run in linear order keep the algorithm run in (log n) order keep elements in increasing or decreasing order

Page 35: CS502 Full Material

Question # 2 of 10 ( Start time: 06:19:38 PM ) Total Marks: 1 Heaps can be stored in arrays without using any pointers; this is due to the ____________ nature of the binary tree, Select correct option: left-complete right-complete tree nodes tree leaves Sieve Technique can be applied to selection problem? Select correct option: True False Question # 4 of 10 ( Start time: 06:21:10 PM ) Total Marks: 1 A heap is a left-complete binary tree that conforms to the ___________ Select correct option: increasing order only decreasing order only heap order (log n) order Question # 5 of 10 ( Start time: 06:21:39 PM ) Total Marks: 1 A (an) _________ is a left-complete binary tree that conforms to the heap order Select correct option: heap binary tree binary search tree array Question # 6 of 10 ( Start time: 06:22:04 PM ) Total Marks: 1 Divide-and-conquer as breaking the problem into a small number of Select correct option: pivot Sieve smaller sub problems Selection Question # 7 of 10 ( Start time: 06:22:40 PM ) Total Marks: 1 In Sieve Technique we do not know which item is of interest Select correct option:

Page 36: CS502 Full Material

True False Question # 8 of 10 ( Start time: 06:23:26 PM ) Total Marks: 1 The recurrence relation of Tower of Hanoi is given below T(n)={1 if n=1 and 2T(n-1) if n >1 In order to move a tower of 5 rings from one peg to another, how many ring moves are required? Select correct option: 16 10 32 31 (yeh just tukkahai) Question # 9 of 10 ( Start time: 06:24:44 PM ) Total Marks: 1 In the analysis of Selection algorithm, we eliminate a constant fraction of the array with each phase; we get the convergent _______________ series in the analysis, Select correct option: linear arithmetic geometric (yeh b gup hi lugtihai) exponent Question # 10 of 10 ( Start time: 06:25:43 PM ) Total Marks: 1 For the heap sort, access to nodes involves simple _______________ operations. Select correct option: arithmetic binary algebraic logarithmic (bongihai...) Question No: 31 ( Marks: 1 ) Do you think greedy algorithm gives an optimal solution to the activity scheduling problem? yes, greedy algorithm gives an optimal solution to the activity scheduling problem. as we have the data as a whole ,and activity a1 must be started at a given start time and ends at a given finish time. all the intermediate activities who overlap will be excluded automatically as no new activity will be selected as our data till the finish of last activity. so this greediness of algorithm gives us the optimal solution.

Page 37: CS502 Full Material

Question No: 32 ( Marks: 1 ) Define Forward edge A forward edge is a non-tree edge that connects a vertex to a descendent in a DFS-tree. Question No: 33 ( Marks: 2 ) Is there any relationship between number of back edges and number of cycles in DFS? A back edge connects a vertex to an ancestor in a DFS-tree. No back edges means no cycles. But there is some simple relationship Between the number of back edges and the number of cycles. For example, a DFS tree may only have a single back edge, and there may anywhere from one up to an exponential number of simple cycles in the graph. Question No: 34 ( Marks: 2 ) What is the common problem in communications networks and circuit designing? Common problem in communications networks and circuit design is that of connecting together a set of nodes by a network of total minimum length. The length is the sum of lengths of connecting wires. Question No: 35 ( Marks: 3 ) Let the adjacency list representation of an undirected graph is given below. Explain what general property of the list indicates that the graph has an isolated vertex. a b c e b a d c a d e f d b c f e a c f f c d e g Ans: A graph is connected if every vertex can reach Every other vertex. and is isolated if any node has not connected to other vertex ,here’s “g” is the node that is not connected with any other vertex. This general property of the list indicates that the graph has an isolated vertex.

Algorithm-CS502 QUIZ # 1

Mc090400760

Page 38: CS502 Full Material

03-11-2010

Top of Form

/wEPDwUKMTY2N

/wEWCgKwyJHhD

MC090400760 : Imran Shahzad Quiz Start Time: 11:20 PM

Time Left 35 sec(s)

Question # 1 of 10 ( Start time: 11:20:20 PM ) Total Marks: 1 The number of nodes in a complete binary tree of height h is

Select correct option:

2^(h+1) – 1

2 * (h+1) – 1

2 * (h+1)

((h+1) ^ 2) – 1

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

/wEPDwUKMTY2N

/wEWCgLM9c6GB

MC090400760 : Imran Shahzad Quiz Start Time: 11:20 PM

Time Left 81 sec(s)

Page 39: CS502 Full Material

Question # 2 of 10 ( Start time: 11:21:44 PM ) Total Marks: 1 A heap is a left-complete binary tree that conforms to the ___________

Select correct option:

increasing order only

decreasing order only

heap order

(log n) order

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

/wEPDwUKMTY2N

/wEWCgK5yJH0C

MC090400760 : Imran Shahzad Quiz Start Time: 11:20 PM

Time Left 79 sec(s)

Question # 3 of 10 ( Start time: 11:22:29 PM ) Total Marks: 1 In which order we can sort?

Select correct option:

increasing order only

decreasing order only

Page 40: CS502 Full Material

increasing order or decreasing order

both at the same time

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

/wEPDwUKMTY2N

/wEWCgKC78FiAr

MC090400760 : Imran Shahzad Quiz Start Time: 11:20 PM

Time Left 8 sec(s)

Question # 4 of 10 ( Start time: 11:22:57 PM ) Total Marks: 1 Consider the following Algorithm: Fun(n){ if (n=1) return 1 else return (n * Fun(n-1)) } Recurrence for the above algorithm is:

Select correct option:

nT(n-1)+1

2T(n-1)+1

T(n-1)+cn

T(n-1)+1

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

/wEPDwUKMTY2N

Page 41: CS502 Full Material

/wEWCgKK8J16A

MC090400760 : Imran Shahzad Quiz Start Time: 11:20 PM

Time Left 7 sec(s)

Question # 5 of 10 ( Start time: 11:24:25 PM ) Total Marks: 1 How much time merge sort takes for an array of numbers?

Select correct option:

T(n^2)

T(n)

T( log n)

T(n log n)

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

/wEPDwUKMTY2N

/wEWBgKp0t/HCw

MC090400760 : Imran Shahzad Quiz Start Time: 11:20 PM

Time Left 17 sec(s)

Question # 6 of 10 ( Start time: 11:25:57 PM ) Total Marks: 1 Sieve Technique can be applied to selection problem?

Select correct option:

True

Page 42: CS502 Full Material

False

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

/wEPDwUKMTY2N

/wEWCgKphcL+A

MC090400760 : Imran Shahzad Quiz Start Time: 11:20 PM

Time Left 72 sec(s)

Question # 7 of 10 ( Start time: 11:27:23 PM ) Total Marks: 1 The reason for introducing Sieve Technique algorithm is that it illustrates a very important special case of,

Select correct option:

divide-and-conquer

decrease and conquer

greedy nature

2-dimension Maxima

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

/wEPDwUKMTY2N

/wEWCgLShL2ZCA

MC090400760 : Imran Shahzad Quiz Start Time: 11:20 PM

Time Left 20 sec(s)

Page 43: CS502 Full Material

Question # 8 of 10 ( Start time: 11:27:57 PM ) Total Marks: 1 The analysis of Selection algorithm shows the total running time is indeed ________in n,

Select correct option:

arithmetic

geometric

linear

orthogonal

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

/wEPDwUKMTY2N

/wEWCgK8/peKBQ

MC090400760 : Imran Shahzad Quiz Start Time: 11:20 PM

Time Left 42 sec(s)

Question # 9 of 10 ( Start time: 11:29:27 PM ) Total Marks: 1 For the Sieve Technique we take time

Select correct option:

T(nk)

T(n / 3)

Page 44: CS502 Full Material

n^2

n/3

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

/wEPDwUKMTY2N

/wEWCgKQ9dDrA

MC090400760 : Imran Shahzad Quiz Start Time: 11:20 PM

Time Left 23 sec(s)

Question # 10 of 10 ( Start time: 11:30:44 PM ) Total Marks: 1 How many elements do we eliminate in each time for the Analysis of Selection algorithm?

Select correct option:

n / 2 elements

(n / 2) + n elements

n / 4 elements

2 n elements

Click here to Save Answer & Move to Next Question

Bottom of Form Quiz Start Time: 06:18 PM Time Left 55 sec(s)

Page 45: CS502 Full Material

Question # 1 of 10 ( Start time: 06:18:58 PM ) Total Marks: 1 We do sorting to, Select correct option: keep elements in random positions keep the algorithm run in linear order keep the algorithm run in (log n) order keep elements in increasing or decreasing order MC090406557 : Nadia Parveen Quiz Start Time: 06:18 PM Time Left 62 sec(s) Question # 2 of 10 ( Start time: 06:19:38 PM ) Total Marks: 1 Heaps can be stored in arrays without using any pointers; this is due to the ____________ nature of the binary tree, Select correct option: left-complete right-complete tree nodes tree leaves MC090406557 : Nadia Parveen Quiz Start Time: 06:18 PM Time Left 77 sec(s)

Page 46: CS502 Full Material

Question # 3 of 10 ( Start time: 06:20:18 PM ) Total Marks: 1 Sieve Technique can be applied to selection problem? Select correct option: True False MC090406557 : Nadia Parveen Quiz Start Time: 06:18 PM Time Left 74 sec(s) Question # 4 of 10 ( Start time: 06:21:10 PM ) Total Marks: 1 A heap is a left-complete binary tree that conforms to the ___________ Select correct option: increasing order only decreasing order only heap order (log n) order MC090406557 : Nadia Parveen Quiz Start Time: 06:18 PM Time Left 77 sec(s) Question # 5 of 10 ( Start time: 06:21:39 PM ) Total Marks: 1 A (an) _________ is a left-complete binary tree that conforms to the heap order

Page 47: CS502 Full Material

Select correct option: heap binary tree binary search tree array MC090406557 : Nadia Parveen Quiz Start Time: 06:18 PM Time Left 72 sec(s) Question # 6 of 10 ( Start time: 06:22:04 PM ) Total Marks: 1 Divide-and-conquer as breaking the problem into a small number of Select correct option: pivot Sieve smaller sub problems Selection MC090406557 : Nadia Parveen Quiz Start Time: 06:18 PM Time Left 48 sec(s) Question # 7 of 10 ( Start time: 06:22:40 PM ) Total Marks: 1

Page 48: CS502 Full Material

In Sieve Technique we do not know which item is of interest Select correct option: True False MC090406557 : Nadia Parveen Quiz Start Time: 06:18 PM Time Left 34 sec(s) Question # 8 of 10 ( Start time: 06:23:26 PM ) Total Marks: 1 The recurrence relation of Tower of Hanoi is given below T(n)={1 if n=1 and 2T(n-1) if n >1 In order to move a tower of 5 rings from one peg to another, how many ring moves are required? Select correct option: 16 10 32 31 (yeh just tukka hai) MC090406557 : Nadia Parveen Quiz Start Time: 06:18 PM Time Left 36 sec(s) Question # 9 of 10 ( Start time: 06:24:44 PM ) Total Marks: 1

Page 49: CS502 Full Material

In the analysis of Selection algorithm, we eliminate a constant fraction of the array with each phase; we get the convergent _______________ series in the analysis, Select correct option: linear arithmetic geometric (yeh b gup hi lugti hai) exponent MC090406557 : Nadia Parveen Quiz Start Time: 06:18 PM Time Left 76 sec(s) Question # 10 of 10 ( Start time: 06:25:43 PM ) Total Marks: 1 For the heap sort, access to nodes involves simple _______________ operations. Select correct option: arithmetic binary algebraic logarithmic (bongi hai...) Question # 1 of 10 ( Start time: 10:02:41 PM ) Total Marks: 1 For the sieve technique we solve the problem, Select correct option: recursively mathematically precisely accurately The sieve technique works in ___________ as follows Select correct option: phases numbers integers routines Slow sorting algorithms run in, Select correct option:

Page 50: CS502 Full Material

T(n^2) T(n) T( log n) A (an) _________ is a left-complete binary tree that conforms to the heap order Select correct option: heap binary tree binary search tree array In the analysis of Selection algorithm, we eliminate a constant fraction of the array with each phase; we get the convergent _______________ series in the analysis, Select correct option: linear arithmetic geometric exponent In the analysis of Selection algorithm, we make a number of passes, in fact it could be as many as, Select correct option: T(n) T(n / 2) log n n / 2 + n / 4 The sieve technique is a special case, where the number of sub problems is just Select correct option: 5 many 1 few In which order we can sort? Select correct option: increasing order only decreasing order only increasing order or decreasing order both at the same time The recurrence relation of Tower of Hanoi is given below T(n)={1 if n=1 and 2T(n-1) if n >1 In order to move a tower of 5 rings from one peg to another, how many ring moves are required? Select correct option: 16 10

Page 51: CS502 Full Material

32 31 Analysis of Selection algorithm ends up with, Select correct option: T(n) T(1 / 1 + n) T(n / 2) T((n / 2) + n) Last message received on 10/13 at 12:43 AM Khanjee: We do sorting to, Select correct option: keep elements in random positions keep the algorithm run in linear order keep the algorithm run in (log n) order keep elements in increasing or decreasing order Khanjee: Divide-and-conquer as breaking the problem into a small number of Select correct option: pivot Sieve smaller sub problems Selection The analysis of Selection algorithm shows the total running time is indeed ________in n, Select correct option: arithmetic geometric linear orthogonal How many elements do we eliminate in each time for the Analysis of Selection algorithm? Select correct option:

Page 52: CS502 Full Material

n / 2 elements (n / 2) + n elements n / 4 elements 2 n elements Sieve Technique can be applied to selection problem? Select correct option: True For the heap sort we store the tree nodes in Select correct option: level-order traversal in-order traversal pre-order traversal post-order traversal 1-One of the clever aspects of heaps is that they can be stored in arrays without using any _______________. pointers ** constants variables functions 2- For the heap sort we store the tree nodes in level-order traversal** in-order traversal

Page 53: CS502 Full Material

pre-order traversal post-order traversal 3- The sieve technique works in ___________ as follows phases numbers integers ** not confrm routines 4- In the analysis of Selection algorithm, we eliminate a constant fraction of the array with each phase; we get the convergent _______________ series in the analysis, linear arithmetic geometric ** exponent 5- We do sorting to, keep elements in random positions keep the algorithm run in linear order

Page 54: CS502 Full Material

keep the algorithm run in (log n) order keep elements in increasing or decreasing order *** 6- In the analysis of Selection algorithm, we make a number of passes, in fact it could be as many as, T(n) T(n / 2)*** log n n / 2 + n / 4 7- In which order we can sort? increasing order only decreasing order only increasing order or decreasing order *** both at the same time 8- In Sieve Technique we do not know which item is of interest True** False 9- For the sieve technique we solve the problem, recursively**

Page 55: CS502 Full Material

mathematically precisely 10- Divide-and-conquer as breaking the problem into a small number of pivot Sieve smaller sub problems ** Selection Question # 1 of 10 Total Marks: 1 Divide-and-Conquer is as breaking the problem into a small number of · Smaller Sub Problems · Pivot · Sieve · Solutions Question # 2 of 10 Total Marks: 1 Analysis of Selection Sort ends up with · T(n) · T(1/1+n) · T(n/2) · T((n/2) +n) Question # 3 of 10 Total Marks: 1 How many elements do we eliminate each time for the Analysis of Selection Algorithm? · (n / 2)+n Elements · n / 2 Elements · n / 4 Elements · 2 n Elements Question # 4 of 10 Total Marks: 1 A heap is a left-complete binary tree that conforms to the ?

Page 56: CS502 Full Material

· Increasing Order · Decreasing order · Heap Order · (nlog n) order Question # 5 of 10 Total Marks: 1 The Sieve Sequence is a special case where the number of smaller sub problems is just_ . · 4 · Many · 1 · Few Imrangee Question # 6 of 10 Total Marks: 1 Heaps can be stored in arrays without using any pointers this is due to the of the binary tree? · Tree Nodes · Right-Complete Nature · Left-Complete Nature · Tree Leaves Question # 7 of 10 Total Marks: 1 For the Heap Sort access to nodes involves simple _ operations: · Geometric · Linear · Arithmetic · Algebraic Question # 8 of 10 Total Marks: 1 The Analysis of Selection Sort shows that the total running time is indeed in n? · Geometric · Linear · Arithmetic · Algebraic Question # 9 of 10 Total Marks: 1 For the sieve technique we solve the problem · Recursively · Randomly · Mathematically · Precisely

Page 57: CS502 Full Material

Question # 10 of 10 Total Marks: 1 How much time merger sort takes for an array of numbers? · T(n^2) · T(n) · T(log n) · T(n log n)

Top of Form

/w EPDw UKMTY2 /w EWCgKcsdzgD

MC090406505 : Quiz Start Time: 06:48 PM

Time Left 86 sec(s)

Question # 1 of 10 ( Start time: 06:48:26 PM ) Total Marks: 1 How many elements do we eliminate in each time for the Analysis of Selection algorithm?

Select correct option:

n / 2 elements

(n / 2) + n elements

n / 4 elements

2 n elements

Click here to Save Answ er & Move to Next Question

Bottom of Form Top of Form

/w EPDw UKMTY2 /w EWCgLeqo+iDQ

MC090406505 :

Time Left 83

Page 58: CS502 Full Material

Quiz Start Time: 06:48 PM

sec(s)

Question # 2 of 10 ( Start time: 06:49:01 PM ) Total Marks: 1 The recurrence relation of Tower of Hanoi is given below T(n)={1 if n=1 and 2T(n-1) if n >1 In order to move a tower of 5 rings from one peg to another, how many ring moves are required?

Select correct option:

16

10

32

31

Click here to Save Answ er & Move to Next Question

Bottom of Form Top of Form

/w EPDw UKMTY2 /w EWCgKqyK/qB

MC090406505 : Quiz Start Time: 06:48 PM

Time Left 85 sec(s)

Question # 3 of 10 ( Start time: 06:49:38 PM ) Total Marks: 1 The number of nodes in a complete binary tree of height h is

Select correct option:

Page 59: CS502 Full Material

2^(h+1) – 1

2 * (h+1) – 1

2 * (h+1)

((h+1) ^ 2) – 1

Click here to Save Answ er & Move to Next Question

Bottom of Form Top of Form

/w EPDw UKMTY2 /w EWCgL8369kA

MC090406505 Quiz Start Time: 06:48 PM

Time Left 87 sec(s)

Question # 4 of 10 ( Start time: 06:50:58 PM ) Total Marks: 1 One of the clever aspects of heaps is that they can be stored in arrays without using any _______________.

Select correct option:

pointers

constants

variables

Page 60: CS502 Full Material

functions

Click here to Save Answ er & Move to Next Question

Bottom of Form Top of Form

/w EPDw UKMTY2 /w EWCgL6y4/ED

MC090406505 : Quiz Start Time: 06:48 PM

Time Left 83 sec(s)

Question # 5 of 10 ( Start time: 06:51:24 PM ) Total Marks: 1 We do sorting to,

Select correct option:

keep elements in random positions

keep the algorithm run in linear order

keep the algorithm run in (log n) order

keep elements in increasing or decreasing order

Click here to Save Answ er & Move to Next Question

Bottom of Form Top of Form

/w EPDw UKMTY2 /w EWBgLg8ajOA

MC090406505 : Time Left 87

sec(s)

Page 61: CS502 Full Material

Quiz Start Time: 06:48 PM

Question # 6 of 10 ( Start time: 06:52:04 PM ) Total Marks: 1 In Sieve Technique we do not know which item is of interest

Select correct option:

True

False

Click here to Save Answ er & Move to Next Question

Bottom of Form Top of Form

/w EPDw UKMTY2 /w EWCgKQh8mZ

MC090406505 : Quiz Start Time: 06:48 PM

Time Left 83 sec(s)

Question # 7 of 10 ( Start time: 06:52:27 PM ) Total Marks: 1 Consider the following Algorithm: Fun(n){ if (n=1) return 1 else return (n * Fun(n-1)) } Recurrence for the above algorithm is:

Select correct option:

nT(n-1)+1

2T(n-1)+1

T(n-1)+cn

Page 62: CS502 Full Material

T(n-1)+1

Click here to Save Answ er & Move to Next Question

Bottom of Form Top of Form

/w EPDw UKMTY2 /w EWCgK26bnjD

MC090406505 : Quiz Start Time: 06:48 PM

Time Left 85 sec(s)

Question # 8 of 10 ( Start time: 06:53:56 PM ) Total Marks: 1 In the analysis of Selection algorithm, we make a number of passes, in fact it could be as many as,

Select correct option:

T(n)

T(n / 2)

log n

n / 2 + n / 4

Click here to Save Answ er & Move to Next Question

Bottom of Form Top of Form

/w EPDw UKMTY2 /w EWCgLuw +Tn

MC090406505 : Time Left 84

Page 63: CS502 Full Material

Quiz Start Time: 06:48 PM

sec(s)

Question # 9 of 10 ( Start time: 06:54:25 PM ) Total Marks: 1 The reason for introducing Sieve Technique algorithm is that it illustrates a very important special case of,

Select correct option:

divide-and-conquer

decrease and conquer

greedy nature

2-dimension Maxima

Click here to Save Answ er & Move to Next Question

Bottom of Form Top of Form

/w EPDw UKMTY2 /w EWCgLuw +Tn

MC090406505 : Quiz Start Time: 06:48 PM

Time Left 84 sec(s)

Question # 9 of 10 ( Start time: 06:54:25 PM ) Total Marks: 1 The reason for introducing Sieve Technique algorithm is that it illustrates a very important special case of,

Select correct option:

Page 64: CS502 Full Material

divide-and-conquer

decrease and conquer

greedy nature

2-dimension Maxima

Click here to Save Answ er & Move to Next Question

Bottom of Form Top of Form

/w EPDw UKMTY2 /w EWCgLMjsiqBQ

MC090406505 : Quiz Start Time: 06:48 PM

Time Left 80 sec(s)

Question # 10 of 10 ( Start time: 06:54:55 PM ) Total Marks: 1 In which order we can sort?

Select correct option:

increasing order only

decreasing order only

increasing order or decreasing order

Page 65: CS502 Full Material

both at the same time

Click here to Save Answ er & Move to Next Question

Bottom of Form

1 - What type of instructions Random Access Machine (RAM) can execute? Choose best answer

1. Algebraic and logic 2. Geometric and arithmetic 3. Arithmetic and logic 4. Parallel and recursive

Correct Choice : 3 From Lectuer # 1 www.vugujranwala.com

2 - Random access machine or RAM is a/an

1. Machine build by Al-Khwarizmi 2. Mechanical machine 3. Electronics machine 4. Mathematical model

Correct Choice : 4 From Lectuer # 1 www.vugujranwala.com

3 - _______________ is a graphical representation of an algorithm

1. Segma Notation 2. Thita Notation 3. Flowchart 4. Asymptotic notation

Correct Choice : 3 From Lectuer # 2 www.vugujranwala.com

4 - What will be the total number of max comparisons if we run brute-force maxima algorithm with n elements?

1. n^2 2. n^n/2 3. n 4. n^8

Correct Choice : 1 From Lectuer # 3

Page 66: CS502 Full Material

www.vugujranwala.com

5 - function is given like 4n^4+ 5n^3+n what is the run time of this

1. theata(n^4) 2. theata(n^3) 3. theata(4n^4+ 5n^3) 4. theata(4n^4+ 5n^3)

Correct Choice : 1 From Lectuer # 4 www.vugujranwala.com

6 - Consider the following code: For(j=1; j

www.vugujranwala.com

7 - Execution of the following code fragment int i = N; while (i > 0)

Page 67: CS502 Full Material

{ int Sum = 0; int j; for (j = 0; j Sum++; cout

www.vugujranwala.com

8 - Let us say we have an algorithm that carries out N2 operations for an input of size N. Let us say that a computer takes 1 microsecond (1/1000000 second) to carry out one operation. How long does the algorithm run for an input of size 3000?

1. 90 seconds 2. 9 seconds 3. 0.9 seconds 4. 0.09 seconds

Correct Choice : 2 From Lectuer # 4 www.vugujranwala.com

9 - The appropriate big thita classification of the given function. f(n) = 4n2 + 97n + 1000 is

1. ?(n) 2. O(2^n) 3. O(n^2) 4. O(n^2logn)

Correct Choice : 3 From Lectuer # 4 www.vugujranwala.com

10 - The appropriate big ? classification of the given function. f(n) = 4n2 + 97n + 1000 is

1. ?(n) 2. O(2^n) 3. O(n^2) 4. O(n^2logn)

Correct Choice : 3 From Lectuer # 4 www.vugujranwala.com

11 - Which sorting algorithm is faster

1. O (n log n) 2. O n^2 3. O (n+k) 4. O n^3

Correct Choice : 3 From Lectuer # 5 www.vugujranwala.com

12 - If algorithm A has running time 7n^2 + 2n + 3 and algorithm B has running time 2n^2, then

1. Both have same asymptotic time complexity 2. A is asymptotically greater 3. B is asymptotically greater 4. None of others

Page 68: CS502 Full Material

Correct Choice : 1 From Lectuer # 6 www.vugujranwala.com

13 - If algorithm A has running time 7n^2 + 2n + 3 and algorithm B has running time 2n^2, then

1. Both have same asymptotic time complexity 2. A is asymptotically greater 3. B is asymptotically greater 4. None of others

Correct Choice : 1 From Lectuer # 6 www.vugujranwala.com

14 - What is the solution to the recurrence T(n) = T(n/2)+n .

1. O(logn) 2. O(n) 3. O(nlogn) 4. O(n^2)

Correct Choice : 1 From Lectuer # 8 www.vugujranwala.com

15 - How much time merge sort takes for an array of numbers?

1. (n^2) 2. T(n) 3. T( log n) 4. T(n log n)

Correct Choice : 2 From Lectuer # 8 www.vugujranwala.com

www.vugujranwala.com

17 - Consider the following Algorithm: Factorial (n){ if (n=1)

return 1 else return (n * Factorial(n-1))

} Recurrence for the following algorithm is:

1. T(n) = T(n-1) +1 2. T(n) = nT(n-1) +1 3. T(n)= T(n-1) +n 4. T(n)=T(n(n-1)) +1

Correct Choice : 4 From Lectuer # 9 www.vugujranwala.com

18 - For the Sieve Technique we take time

1. T(nk) . 2. T(n / 3)

Page 69: CS502 Full Material

3. n^2 4. n/3

Correct Choice : 1 From Lectuer # 10 www.vugujranwala.com

www.vugujranwala.com

20 - Sieve Technique applies to problems where we are interested in finding a single itemfrom a larger set of _____________

1. n items 2. phases 3. pointers 4. constant

Correct Choice : 1 From Lectuer # 10 www.vugujranwala.com

www.vugujranwala.com

22 - In Sieve Technique we do not know which item is of interest

1. FALSE 2. TRUE 3. 4.

Correct Choice : 2 From Lectuer # 10 www.vugujranwala.com

23 - For the sieve technique we solve the problem,

1. recursively 2. mathematically 3. accurately 4. precisely

Correct Choice : 1 From Lectuer # 10 www.vugujranwala.com

24 - For the Sieve Technique we take time

1. T(nk) 2. T(n / 3) 3. n^2 4. n/3

Correct Choice : 1 From Lectuer # 10 www.vugujranwala.com

25 - How many elements do we eliminate in each time for the Analysis of Selectionalgorithm?

1. n / 2 elements 2. (n / 2) + n elements 3. n / 4 elements 4. n elements

Page 70: CS502 Full Material

Correct Choice : 4 From Lectuer # 10 www.vugujranwala.com

26 - Sieve Technique applies to problems where we are interested in finding a single itemfrom a larger set of _____________

1. n items 2. phases 3. pointers 4. constant

Correct Choice : 1 From Lectuer # 10 www.vugujranwala.com

27 - Sieve Technique can be applied to selection problem?

1. TRUE 2. FALSE 3. 4.

Correct Choice : 1 From Lectuer # 10 www.vugujranwala.com

28 - The analysis of Selection algorithm shows the total running time is indeed ________in n,

1. arithmetic 2. geometric 3. linear 4. orthogonal

Correct Choice : 3 From Lectuer # 10 www.vugujranwala.com

29 - The reason for introducing Sieve Technique algorithm is that it illustrates a very important special case of,

1. divide-and-conquer 2. decrease and conquer 3. greedy nature 4. 2-dimension Maxima

Correct Choice : 1 From Lectuer # 10 www.vugujranwala.com

30 - The sieve technique works in ___________ as follows

1. phases 2. numbers 3. integers 4. routines

Correct Choice : 1 From Lectuer # 10 www.vugujranwala.com

31 - The sieve technique works in ___________ as follows

1. phases

Page 71: CS502 Full Material

2. numbers 3. integers 4. routines

Correct Choice : 1 From Lectuer # 10 www.vugujranwala.com

32 - A (an) _________ is a left-complete binary tree that conforms to the heap order

1. heap 2. binary tree 3. binary search tree 4. array

Correct Choice : 1 From Lectuer # 11 www.vugujranwala.com

www.vugujranwala.com

34 - For the heap sort, access to nodes involves simple _______________ operations.

1. arithmetic 2. binary 3. algebraic 4. logarithmic

Correct Choice : 1 From Lectuer # 11 www.vugujranwala.com

www.vugujranwala.com

www.vugujranwala.com

37 - We do sorting to,

1. keep elements in random positions 2. keep the algorithm run in linear order 3. keep the algorithm run in (log n) order 4. keep elements in increasing or decreasing order

Correct Choice : 1 From Lectuer # 11 www.vugujranwala.com

www.vugujranwala.com

www.vugujranwala.com

www.vugujranwala.com

www.vugujranwala.com

42 - For the heap sort we store the tree nodes in

1. level-order traversal 2. in-order traversal 3. pre-order traversal 4. post-order traversal

Correct Choice : 1 From Lectuer # 11 www.vugujranwala.com

Page 72: CS502 Full Material

www.vugujranwala.com

44 - In the analysis of Selection algorithm, we make a number of passes, in fact it could be asmany as,

1. T(n) 2. T(n / 2) 3. log n 4. n / 2 + n / 4

Correct Choice : 3 From Lectuer # 11 www.vugujranwala.com

45 - In the analysis of Selection algorithm, we make a number of passes, in fact it could be asmany as,

1. T(n) 2. T(n / 2) 3. log n 4. n / 2 + n / 4

Correct Choice : 3 From Lectuer # 11 www.vugujranwala.com

46 - In which order we can sort?

1. increasing order only 2. decreasing order only 3. increasing order or decreasing order 4. both at the same time

Correct Choice : 3 From Lectuer # 11 www.vugujranwala.com

47 - One of the clever aspects of heaps is that they can be stored in arrays without using any_______________.

1. pointers 2. constants 3. variables 4. functions

Correct Choice : 1 From Lectuer # 11 www.vugujranwala.com

48 - One of the clever aspects of heaps is that they can be stored in arrays without using any_______________.

1. pointers 2. constants 3. variables 4. functions

Correct Choice : 1 From Lectuer # 11 www.vugujranwala.com

49 - Slow sorting algorithms run in,

1. O(n^2)

Page 73: CS502 Full Material

2. O(n) 3. O( log n) 4. O(n log n)

Correct Choice : 1 From Lectuer # 11 www.vugujranwala.com

50 - What is the total time to heapify?

1. ?(log n) 2. ?(n log n) 3. ?(n^2 log n) 4. ?(log^2n)

Correct Choice : 1 From Lectuer # 12 www.vugujranwala.com

-When we call heapify then at each level the comparison performed takes time It will takeO (1)

1. Time will vary according to the nature of input data 2. It can not be predicted 3. It will take O (log n) 4. None of the Given

Correct Choice : 3 From Lectuer # 12 www.vugujranwala.com

www.vugujranwala.com

53 - After partitioning array in Quick sort, pivot is placed in a position such that

1. Values smaller than pivot are on left and larger than pivot are on right 2. Values larger than pivot are on left and smaller than pivot are on right 3. Pivot is the first element of array 4. Pivot is the last element of array

Correct Choice : 2 From Lectuer # 13 www.vugujranwala.com

54 - The running time of quick sort depends heavily on the selection of

1. No of inputs 2. Arrangement of elements in array 3. Size o elements 4. Pivot element

Correct Choice : 4 From Lectuer # 13 www.vugujranwala.com

55 - In Quick Sort Constants hidden in T(n log n) are

1. Large 2. Medium 3. Small 4. Not Known

Correct Choice : 3 From Lectuer # 14 www.vugujranwala.com

Page 74: CS502 Full Material

56 - In Quick Sort Constants hidden in T(n log n) are

1. Large 2. Medium 3. Small 4. Not Known

Correct Choice : 3 From Lectuer # 14 www.vugujranwala.com

57 - Is it possible to sort without making comparisons?

1. Yes 2. No 3. 4.

Correct Choice : 1 From Lectuer # 15 www.vugujranwala.com

58 - Merge sort is stable sort, but not an in-place algorithm

1. TRUE 2. FALSE 3. 4.

Correct Choice : 1 From Lectuer # 15 www.vugujranwala.com

59 - In counting sort, once we know the ranks, we simply _________ numbers to their finalpositions in an output array.

1. Delete 2. copy 3. Mark 4. arrange

Correct Choice : 2 From Lectuer # 15 www.vugujranwala.com

60 - An in place sorting algorithm is one that uses ___ arrays for storage

1. Two dimensional arrays 2. More than one array 3. No Additional Array 4. None of the above

Correct Choice : 3 From Lectuer # 15 www.vugujranwala.com

61 - Continuation/counting sort is suitable to sort the elements in range 1 to k

1. K is Large 2. K is not known 3. K may be small or large 4. K is small

Page 75: CS502 Full Material

Correct Choice : 4 From Lectuer # 15 www.vugujranwala.com

62 - In stable sorting algorithm.

1. If duplicate elements remain in the same relative position after sorting 2. One array is used 3. More than one arrays are required 4. Duplicating elements not handled

Correct Choice : 1 From Lectuer # 15 www.vugujranwala.com

63 - One example of in place but not stable algorithm is

1. Merger Sort 2. Quick Sort 3. Continuation Sort 4. Bubble Sort

Correct Choice : 2 From Lectuer # 15 www.vugujranwala.com

64 - One example of in place but not stable algorithm is

1. Merger Sort 2. Quick Sort 3. Continuation Sort 4. Bubble Sort

Correct Choice : 2 From Lectuer # 15 www.vugujranwala.com

65 - One of the clever aspects of heaps is that they can be stored in arrays without using any _______________.

1. pointers 2. constants 3. variables 4. functions

Correct Choice : 1

66 - Quick sort is

1. Stable & in place 2. Not stable but in place 3. Stable but not in place

From Lectuer # 15 www.vugujranwala.com

4. Some time stable & some times in place Correct Choice : 3 From Lectuer # 15

www.vugujranwala.com

67 - Quick sort is

1. Stable & in place 2. Not stable but in place 3. Stable but not in place

Page 76: CS502 Full Material

4. Some time stable & some times in place Correct Choice : 2 From Lectuer # 15

www.vugujranwala.com

68 - Which may be a stable sort?

1. Merger 2. Insertion 3. Both above 4. None of the above

Correct Choice : 3 From Lectuer # 15 www.vugujranwala.com

69 - Which of the following sorting algorithms is stable? (i) Merge sort, (ii) Quick sort, (iii) Heap sort, (iv) Counting Sort.

1. Only i 2. Only ii 3. Both i and ii 4. Both iii and iv

Correct Choice : 1 From Lectuer # 15 www.vugujranwala.com

70 - Which of the following sorting algorithms is stable? (i) Merge sort, (ii) Quick sort, (iii) Heap sort, (iv) Counting Sort.

1. Only i 2. Only ii 3. Both i and ii 4. Both iii and iv

Correct Choice : 1 From Lectuer # 15 www.vugujranwala.com

71 - Mergesort is a stable algorithm but not an in-place algorithm.

1. TRUE 2. FALSE 3. 4.

Correct Choice : 1 From Lectuer # 16 www.vugujranwala.com

72 - Memorization is?

1. To store previous results for future use 2. To avoid this unnecessary repetitions by writing down the results of recursive

Page 77: CS502 Full Material

calls and looking them up again if we need them later 3. To make the process accurate 4. None of the above

Correct Choice : 2 From Lectuer # 16 www.vugujranwala.com

73 - Dynamic programming algorithms need to store the results of intermediatesub-problems.

1. TRUE 2. FALSE 3. 4.

Correct Choice : 1 From Lectuer # 17 www.vugujranwala.com

74 - Dynamic programming uses a top-down approach.

1. TRUE 2. FALSE 3. 4.

Correct Choice : 2 From Lectuer # 17 www.vugujranwala.com

75 - The edit distance between FOOD and MONEY is

1. At most four 2. At least four 3. Exact four 4. Wrong

Correct Choice : 1 From Lectuer # 17 www.vugujranwala.com

76 - The edit distance between FOOD and MONEY is

1. At most four 2. At least four 3. Exact four 4. Wrong

Correct Choice : 1 From Lectuer # 17 www.vugujranwala.com

77 - If there are O (n^2) entries in edit distance matrix then the total running time is

1. O (1) 2. O (n^2) 3. O (n) 4. O (n log n)

Correct Choice : 2 From Lectuer # 18 www.vugujranwala.com

www.vugujranwala.com

Page 78: CS502 Full Material

79 - A p x q matrix A can be multiplied with a q x r matrix B. The result will be a p x r matrix C. There are (p . r) total entries in C and each takes _________ to compute.

1. O (q) 2. O (1) 3. O (n^2) 4. O (n^3)

Correct Choice : 1 From Lectuer # 19 www.vugujranwala.com

80 - For Chain Matrix Multiplication we can not use divide and conquer approach because,

1. We do not know the optimum k 2. We use divide and conquer for sorting only 3. We can easily perform it in linear time 4. Size of data is not given

Correct Choice : 1 From Lectuer # 19 www.vugujranwala.com

www.vugujranwala.com

82 - A p x q matrix A can be multiplied with a q x r matrix B. The result will be a p x r matrix C. There are (p . r) total entries in C and each takes _________ to compute.

1. O (q) 2. O (1) 3. O (n^2) 4. O (n^3)

Correct Choice : 1 From Lectuer # 19 www.vugujranwala.com

83 - The Knapsack problem belongs to the domain of _______________ problems.

1. Optimization 2. NP Complete 3. Linear Solution 4. Sorting

Correct Choice : 1 From Lectuer # 21 www.vugujranwala.com

84 - Suppose we have three items as shown in the following table, and suppose the capacity of the knapsack is 50 i.e. W = 50. Item Value Weight 1 60 10 2 100 20 3 120 30 The optimal solution is to pick

1. Items 1 and 2 2. Items 1 and 3 3. Items 2 and 3 4. None of these

Page 79: CS502 Full Material

Correct Choice : 4 From Lectuer # 22

Which statement is true?

Select correct option:

Correct Choice : 3 From Lectuer # 21 www.vugujranwala.com

85 - Huffman algorithm uses a greedy approach to generate a postfix code T thatminimizes the expected length B (T) of the encoded string.

1. TRUE 2. FALSE 3. 4.

Correct Choice : 1 From Lectuer # 22 www.vugujranwala.com

86 - The codeword assigned to characters by the Huffman algorithm have the property that nocodeword is the postfix of any other.

1. TRUE 2. FALSE 3. 4.

Correct Choice : 2 From Lectuer # 22 www.vugujranwala.com

87 - The greedy part of the Huffman encoding algorithm is to first find two nodes withlarger frequency.

1. TRUE 2. FALSE 3. 4.

Correct Choice : 2 From Lectuer # 22 www.vugujranwala.com

88 - An optimization problem is one in which you want to find,

1. Not a solution 2. An algorithm 3. Good solution 4. The best solution

Page 80: CS502 Full Material

If a dynamic-programming problem satisfies the optimal-substructure property, then a locally optimal solution is globally optimal.

If a greedy choice property satisfies the optimal-substructure property, then a locally optimal solution is globally optimal.

Both of above

None of above

What general property of the list indicates that the graph has an isolated vertex?

Select correct option:

There is Null pointer at the end of list.

The Isolated vertex is not handled in list.

Only one value is entered in the list.

There is at least one null list.

Using ASCII standard the string “abacdaacacwe” will be encoded with __________ bits

Select correct option:

64

128

96

120

Click here to Save Answer & Move to Next Question

Quiz Start Time: 05:45 PM

Time Left 13

sec(s)

Question # 7 of 10 ( Start time: 05:49:48 PM ) Total Marks: 1

Suppose that a graph G = (V,E) is implemented using adjacency lists. What is the complexity of a breadth-first

Page 81: CS502 Full Material

traversal of G?

Select correct option:

O(|V |^2)

O(|V | |E|)

O(|V |^2|E|)

O(|V | + |E|)

A digraph is strongly connected under what condition? A digraph is strongly connected if for every pair of vertices u, v e V, u can reach v A digraph is strongly connected if for every pair of vertices u, v e V, u can reach v and vice versa. A digraph is strongly connected if for at least one pair of vertex u, v e V, u can reach v and vice versa. A digraph is strongly connected if at least one third pair of vertices u, v e V, u can reach v and vice versa You have an adjacency list for G, what is the time complexity to compute Graph transpose G^T ? E V V+E V.E What algorithm technique is used in the implementation of Kruskal solution for the MST? Greedy Technique What is the time complexity to extract a vertex from the priority queue in Prim’s algorithm? log (V) v.v E.V log (E) Djkistra algorithm: Has greedy approach to find all shortest paths Has both greedy and Dynamic approach to find all shortest paths Has greedy approach to compute single source shortest paths to all other vertices Has both greedy and dynamic approach to compute single source shortest paths to all other vertices.

Top of Form

/wEPDwUKMTY2N

Page 82: CS502 Full Material

/wEWCgK3kf61Bw

Quiz Start Time: 06:56 PM

Time Left 84 sec(s)

Question # 1 of 10 ( Start time: 06:56:28 PM ) Total Marks: 1 What is the time complexity to extract a vertex from the priority queue in Prim’s algorithm?

Select correct option:

log (V)

V.V

E.E

log (E)

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

/wEPDwUKMTY2N

/wEWCgKT24qzA

Quiz Start Time: 06:56 PM

Time Left 86 sec(s)

Question # 2 of 10 ( Start time: 06:56:41 PM ) Total Marks: 1 What algorithm technique is used in the implementation of Kruskal solution for the MST?

Select correct option:

Greedy Technique

Page 83: CS502 Full Material

Divide-and-Conquer Technique

Dynamic Programming Technique

The algorithm combines more than one of the above

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

/wEPDwUKMTY2N

/wEWCgKUwezjA

Quiz Start Time: 06:56 PM

Time Left 85 sec(s)

Question # 3 of 10 ( Start time: 06:56:51 PM ) Total Marks: 1 Which is true statement in the following.

Select correct option:

Kruskal algorithm is multiple source technique for find

Kruskal’s algorithm is used to find minimum spanning t

Both of above

Kruskal's algorithm (choose best non-cycle edge) is b Tree edge) when the graph has relatively few edg

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

Page 84: CS502 Full Material

/wEPDwUKMTY2N

/wEWCgLH3on3D

Quiz Start Time: 06:56 PM

Time Left 85 sec(s)

Question # 4 of 10 ( Start time: 06:57:02 PM ) Total Marks: 1 What is the time complexity to extract a vertex from the priority queue in Prim’s algorithm?

Select correct option:

O (log E)

? (V)

? (V+E)

O (log V)

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

/wEPDwUKMTY2N

/wEWCgKt3MieAw

Quiz Start Time: 06:56 PM

Time Left 87 sec(s)

Question # 5 of 10 ( Start time: 06:57:14 PM ) Total Marks: 1 You have an adjacency list for G, what is the time complexity to compute Graph transpose G^T ?

Select correct option:

(V+E)

Page 85: CS502 Full Material

V.E

V

E

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

/wEPDwUKMTY2N

/wEWCgKP97SuD

Quiz Start Time: 06:56 PM

Time Left 85 sec(s)

Question # 6 of 10 ( Start time: 06:57:26 PM ) Total Marks: 1 A digraph is strongly connected under what condition?

Select correct option:

A digraph is strongly connected if for every pair of v

A digraph is strongly connected if for every pair of v

A digraph is strongly connected if for at least one pa

A digraph is strongly connected if at least one third

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

Page 86: CS502 Full Material

/wEPDwUKMTY2N

/wEWCgLcp5/pAg

Quiz Start Time: 06:56 PM

Time Left 86 sec(s)

Question # 7 of 10 ( Start time: 06:57:37 PM ) Total Marks: 1 The relationship between number of back edges and number of cycles in DFS is,

Select correct option:

Both are equal

Back edges are half of cycles

Back edges are one quarter of cycles

There is no relationship between no. of edges and cy

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

/wEPDwUKMTY2N

/wEWCgKyocSoC

Quiz Start Time: 06:56 PM

Time Left 86 sec(s)

Question # 8 of 10 ( Start time: 06:57:47 PM ) Total Marks: 1 You have an adjacency list for G, what is the time complexity to compute Graph transpose G^T.?

Select correct option:

? (V + E)

Page 87: CS502 Full Material

? (V E)

? (V)

? (V^2)

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

/wEPDwUKMTY2N

/wEWCgLXyo3VC

MC080408597 : Muhammad Asif Quiz Start Time: 06:56 PM

Time Left 39 sec(s)

Question # 9 of 10 ( Start time: 06:57:58 PM ) Total Marks: 1 Dijkstra’s algorithm :

Select correct option:

Has greedy approach to find all shortest paths

Has both greedy and Dynamic approach to find all sh

Has greedy approach to compute single source short

Has both greedy and dynamic approach to compute

Click here to Save Answer & Move to Next Question

Bottom of Form Top of Form

Page 88: CS502 Full Material

/wEPDwUKMTY2N

/wEWCgLqzaeZBw

Quiz Start Time: 06:56 PM

Time Left 85 sec(s)

Question # 10 of 10 ( Start time: 06:58:57 PM ) Total Marks: 1 There is relationship between number of back edges and number of cycles in DFS

Select correct option:

Both are equal.

Cycles are half of back edges.

Cycles are one fourth of back edges.

There is no relationship between back edges and num

Click here to Save Answer & Move to Next Question

Bottom of Form Question No: 1 ( Marks: 1 ) - Please choose one Random access machine or RAM is a/an ► Machine build by Al-Khwarizmi ► Mechanical machine ► Electronics machine ► Mathematical model Question No: 2 ( Marks: 1 ) - Please choose one _______________ is a graphical representation of an algorithm ► Σ notation ► Θ notation ► Flowchart ► Asymptotic notation

Page 89: CS502 Full Material

Question No: 3 ( Marks: 1 ) - Please choose one A RAM is an idealized machine with ______________ random-access memory. ► 256MB ► 512MB ► an infinitely large ► 100GB Question No: 4 ( Marks: 1 ) - Please choose one What type of instructions Random Access Machine (RAM) can execute? Choose best answer ► Algebraic and logic ► Geometric and arithmetic ► Arithmetic and logic ► Parallel and recursive Question No: 5 ( Marks: 1 ) - Please choose one What will be the total number of max comparisons if we run brute-force maxima algorithm with n elements?

► 2n

► 2n

n ► n

► 8n

Question No: 6 ( Marks: 1 ) - Please choose one What is the solution to the recurrence T(n) = T(n/2)+n . ► O(logn) ► O(n) ► O(nlogn) ► O(n2) Question No: 7 ( Marks: 1 ) - Please choose one Consider the following code: For(j=1; j<n;j++) For(k=1; k<15;k++) For(l=5; l<n; l++) { Do_something_constant(); } What is the order of execution for this code. ► O(n) ► O(n3) ► O(n2 log n)

Page 90: CS502 Full Material

► O(n2) Question No: 8 ( Marks: 1 ) - Please choose one Consider the following Algorithm: Factorial (n){ if (n=1) return 1 else return (n * Factorial(n-1))

{ Recurrence for the following algorithm is: ► T(n) = T(n-1) +1 ► T(n) = nT(n-1) +1 ► T(n)= T(n-1) +n ► T(n)=T(n(n-1)) +1 Question No: 9 ( Marks: 1 ) - Please choose one What is the total time to heapify? ► Ο(log n) ► Ο(n log n) ► Ο(n2 log n) ► Ο(log2 n) Question No: 10 ( Marks: 1 ) - Please choose one When we call heapify then at each level the comparison performed takes time ► It will take Θ (1) ► Time will vary according to the nature of input data ► It can not be predicted ► It will take Θ (log n) Question No: 11 ( Marks: 1 ) - Please choose one In Quick sort, we don’t have the control over the sizes of recursive calls ► True ► False ► Less information to decide ► Either true or false Question No: 12 ( Marks: 1 ) - Please choose one Is it possible to sort without making comparisons? ► Yes ► No Question No: 13 ( Marks: 1 ) - Please choose one If there are Θ (n2) entries in edit distance matrix then the total running time is ► Θ (1) ► Θ (n2)

Page 91: CS502 Full Material

► Θ (n) ► Θ (n log n) Question No: 14 ( Marks: 1 ) - Please choose one For Chain Matrix Multiplication we can not use divide and conquer approach because, ► We do not know the optimum k ► We use divide and conquer for sorting only ► We can easily perform it in linear time ► Size of data is not given Question No: 15 ( Marks: 1 ) - Please choose one The Knapsack problem belongs to the domain of _______________ problems. ► Optimization ► NP Complete ► Linear Solution ► Sorting Question No: 16 ( Marks: 1 ) - Please choose one Suppose we have three items as shown in the following table, and suppose the capacity of the knapsack is 50 i.e. W = 50.

Item Value Weight1 60 102 100 203 120 30

The optimal solution is to pick ► Items 1 and 2 ► Items 1 and 3 ► Items 2 and 3 ► None of these

CS502 QUIZ # 2 SOLVED 24 JUNE 2010 7:57 AM | Posted by Guru

In drawing a proper flowchart, all necessary steps that are a part of process should be listed out in ________________ order.

Select correct option:

Logical Page No. 109

Physical

Page 92: CS502 Full Material

Random

Top to Bottom

Which of the following is a problem solving technique that re-assembles a system’s components back into a complete system?

Select correct option:

System analysis

System design Page No. 93

System check

System configuration

The study of business problem domain is used to recommend improvements and specify the business requirements for the solution.

Select correct option:

True Page No. 102

False

Which of the following may be of low fidelity and dismissed as toys?

Select correct option:

Interfaces

Inference engines

Page 93: CS502 Full Material

Early prototypes Page No. 101

Development engines

Which of the following refers to the structuring of hardware and software to achieve the effective and efficient processing of information?

Select correct option:

SDLC

System monitoring

Operational planning

System development Page No. 78

Which of the following allows manufacturers to rapidly and inexpensively test the parts of the design which are most likely to have problems?

Select correct option:

Physical Model

Prototype Page No. 100

Trial version

Carbon copy

Which of the following are knowledge workers who facilitate the development of information systems and computer applications by bridging the communications gap that exists between non-technical system users, and System designers and developers?

Select correct option:

Page 94: CS502 Full Material

System Analysts Page No. 103

Software Engineers

System Designers

Chief Executives

Which of the following provides a structured means of addressing the impact of technologies on an organization?

Select correct option:

Business planning

IT planning Page No. 67

Requirements planning

Configuration planning

Employees might be unwilling to accept the high level of responsibility if organization is dominated by _____________and the culture is ____________.

Select correct option:

Workers, autocratic

top management, autocratic Page No. 87

top management, democratic

Middle level management, democratic

In which of the following environments, duplication of clerical work is generally observed.

Page 95: CS502 Full Material

Question # 1 of 10 ( Start time: 06:18:58 PM ) Total Marks: 1 We do sorting to, Select correct option: keep elements in random positions keep the algorithm run in linear order keep the algorithm run in (log n) order keep elements in increasing or decreasing order Question # 2 of 10 ( Start time: 06:19:38 PM ) Total Marks: 1 Heaps can be stored in arrays without using any pointers; this is due to the ____________ nature of the binary tree, Select correct option: left-complete right-complete tree nodes tree leaves Question # 3 of 10 ( Start time: 06:20:18 PM ) Total Marks: 1 Sieve Technique can be applied to selection problem? Select correct option: True False Question # 4 of 10 ( Start time: 06:21:10 PM ) Total Marks: 1 A heap is a left-complete binary tree that conforms to the ___________

Select correct option:

Computerized

Automated

Manual Page No. 102

Semi-computerized

Page 96: CS502 Full Material

Select correct option: increasing order only decreasing order only heap order (log n) order Question # 5 of 10 ( Start time: 06:21:39 PM ) Total Marks: 1 A (an) _________ is a left-complete binary tree that conforms to the heap order Select correct option: heap binary tree binary search tree array Question # 6 of 10 ( Start time: 06:22:04 PM ) Total Marks: 1 Divide-and-conquer as breaking the problem into a small number of Select correct option: pivot Sieve smaller sub problems Selection Question # 7 of 10 ( Start time: 06:22:40 PM ) Total Marks: 1 In Sieve Technique we do not know which item is of interest Select correct option: True False Question # 8 of 10 ( Start time: 06:23:26 PM ) Total Marks: 1 The recurrence relation of Tower of Hanoi is given below T(n)={1 if n=1 and 2T(n-1) if n >1 In order to move a tower of 5 rings from one peg to another, how many ring moves are required? Select correct option: 16 10

Page 97: CS502 Full Material

32 31 Question # 9 of 10 ( Start time: 06:24:44 PM ) Total Marks: 1 In the analysis of Selection algorithm, we eliminate a constant fraction of the array with each phase; we get the convergent _______________ series in the analysis, Select correct option: linear arithmetic geometric exponent Question # 10 of 10 ( Start time: 06:25:43 PM ) Total Marks: 1 For the heap sort, access to nodes involves simple _______________ operations. Select correct option: arithmetic binary algebraic logarithmic For the sieve technique we solve the problem, Select correct option: recursively mathematically precisely accurately The sieve technique works in ___________ as follows Select correct option: phases numbers integers routines Slow sorting algorithms run in, Select correct option: T(n^2) T(n) T( log n)

Page 98: CS502 Full Material

A (an) _________ is a left-complete binary tree that conforms to the heap order Select correct option: heap binary tree binary search tree array In the analysis of Selection algorithm, we eliminate a constant fraction of the array with each phase; we get the convergent _______________ series in the analysis, Select correct option: linear arithmetic geometric exponent In the analysis of Selection algorithm, we make a number of passes, in fact it could be as many as, Select correct option: T(n) T(n / 2) log n n / 2 + n / 4 The sieve technique is a special case, where the number of sub problems is just Select correct option: 5 many 1 few In which order we can sort? Select correct option: increasing order only decreasing order only increasing order or decreasing order both at the same time The recurrence relation of Tower of Hanoi is given below T(n)={1 if n=1 and 2T(n-1) if n >1 In order to move a tower of 5 rings from one peg to another, how many ring moves are required?

Page 99: CS502 Full Material

Select correct option: 16 10 32 31 Analysis of Selection algorithm ends up with, Select correct option: T(n) T(1 / 1 + n) T(n / 2) T((n / 2) + n) We do sorting to, Select correct option: keep elements in random positions keep the algorithm run in linear order keep the algorithm run in (log n) order keep elements in increasing or decreasing order Divide-and-conquer as breaking the problem into a small number of Select correct option: pivot Sieve smaller sub problems Selection The analysis of Selection algorithm shows the total running time is indeed ________in n, Select correct option: arithmetic geometric linear

Page 100: CS502 Full Material

orthogonal How many elements do we eliminate in each time for the Analysis of Selection algorithm? Select correct option: n / 2 elements (n / 2) + n elements n / 4 elements 2 n elements Sieve Technique can be applied to selection problem? Select correct option: True false For the heap sort we store the tree nodes in Select correct option: level-order traversal in-order traversal pre-order traversal post-order traversal eagle_eye [email protected] CS502 today Quiz attempt by eagle_eye Make your own search before submit your own quiz This answers is just for idea -------------------------------------------------------------------------- Quiz Start Time: 05:49 PM Time Left 84 sec(s)

Page 101: CS502 Full Material

Question # 1 of 10 ( Start time: 05:49:29 PM ) Total Marks: 1 Defining the services of an object means: Select correct option: What it does? What it knows? Who knows it? Whome it knows? -------------------------------------------------------------------------- Quiz Start Time: 05:49 PM Time Left 90 sec(s) Question # 2 of 10 ( Start time: 05:50:56 PM ) Total Marks: 1 Identify the TRUE statement(s) Select correct option: An attribute that may have a number of values should be replaced by a new class and an object connection An attribute that varies over time, e.g., price of an item, should be replaced by an additional class with an effective date and value Replace “yes/no” type attributes with “status” type attributes for flexibility -------------------------------------------------------------------------- Quiz Start Time: 05:49 PM Time Left 79 sec(s) Question # 5 of 10 ( Start time: 05:51:58 PM ) Total Marks: 1 Every object that you put in your object model should have some responsibility or role to play in the problem domain. Select correct option: eagle_eye [email protected] TRUE FALSE -------------------------------------------------------------------------- Quiz Start Time: 05:49 PM Time Left 88 sec(s) Question # 6 of 10 ( Start time: 05:52:55 PM ) Total Marks: 1 Consider the following piece of code: public clas s Square extends Shape { // some code . } The above code is an example of: Select correct option: Part-Whole relationship Generalization/Specialization Data Sharing Data encapsulation --------------------------------------------------------------------------

Page 102: CS502 Full Material

Quiz Start Time: 05:49 PM Time Left 87 sec(s) Question # 7 of 10 ( Start time: 05:53:13 PM ) Total Marks: 1 A structure is a manner of organization which expresses a semantically strong organization within the problem domain. Select correct option: TRUE FALSE -------------------------------------------------------------------------- Quiz Start Time: 05:49 PM Time Left 88 sec(s) Question # 9 of 10 ( Start time: 05:54:10 PM ) Total Marks: 1 "A car is made up of a body, three or four wheels, a steering mechanism, a breaking mechanism, and a power-engine" The above statement is example of: Select correct option: Whole-Part relationship Inheritance eagle_eye [email protected] Specialization Generalization -------------------------------------------------------------------------- Quiz Start Time: 05:49 PM Time Left 88 sec(s) Question # 10 of 10 ( Start time: 05:55:34 PM ) Total Marks: 1 If Dog derives from Mammal, and Mammal derives from Animal, then: Select correct option: Dog inherits Animal's functions and data Dog does not inherit Animal's functions and data Mammal inherits functions and data of both Dog and Animal None of the given options -------------------------------------------------------------------------- Quiz Start Time: 05:57 PM Time Left 89 sec(s) Question # 1 of 10 ( Start time: 05:57:08 PM ) Total Marks: 1 A structure is a manner of an organization which expresses a ________ strong organization within the problem domain. Select correct option: semantically syntactically graphically

Page 103: CS502 Full Material

none of the given -------------------------------------------------------------------------- Quiz Start Time: 05:57 PM Time Left 89 sec(s) Question # 2 of 10 ( Start time: 05:57:48 PM ) Total Marks: 1 eagle_eye [email protected] "A car is made up of a body, three or four wheels, a steering mechanism, a breaking mechanism, and a power-engine" The above statement is example of: Select correct option: Whole-Part relationship Inheritance Specialization Generalization -------------------------------------------------------------------------- Quiz Start Time: 05:57 PM Time Left 88 sec(s) Question # 3 of 10 ( Start time: 05:58:12 PM ) Total Marks: 1 In "Railway ticket reservation system" the roles such as enquiry , reservation and ticketing and cancellation are to be performed by the user called :- Select correct option: Passenger System analyst System developer System designer -------------------------------------------------------------------------- Quiz Start Time: 05:57 PM Time Left 81 sec(s) Question # 4 of 10 ( Start time: 05:59:41 PM ) Total Marks: 1 Every object that you put in your object model should have some responsibility or role to play in the problem domain. Select correct option: TRUE FALSE -------------------------------------------------------------------------- Quiz Start Time: 05:57 PM Time Left 87 sec(s) Question # 5 of 10 ( Start time: 06:00:14 PM ) Total Marks: 1 eagle_eye

Page 104: CS502 Full Material

[email protected] Specialization means: Select correct option: Calling the same method with object of child object Hiding the data Creating new subclasses from an existing class None of given options -------------------------------------------------------------------------- Quiz Start Time: 05:57 PM Time Left 87 sec(s) Question # 7 of 10 ( Start time: 06:01:52 PM ) Total Marks: 1 Ambiguity does not arise if requirements are not specified in clear terms Select correct option: TRUE FALSE -------------------------------------------------------------------------- Quiz Start Time: 06:13 PM Time Left 83 sec(s) Question # 1 of 10 ( Start time: 06:14:00 PM ) Total Marks: 1 While establishing the services for an object, the following fundamental questions should be asked Select correct option: Why does the system need this object any way? What useful questions can it answer? What useful action can it perform? All of the given options -------------------------------------------------------------------------- Quiz Start Time: 06:13 PM Time Left 87 sec(s) eagle_eye [email protected] Question # 3 of 10 ( Start time: 06:16:11 PM ) Total Marks: 1 ________ has become a standard notation for object oriented system modeling. Select correct option: UML C++ OCL (object Constraint Language) None of the given options MC090404410 : Tabish Ali Raza Quiz Start Time: 06:22 PM Time Left 86

Page 105: CS502 Full Material

sec(s) Question # 3 of 10 ( Start time: 06:23:35 PM ) Total Marks: 1 A cohesive Class is one which emphasizes on ____ unit of functionality Select correct option: Single Multiple Static None of the given options -------------------------------------------------------------------------- Quiz Start Time: 06:30 PM Time Left 86 sec(s) Question # 1 of 10 ( Start time: 06:30:30 PM ) Total Marks: 1 ________ analysis educates the analyst on business domain complexity and shows a way to deal with it. Select correct option: Domain Use Case Object Collaboration None of the given options (not sure) eagle_eye [email protected] -------------------------------------------------------------------------- Quiz Start Time: 06:30 PM Time Left 86 sec(s) Question # 7 of 10 ( Start time: 06:32:28 PM ) Total Marks: 1 The key objective(s) of OOD process should achieve the following: Select correct option: The class as far as possible should be Independent , but could be dependent on only a few classes. Interaction between two classes should be explicit. Class hierarchy should be built on specialization of higher class. All of the given options CS 502 In drawing a proper flowchart, all necessary steps that are a part of process should be listed out in ________________ order. Select correct option: Logical Page No. 109 Physical Random Top to Bottom

Page 106: CS502 Full Material

Which of the following is a problem solving technique that re-assembles a system’s components back into a complete system? Select correct option: System analysis System design Page No. 93 System check System configuration The study of business problem domain is used to recommend improvements and specify the business requirements for the solution. Select correct option: True Page No. 102 False Which of the following may be of low fidelity and dismissed as toys? Select correct option: Interfaces Inference engines Early prototypes Page No. 101 Development engines Which of the following refers to the structuring of hardware and software to achieve the effective and efficient processing of information? Select correct option: SDLC System monitoring Operational planning System development Page No. 78 Which of the following allows manufacturers to rapidly and inexpensively test the parts of the design which are most likely to have problems? Select correct option: Physical Model Prototype Page No. 100 Trial version Carbon copy Which of the following are knowledge workers who facilitate the development of information systems and computer applications by bridging the communications gap that exists between non-technical system users, and System designers and developers? Select correct option: System Analysts Page No. 103 Software Engineers System Designers Chief Executives Which of the following provides a structured means of addressing the impact of technologies on an organization?

Page 107: CS502 Full Material

Select correct option: Business planning IT planning Page No. 67 Requirements planning Configuration planning Employees might be unwilling to accept the high level of responsibility if organization is dominated by _____________and the culture is ____________. Select correct option: Workers, autocratic top management, autocratic Page No. 87 top management, democratic Middle level management, democratic In which of the following environments, duplication of clerical work is generally observed. Select correct option: Computerized Automated Manual Page No. 102 Semi-computerized Q 1 Total time for heapify is: ? (log2 n) ? (n log n) ? (n2 log n) ? (log n) Q2:_ If an algorithm has a complexity of log2n + nlog2n + n. we could say that it has complexity 1)O(n) 2)O( n log2 n) 3)O(3) 4)O( log2( log2n )) 5)O ( log2n) Q 4 Due to left-complete nature of binary tree, heaps can be stored in Link list Structure Array None of above Q5 In selection algorithm, because we eliminate a constant fraction of the array with each phase, we get the

Page 108: CS502 Full Material

Convergent geometric series Divergent geometric series None of these Q#6 In RAM model instructions are executed One after another Parallel Concurrent Random Qus 7 Consider the following pairs of functions I . f(x) = x + 3x+7 g(x) = x + 1022

II f(x) = x2log(x) g(x) = x3

III f(x) = x + log(3x +7) g(x) = (x48 2 +17x +3)2

Which of the pairs of functions f and g are asymptotic? ? Only I ? Only II ? Both I and III ? None of the above qus8 Execution of the following code fragment int Idx; for (Idx = 0; Idx < N; Idx++) { cout << A[Idx] << endl; } is best described as being ? O(N) ? O(N2) ? O(log N) ? O(N log N) qus9 If algorithm A has running time 7n2 + 2n + 3 and algorithm B has running time 2n2, then ? Both have same asymptotic time complexity ? A is asymptotically greater ? B is asymptotically greater ? None of others Question No. 10 Which of the following sorting algorithms is stable? (i) Merge sort, (ii) Quick sort, (iii) Heap sort, (iv) Counting Sort. Counting sort and merge sort are stable ? Only i

Page 109: CS502 Full Material

? Only ii ? Both i and ii ? Both iii and iv qus11 Consider the following recurrence relation ? 2 if n = 0 T n( ) =? ? 6 (T n - 1) otherwise Then T(2) is ? 36 ? 72 ? 12 ? None of the above qus12 Let us say we have an algorithm that carries out N2 operations for an input of size N. Let us say that a computer takes 1 microsecond (1/1000000 second) to carry out one operation. How long does the algorithm run for an input of size 3000? ? 90 seconds ? 9 seconds ? 0.9 seconds ? 0.09 seconds qus13 The appropriate big ? classification of the given function. f(n) = 4n2 + 97n + 1000 is ? ? (n) ? ? (2n) ? ? (n2) ? ? (n2 log n) qus14 Consider the following polynomial aknk+ak-1nk-1+………….a0 .

What is the Big –O representation of the above polynomial? ? O(kn) ? O(nk) ? O(nk+1) ? None of the above qus15 Consider the C++ program segment given below: for ( i=0 ; i < n; i++) { for (j = 1,sum=a[0]; j < = i; j++) Sum+=a[j]; Cout<< “The sum for sub-array is<< sum;

Page 110: CS502 Full Material

} The running time of the above algorithm is ? n. ? n log n . ? log n . ? n2. Consider the following pairs of functions I . f(x) = (x3 + x2 + x + 1)4 g(x) = (x4 +x3 + x2+ x + 1)3

II f(x) = 22

x g(x) = 2x 2

III f(x) = 2x + 3 g(x) = 2x + 7

IV f(x) = log(x2 + 1) g(x) = log( x) Which of the pairs of functions f and g are asymptotic? ? Only I ? Only III ? Both I and II ? Both III and IV Question No. 5 Dynamic programming uses a top-down approach. ? True ? False Dynamic Programming uses top down approach with memorization Question No. 6 The edit distance between FOOD and MONEY is ? At most four ? At least four ? Exact four Question No. 7 Consider the following recurrence relation ? 4 if n = 1 T n( ) =? T n + 2

n if n is divisible by 5 ? ( / 5) 3 Then T(5) is ? 25 ? 75 ? 79 ? None of the above Questio Compute the edit distance and edit scripts for the strings “CRICKET” and “HOCKEY”. Question No. 9 Calculate the ? complexity of the following sort procedure sort( A[1..n] ) {

Page 111: CS502 Full Material

for i = 2 to n do for j = n downto i do if( A[j-1] > A[j] ) swap(A[j-1], A[j]) } Question No. 10 Execution of the following code fragment int i = N; while (i > 0) { int Sum = 0; int j; for (j = 0; j < N; j++) Sum++; cout << Sum << end; i--; } is best described as being ? O(N) ? O(N2) ? O(log N) ? O(N log N) Question No. 11 It is impossible to design a sorting algorithm based on comparison of keys whose worstcase run time is in O(n). ? True ? False Question No. 12 Consider the following recurrence relation ? 5 if n = 1 T n( ) =? + if n is even ? 2 ( / 2) 3 Then T(8) is ? 61 ? 29 ? 13 ? None of the above Question No. 13 The merge sort algorithm involves the following steps. (i) Recursively sort the 1st and 2nd halves separately (ii) Merge the two-sorted halves into a sorted group. (iii) If the number of items to sort is 0 or 1, return. Which is the correct order of instructions in merge sort algorithm? ? (i),(ii),(iii) ? (ii),(iii),(i) ? (iii),(ii),(i) ? (iii),(i),(ii) qus14

Page 112: CS502 Full Material

iterfib achieve an exponential speedup over the original recursive algorithm True False In Max Heap, node �i/2��> node i In Min Heap, node �i/2��< node i Edit Distance: The edit distance of two strings, s1 and s2, is defined as the minimum number of changes required to change string s1 into string s2, where a change is one of the following: • Substitute (change) a letter, • Insert a letter or • Delete a letter Knapsack Problem is that, ��We have to fill a bag that can carry maximum weight W ��We have to fill the bag with different items each having a certain weight and value ��We want to fill the bag with these items such that total value of items present in bag is maximum and total weight of items doesn’t increase maximum weight that bag can carry(W). this knapsack problem belongs to the domain of optimization problems An optimization problem is one in which you want to find, not just a solution, but the best solution The problem is called a “0-1” problem, because each item must be entirely accepted or rejected. 1. Simple Sub problems: We should be able to break the original problem to smaller sub problems that have the same structure 2. Principle of Optimality: Recursively define the value of an optimal solution. Express the solution of the original problem in terms of optimal solutions for smaller problems. 3. Bottom-up computation: Compute the value of an optimal solution in a bottom-up fashion by using a table structure. 4. Construction of optimal solution: Construct an optimal solution from computed information. How an optimal solution is constructed for knapsack algorithm Constructing the Optimal Solution The algorithm for computing V[i, j] does not keep record of which subset of items gives

Page 113: CS502 Full Material

the optimal solution. To compute the actual subset, we can add an auxiliary Boolean array keep[i, j] which is 1 if we decide to take the ith item and 0 otherwise. We will use all the values keep[i, j] to determine the optimal subset T of items to put in the knapsack define an optimal value:_ The minimum (or maximum) value of the objective function over the feasible region of an optimization problem. Original recursive algorithm takes theta phi ki power n that is ……………1.618………………. The analysis of Selection algorithm shows the total running time is indeed ________in n (linear) 3. The sieve technique works in ___________ as follows (phases) how to fill the edit distance table??? Fill first row and first column in increasing order as filled in handouts. Now fill the cells with one of these four values (which one is least), If cell is (i,j) where i = row no, and j = column no Then its value will be one of these values, Value of cell (i-1,j) [immediate above cell] + 1 Value of cell (i,j-1) [immediate left cell] +1 Value of cell (i-1,j-1) [left diagonal cell] +1 if characters for that cell do not match Value of cell (i-1,j-1) [left diagonal cell] if characters for that cell match 1) Business model is the part of designing phase of software engineering development life cycle ? True ? False 2) The state transition diagram ? depicts relationships between data objects ? depicts functions that transform the data flow ? indicates how data are transformed by the system ? indicates system reactions to external events 3) The best way to conduct a requirements validation review is to ? Examine the system ? Have the customer look over the requirements ? Send them to the design team ? Use checklist to examine the questions 4) The system specification describes the ? Function, performance and constraints of a computer-based system ? implementation of each allocated system ? time required for simulation ? element software architecture 5) For each of the following given Requirement indicate whether it is Functional (F) or

Page 114: CS502 Full Material

Non- Functional (N) Requirement. [2 marks each] 1. The System should be designed so it can later be extended to a Blue Line reservation System.(N) 2. The System will allow the user to view the layout of seats in Bus.(F) 3. The System must be available at all times.(N) 4. A given seat can be assigned to only one person.(F) 6)Both the software engineer and customer take an active role in software requirements engineering-a set of activities that is often referred to as Requirement_______________ ? Managing ? Recognition ? Analysis ? Modeling _________ is a measure of independence of a module or component. ? Cohesion ? Coupling ? Loop coupling ? Loop cohesion 7) In the Functional design, the structure of the system revolves around __________ ? Functions ? Sequences ? Models ? Flows 8)Use case is the part of designing phase of software engineering ? True ? False 9) Three categories of risks are ? Business, personnel risks, budget risks ? project risks, technical risks, business risks ?planning risks, technical risks, personnel risks ? management risks, technical risks, design risks

Fibonacci sequence 2mark

Clique cover problem 2mark

Page 115: CS502 Full Material

Make Adjacency list from the given table 3marks

Communication design problem (MST).

Strong connected component problem

Heapify proof..... 5marks

Dijkstra Algorithmn

Define Floyd Marshall 5marks

Floyd Marshall 3marks

runtime space used

DFS algoritmn 3marks

Page 116: CS502 Full Material

Filename: algo_mcq_compiled.doc Directory: C:\Users\Memoona\Documents Template:

C:\Users\Memoona\AppData\Roaming\Microsoft\Templates\Normal.dotm

Title: 1 Subject: Author: dcs Keywords: Comments: Creation Date: 8/22/2010 7:06:00 AM Change Number: 29 Last Saved On: 2/20/2011 10:04:00 PM Last Saved By: Memoona Total Editing Time: 225 Minutes Last Printed On: 2/20/2011 10:06:00 PM As of Last Complete Printing Number of Pages: 115 Number of Words: 19,511 (approx.) Number of Characters: 111,218 (approx.)