74 Algorithms
74 Algorithms
Information contained in this book has been obtained by authors, from sources believes to be reliable. However,
neither Nodia nor its authors guarantee the accuracy or completeness of any information herein, and Nodia nor its
authors shall be responsible for any error, omissions, or damages arising out of use of this information. This book
is published with the understanding that Nodia and its authors are supplying information but are not attempting
to render engineering or other professional services.
B-8, Dhanshree Tower Ist, Central Spine, Vidyadhar Nagar, Jaipur 302039
Ph : +91 - 141 - 2101150
www.nodia.co.in
email : [email protected]
YEAR 2001
Q. 1
Q. 2
Consider any array representation of an n element binary heap where the elements
are stored from index 1 to index n of the array. For the element stored at index
i of the array (i # n), the index of the parent is
(B) : i D
(A) i - 1
2
(i + 1)
(C) b i l
(D)
2
2
Q. 3
Q. 4
n
i
.
o
c
i
d
.
a
Let f (n) = n2 log n and g (n) = n (log n) 10 be two positive functions of n . Which of
the following statements is correct ?
(A) f (n) = 0 (g (n)) and g (n) =
Y 0 (f (n)) (B) g (n) = 0 (f (n)) and f (n) =
Y 0 (g (n))
(C) f (n) =
Y 0 (g (n)) and g (n) =
Y 0 (f (n)) (D) f (n) = 0 (g (n)) and g (n) = 0 (f (n))
.
w
o
n
Q. 5
How many undirected graphs (not necessarily connected) can be constructed out
of a given set V = {V1, V2, .......Vn} of n vertices ?
n (n - 1)
(A)
(B) 2n
2
n (n - 1)
(C) n!
(D) 2 2
Q. 6
Q. 7
(C) 3 log 2
(D) 2 log 3
*Maximum Discount*
ALGORITHMS
Q. 8
The minimum number of colours required to colour the vertices of a cycle with n
nodes in such a way that no two adjacent nodes have same colour is.
(A) 2
(B) 3
(C) 4
(D) n - 2 9n C + 2
2
Q. 9
In the worst case, the number of comparisons needed to search a single linked list
of length n for a given element is
(B) n
(A) log n
2
(C) log n2 - 1
(D) n
Q. 10
Q. 11
Q. 12
Q. 13
n
i
.
o
c
.
a
i
d
o
n
.
w
The number of leaf nodes in a rooted tree of n nodes, with each node having 0
or 3 children is :
(n - 1)
(A) n
(B)
3
2
(n - 1)
(2n + 1)
(C)
(D)
2
3
Consider the following algorithm for searching for a given number x in an unsorted
array A [1.....n] having n distinct values :
(1) Choose an i uniformly at random from [1....n]
(2) If A [i] = x then stop else Goto 1;
Assuming that x is present A, What is the expected number of comparisons made
by the algorithm before it terminates ?
(A) n
(B) n - 1
(B) 2n
(D) n
2
.
a
i
d
o
n
n
i
.
o
c
.
w
Q. 14
A weight-balanced tree is a binary tree in which for each node, the number of
nodes in the let sub tree is at least half and at most twice the number of nodes in
the right sub tree. The maximum possible height (number of nodes on the path
from the root to the furthest leaf) of such a tree on n nodes is best described by
which of the following ?
(A) log 2 n
(B) log 43 n
(C) log 3 n
(D) log 23 n
Q. 15
*Maximum Discount*
ALGORITHMS
YEAR 2003
ONE MARK
Q. 16
n
i
.
o
c
.
a
i
d
Q. 17
o
n
.
w
n
i
.
o
c
.
a
The usual Q (n2) implementation of Insertion Sort to sort ab array uses linear
search to identify the position where an element is to be inserted into the already
sorted part of the array. If, instead, we use binary search to identify the position,
the worst case running time will
(A) remain Q (n2)
(B) become Q (n (log n) 2)
(C) become Q (n log n)
(D) become Q (n)
Q. 18
o
n
i
d
.
w
In a heap with n elements with the smallest element at the root, the 7th smallest
element ban be found in time
(A) Q (n log n)
(B) Q (n)
(C) Q (log n)
(D) H (1)
Q. 19
YEAR 2003
TWO MARKS
If all permutation are equally likely, what is the expected number of inversions in
a randomly chosen permutation of 1.....n ?
(A) n (n - 1)/ 2
(B) n (n - 1)/ 4
(C) n (n + 1)/ 4
(D) 2n [log2 n]
*Maximum Discount*
ALGORITHMS
Q. 21
What would be the worst case time complexity of the insertion Sort algorithm, if
the inputs are restricted to permutations of 1....n with at most n inversions?
(A) Q (n2)
(B) Q (n log n)
1.5
(C) Q (n )
(D) Q (n)
Q. 22
The cube root of a natural number n is defined as the largest natural number m
such that m3 # n . The complexity of computing the cube root of n (n is represented
in binary notation) is
(A) O (n) but not O (n0.5)
(B) O (n0.5) but not O (log n ) k ) for any constant k > 0
(C) O (log n) k ) for some constant k > 0 , but not O (loglog n) m) for any constant
m>0
(D) O (loglog n) k ) for some constant k > 0.5 , but not O (loglog n) 0.5)
Q. 23
n
i
.
o
c
.
a
i
d
o
n
.
w
Let G = (V, E) be an undirected graph with a sub-graph G1 = (V1, E1), Weight are
assigned to edges of G as follows
0 if e ! E,
w (e) = )
1 otherwise
Q. 24
.
a
(A) 29
(C) 38
Q. 25
n
i
.
o
c
.
w
o
n
i
d
(B) 31
(D) 41
The following are the starting and ending times of cetivities A, B, C, D, E, F, G and
H respectively in chronological order;"as bs aa ae ds ae es fs be de gs ee fe hs ge hel Here, xs
denotes the starting time and xe denotes the ending time of activity X . W need
to schedule the activities in a set of rooms available to us. An activity can be
scheduled in a room only if the room is reserved for the activity for its entire
duration. What is the minimum number of rooms required?
(A) 3
(B) 4
(C) 5
(D) 6
*Maximum Discount*
Q. 26
ALGORITHMS
n
i
.
o
c
.
a
i
d
o
n
.
w
YEAR 2004
n
i
.
o
c
ONE MARK
Q. 27
Level order traversal of a rooted tree can be done by stating from the root and
performing
(A) preorder traversal
(B) inorder traversal
(C) depth first search
(D) breadth first search
Q. 28
Q. 29
.
w
o
n
i
d
.
a
The tightest lower bound on the number of comparisons, in the worst case, for
comparision-based sorting is of the order of
(A) n
(B) n2
(C) n log n
(D) n log2 n
YEAR 2004
Q. 30
TWO MARKS
*Maximum Discount*
Q. 31
Q. 32
Q. 33
ALGORITHMS
n
i
.
o
c
.
a
i
d
Suppose each set is represented as a linked list with elements in arbitrary order.
Which of the operations among union, intersection, membership, cardinality will
be the slowest?
(A) union only
(B) intersection, membership
(C) membership, cardinality
(D) union, intersection
o
n
.
w
.
a
i
d
o
n
n
i
.
o
c
In what order do the nodes get included into the set of vertices ofr which the
shortest path distances are finalized?
(A) P, Q, R, S, T, U
(B) P, Q, R, U, S, T
(C) P, Q, R, U, T, S
(D) P, Q, T, R, U, S
Q. 34
.
w
*Maximum Discount*
Q. 35
Q. 36
Q. 37
ALGORITHMS
n
i
.
o
c
.
a
i
d
o
n
.
w
A program takes as input a balanced binary search tree with n leaf modes and
computes the value of a function g (x) for each node x . If the cost of computing
g (x) is min (number of leaf-nodes in lear-subtree of x , number of leaf-nodes in
right-subtree of x) then the worst case time complexity of the program is
(A) q (n)
(B) O (n log n)
2
(C) O (n)
(D) O (2n)
n
i
.
o
c
YEAR 2005
Q. 38
Q. 39
.
a
.
w
o
n
i
d
YEAR 2005
Q. 40
ONE MARK
TWO MARKS
*Maximum Discount*
ALGORITHMS
Q. 41
How many distinct binary search trees can be created out of 4 distinct keys?
(A) 5
(B) 14
(C) 24
(D) 35
Q. 42
In a complete k-ary, every internal node has exactly k children. The number of
leaves in such a tree with n internal nodes is
(A) n k
(B) (n - 1) k + 1
(C) n (k - 1) + 1
(D) n (k - 1)
Q. 43
Q. 44
Let G (V, E) an undirected graph with positive edge weights. Dijkstras single
source-shortes path algorithm can be implemented using the binary heap data
structure with time complexity?
(A) O (| V | 2)
(B) O (| E |) +| V | log | V |)
(C) O (| V | log | V |)
(D) O ((| E |+| V |) log | V |)
Q. 45
n
i
.
o
c
.
a
i
d
o
n
.
w
Suppose there are log n sorted lists of n/ log n elements each. The time complexity
of producing a sorted list of all these elements is: (Hint: Use a heap data structure)
(A) O (n loglogn)
(B) q (n log n)
(C) W (n log n)
(D) W (n3/2)
n
i
.
o
c
.
a
.
w
o
n
i
d
Q. 46
Q. 47
The space complexity of the above function is foo O and store the values of foo
(i), 0 <= i < n, as and when they are computed. With this modification, the time
complexity for function fooO is significantly reduced. The space complexity of the
modified function would be:
(A) O (1)
(B) O (n)
2
(C) O (n )
(D) O (n!)
*Maximum Discount*
ALGORITHMS
n
i
.
o
c
Task
T1
T2
T3
T4
T5
T6
T7
T8
T9
Profit
15
20
30
18
18
10
23
16
25
Deadline
.
a
i
d
Q. 48
Are all tasks completed in the schedule that gives maximum profit?
(A) All tasks are completed
(B) T1 and T6 are left out
(C) T1 and T8 are left out
(D) T4 and T6 are left out
Q. 49
o
n
.
w
(B) 165
(D) 175
YEAR 2006
Q. 50
Q. 51
ONE MARK
n
i
.
o
c
In a binary max heap containing n numbers, the smallest element can be found
in time
(A) q (n)
(B) q (log n)
(C) q (log log n)
(D) q (1)
o
n
i
d
.
a
Q. 52
Consider a weighted complete graph G on the vertex set {v1, v2,....... vn} such that
the weight of the edge (vi, vj ) is 2 | i - j |. The weight of a minimum spanning tree
of G is
(A) n - 1
(B) 2n - 2
(C) b n l
(D)
2
Q. 53
Q. 54
.
w
*Maximum Discount*
ALGORITHMS
Q. 55
Which one the following in place sorting algorithms needs the minimum number
of swaps?
(A) Quick-sort
(B) Insertion sort
(C) Selection sort
(D) Heap sort
Q. 56
Q. 57
n
i
.
o
c
.
a
i
d
o
n
.
w
YEAR 2006
Q. 58
TWO MARKS
n
i
.
o
c
.
w
o
n
i
d
.
a
Which one of the following cannot be the sequence of edges added, in that order,
to a minimum spanning tree using Kruskals algorithm?
(A) (a - b),( d - f),( b - f).( d - c),( d - e)
(B) (a - b),( d - f),( b - c),( b - f),( d - e)
(C) (d - f),( a - b),( d - c),( d - e),( d - e)
(D) (d - f),( a - b),( b - f),( d - e),( d - e)
Q. 59
Let T be a depth first search tree in a undirected graph G Vertices u and v are
leaves of this tree T . The degrees of both u and v in G are at least 2. Which one
of the following statements is true?
(A) There must exist a vertex w adjacent to both u and v in G
(B) There must exist a vertex w whose removal disconnects u and v in G
(C) There must be exist a cycle in G containing u and v
(D) There must exist a cycle in G containing u and all its neighbours in G
*Maximum Discount*
Q. 60
ALGORITHMS
Q. 61
n
i
.
o
c
.
a
i
d
o
n
.
w
(C) T (n) = q ( n )
Q. 62
Q. 63
The median of n elements can be found in O (n) time. Which one of the following
is correct about the complexity of quick sort, in which remains is selected as
pivot?
(B) q (n log n)
(A) q (n)
2
(C) q (n )
(D) q (n3)
n
i
.
o
c
.
a
Given two arrays of numbers a1 .......an and b1,..... bn where each number is 0 or 1,
the fastest algorithm to find the largest span (i, j) such that
ai + + ai + 1 + ...... + aj = bi + bi + 1 + ...... + bj , or report that there is no such span,
(A) Takes O (3n) and W(2n) time if hashing is permitted
(B) Takes O (n3) and W (n2.5) time in the key comparison model
(C) Takes Q (n) time and space
.
w
o
n
i
d
(D) Takes O ( n ) time only if the sum of the 2n elements is an even number
Q. 64
Consider the following code written in a pass-by reference language like FORTAN
and these statements about the code.
Subroutine swap (ix,iy)
it=ix
L1 :
ix=iy
L2 :
iy=it
end
ia=3
ib=8
call swap (ia,ib+5)
print*,ia,ib
end
S1: The complier will generate code to allocate a temporary nameless cell,
initialize it to 13, and pass the address of the cell to swap
S2: On execution the code will generate a runtime error on line 1.1
*Maximum Discount*
ALGORITHMS
S3: On execution the code will generate a runtime error on line 1.2
S4: The program will print 13 and 8
S5: The program will print 13 and-2
Exactly the following set of statement (s) is correct:
(A) S1 andS2
(B) S1 and S4
(C) S3
(D) S1 amd S5
.
a
YEAR 2007
Q. 65
Q. 66
Q. 67
n
i
.
o
c
i
d
The height of a binary tree is the maximum number of edges in any root to leaf
path. The maximum number of nodes is a binary tree of height h is
(A) 2h
(B) 2h - 1 - 1
(C)2h + 1 - 1
(D) 2h + 1
o
n
.
w
The maximum number of binary trees that can be formed with three unlabeled
nodes is
(A) 1
(B) 5
(C) 4
(D) 3
Which of the following sorting algorithms has the lowest worst-case complexity?
(A) Merge sort
(B) Bubble sort
(C) Quick sort
(D) Selection sort
YEAR 2007
Q. 68
Q. 69
ONE MARK
n
i
.
o
c
.
a
TWO MARKS
.
w
o
n
i
d
Consider the hash table of size seven, with starting index zero, and a has function
(3x + 4) and 7. Assuming the has table is initially empty, which of the following
is the contents of the table when the sequence 1,3,8,10 is inserted into the table
using closed hashing?
Note that-denotes an empty location in the table
(A) 8,-,-,-,-,-,-,10
(B) 1,8,10,-,-,-,-,3
(C)1,-,-,-,-,-,-,,3
(D) 1,10,8,-,-,-,3
Q. 70
Q. 71
A complete n-ary tree is a tree in which each node has n children or no children.
Let I be the number of internal nodes and L be the number of leaves in a
complete n-ary tree. If L= 41, and I =10, what is the value of n
(A) 3
(B) 4
(C) 5
(D) 6
*Maximum Discount*
Q. 72
ALGORITHMS
o
n
Q. 75
n
i
.
o
c
Consider the process of inserting an element into a Max Heap, where the Max
Heap is represented by an array. Suppose we perform a binary search on the path
from the new leaf to the root to find the position for the newly inserted element,
the number of comparisons performed is
(A) q (log2 n)
(B) q (log2 log2 n)
(C) qn
(D) q (n log2 n)
.
w
o
n
i
d
.
a
Let w be the minimum weight among all edge weights in an undirected connected
graph, Let e be a specific edge of weight w. Which of the following is FALSE ?
(A) There is a minimum spanning tree containing e.
(B) If e is not in a minimum spanning tree T ,then in the cycle formed by
adding e to T , all edges have the same weight.
(C) Every minimum spanning tree has an edge of weight w
(D) e is present in every minimum spanning tree
Q. 76
.
w
Q. 74
.
a
i
d
(D) Q ( n )
Q. 73
n
i
.
o
c
*Maximum Discount*
Q. 77
ALGORITHMS
n
i
.
o
c
.
a
i
d
o
n
.
w
Q. 78
Q. 79
Q. 81
.
a
i
d
o
n
.
w
YEAR 2008
Q. 80
n
i
.
o
c
ONE MARK
The most efficient algorithm for finding the number of connected components in
an undirected graph on n vertices and m edges has time complexity.
(A) Q (n)
(B) Q (m)
(C) Q (m + n)
(D) Q (mn)
The Breadth First Search algorithm has been implemented using the queue data
structure. One possible order of visiting the nodes of the following graph is
(A) MNOPQR
(C) QMNPRO
(B) NQMPOR
(D) QMNPOR
*Maximum Discount*
ALGORITHMS
YEAR 2008
Q. 82
TWO MARKS
n
i
.
o
c
.
a
i
d
o
n
.
w
Q. 83
Q. 84
Q. 85
Q. 86
Q. 87
n
i
.
o
c
.
w
o
n
i
d
.
a
*Maximum Discount*
Q. 88
ALGORITHMS
Dijkstras single source shortest path algorithm when run from vertex a in the
above graph, computes the corrects shortest path distance to
o
n
.
w
You are given the postorder traversal, P of a binary search tree on the n elements
1,2,.....,n . You have to determine the unique binary search tree that has P as its
postorder traversal. What is the time complexity of the most efficient algorithm
for doing this?
(A) Q (log n)
(B) Q (n)
(C) Q (n log n)
(D) none of the above, as the tree cannot be uniquely determined.
Q. 90
.
a
i
d
n
i
.
o
c
n
i
.
o
c
We have a binary heap on n elements and wish to insert n more elements (not
necessarily one after another) into this heap. The total time required for this is
(A) Q (log n)
(B) Q (n)
(C) Q (n log n)
(D) Q (n2)
o
n
i
d
.
a
.
w
*Maximum Discount*
ALGORITHMS
Q. 91
Q. 92
n
i
.
o
c
.
a
i
d
o
n
.
w
Q. 93
n
i
.
o
c
.
a
Which entry of the array X , if TRUE, implies that there is a subset whose
elements sum to W?
(A) X [1, W]
(B) X [n, 0]
Q. 94
(C) X [n, W]
.
w
o
n
i
d
(D) X [n - 1, n]
*Maximum Discount*
ALGORITHMS
Q. 95
Q. 96
Q. 98
Q. 99
i
d
.
w
ONE MARK
What is the number of swaps required to sort n elements using selection sort, in
the worst case ?
(A) q (n)
(B) q (n log n)
2
(C) q (n )
(D) q (n2 log n)
n
i
.
o
c
i
d
.
a
Let pA be a problem that belongs to the class NP. Then which one of the following
is TRUE ?
(A) There is no polynomial time algorithm for pA
(B) If pA can be solved deterministically in polynomial time, thenP = NP
(C) If pA is NP-hard, then it is NP-complete
(D) pA may be undecidable
YEAR 2009
Q. 100
.
a
o
n
YEAR 2009
Q. 97
n
i
.
o
c
.
w
o
n
TWO MARKS
*Maximum Discount*
Q. 101
ALGORITHMS
The keys 12, 18, 13, 2, 3, 23, 5 and 15 are inserted into an initially empty hash
table of length 10 using open addressing with hash function h (k) = k mod 10 and
linear probing. What is the resultant hash table ?
(A)
(B)
n
i
.
o
c
23
.
a
i
d
4
5
6
15
.
w
7
8
18
(C)
Q. 102
o
n
12
13
4
5
6
7
8
18
9
(D)
12
13
23
18
15
12, 2
13, 3, 23
n
i
.
o
c
4
.
w
o
n
i
d
.
a
5
6
7
8
9
Which one of the following is NOT the sequence of edges added to the minimum
spanning tree using Kruskals algorithm ?
(A) (b, e) (e, f) (a, c) (b, c) (f, g) (c, d)
(B) (b, e) (e, f) (a, c) (f, g) (b, c) (c, d)
(C) (b, e) (a, c) (e, f) (b, c) (f, g) (c, d)
(D) (b, e) (e, f) (b, c) (a, c) (f, g) (c, d)
*Maximum Discount*
Q. 103
ALGORITHMS
In quick sort, for sorting n elements, the (n/4th) smallest element is selected as
pivot using an O (n) time algorithm. What is the worst case time complexity of
the quick sort ?
(A) q (n)
(B) q (n log n)
(C) q (n2)
(D) q (n2 log n)
n
i
.
o
c
.
a
A sub-sequence of a given sequence is just the given sequence with some elements
(possibly none of all) left out. We are given two sequence X [m] and Y [n] of length
m and n , respectively, with indexes of X and Y starting from 0.
Q. 104
Q. 105
i
d
o
n
We wish to find the length of the longest common sub-sequence (LCS) of x [m]
and Y [n] of lengths m and n , where an incomplete recursive definition for the
function l (i, j) to compute the length of the LCS of X [m] and Y [n] is given below :
l (i, j) =0, if either i = 0 or j = 0
=expr1, if i , j > 0 and x [i - 1] = Y [j - 1]
=expr2, if i , j > 0 and x [i - 1] =
Y Y [j - 1]
Which one of the following options is correct ?
(A) expr 1/ l (i - 1, j) + 1
(B) expr 1/ l (i, j - 1)
(C) expr 2/ max (l (i - 1, j), l (i, j - 1))
(D) expr 2/ max (l (i - 1, j - 1), l (i, j))
.
w
n
i
.
o
c
.
w
o
n
i
d
.
a
YEAR 2010
Q. 106
ONE MARK
Two alternative package Aand B are available for processing a database having
10k records. Package A requires 0.0001 n2 time units and package B requires 10
n log 10 n time units to process n records. What is the smallest value of k for which
package B will be preferred over A ?
(A) 12
(B) 10
(C) 6
(D) 5
*Maximum Discount*
ALGORITHMS
YEAR 2010
Q. 107
TWO MARKS
.
a
i
d
o
n
Q. 108
Q. 109
Consider a complete undirected graph with vertex set {0, 1, 2, 3, 4}. Entry Wij in
the matrix W below is the weight of the edge {i, j} .
J0 1 8 1 4N
K
O
K1 0 12 4 9O
W = K8 12 0 7 3O
K
O
K1 4 7 0 2O
K4 9 3 2 0O
L
P
What is the minimum possible weight of a spanning tree T in this graph such that
vertex 0 is a leaf node in the tree T ?
(A) 7
(B) 8
(C) 9
(D) 10
.
w
n
i
.
o
c
Q. 110
n
i
.
o
c
i
d
o
n
.
w
.
a
ONE MARK
1 + Li + 1 IfA 6i @ < A 6i + 1@
Li = *
1
Otherwise
Finally the length of the longest monotonically increasing sequence is
max ^L 0, L1, ..., Ln + 1h. Which of the following statements is TRUE?
(A) The algorithm uses dynamic programming paradigm
(B) The algorithm has a linear complexity and uses branch and bound
paradigm
(C) The algorithm has a non-linear polynomial complexity and uses branch and
bound paradigm
(D) The algorithm uses divide and conquer paradigm
*Maximum Discount*
ALGORITHMS
YEAR 2011
Q. 111
Q. 112
TWO MARKS
We are given a set of n distinct elements and an unlabeled binary tree with n
nodes. In how many ways can we populate the tree with the given set so that it
becomes a binary search tree?
(A) 0
(B) 1
(C) n!
(D) 1 .2nCn
n+1
n
i
.
o
c
.
a
i
d
o
n
.
w
An undirected graph G ^V, E h contains n ^n > 2h nodes named v1, v2, ..., vn . Two nodes vi ,
v j are connected if an only if 0 < i - j # 2 . Each edge ^vi, v j h is assigned a weight i + j .
A sample graph with n = 4 is shown below.
Q. 113
What will be the cost of the Minimum Spanning Tree (MST) of such a graph
with n nodes?
(B) n2 - n + 1
(A) 1 ^11n2 - 5n h
12
.
w
(C) 6n - 11
Q. 114
.
a
i
d
o
n
n
i
.
o
c
(D) 2n + 1
The length of the path from v5 to v 6 in the MST of previous question with n = 10
is
(A) 11
(B) 25
(C) 31
(D) 41
YEAR 2012
Q. 115
ONE MARK
The Worst case running time to search for an element in a balanced binary search
tree with n2n element is
(A) Q ^n log n h
(B) Q ^n2n h
(C) Q ^n h
(D) Q ^log n h
*Maximum Discount*
Q. 116
ALGORITHMS
Let W ^n h and A ^n h denote respectively, the worst case and average case running
time of an algorithm executed on an input of zise n . Which of the following is
ALWAYS TRUE?
(A) A ^n h = W ^W ^n hh
(B) A ^n h = Q ^W ^n hh
(C) A ^n h = O ^W ^n hh
(D) A ^n h = o ^W ^n hh
YEAR 2012
n
i
.
o
c
Q. 117
Q. 118
Q. 119
.
a
TWO MARKS
Let G be a weighted graph with edge weights greater than one and Gl be the
graph constructed by squaring the weights of edge in G . Let T and Tl be the
minimum spanning trees of G and Gl respectively, with total weights t and tl.
Which of the following statements is TRUE?
(A) Tl = T with total weight tl = t 2
(B) Tl = T with total weight tl < t 2
(C) Tl =
(D) None of the above
Y T but total weight tl = t 2
i
d
o
n
.
w
A list of n strings, each of length n , is sorted into lexicographic order using the
merge sort algorithm. The worst case running time of this computation is
(A) O ^n log n h
(B) O ^n2 log n h
(C) O ^n2 + log n h
(D) O ^n2h
Consider the directed graph shown in the figure below. There are multiple shortest
paths between vertices S and T . Which one will be reported by Dijkstras shortest
path algorithm? Assume that, in any iteration, the shortest path to a vertex v is
updated only when a strictly shorter path to v is discovered.
(A) SDT
(C) SACDT
.
w
.
a
i
d
o
n
n
i
.
o
c
(B) SVDT
(D) SACET
**********
*Maximum Discount*
ALGORITHMS
ANSWER KEY
Algorithms
1
10
(A)
(D)
(A)
(C)
(B)
(A)
(C)
(B)
(B)
(B)
11
12
13
14
15
16
17
18
19
20
(D)
(D)
(C)
(C)
(B)
(D)
(D)
(B)
(C)
(D)
21
22
23
24
25
26
27
28
29
30
(A)
(A)
(C)
(D)
(D)
(B)
(B)
(B)
(A)
31
32
33
34
35
36
37
38
39
40
(C)
(B)
(D)
(A)
(A)
(A)
(B)
(C)
(B)
(D)
41
42
43
44
45
i
d
(C)
46
47
48
49
50
(C)
(C)
(D)
(A)
(D)
(A)
(C)
(C)
(A)
(C)
51
52
53
54
55
56
57
58
59
60
(B)
(A)
(A)
(B)
(D)
(C)
(A)
(D)
(A)
(D)
61
62
63
65
66
67
68
69
70
(B)
(C)
(A)
(C)
(C)
(D)
(B)
(A)
(D)
71
72
74
75
76
77
78
79
80
(B)
(D)
(D)
(C)
(B)
(B)
(B)
(C)
(B)
(C)
(C)
81
82
83
84
85
86
87
88
89
90
(A)
(A)
(B)
(C)
(A)
(C)
(D)
(B)
(C)
(B)
91
92
93
94
95
96
97
98
99
100
(C)
(*)
(D)
(B)
(A)
(B)
(C)
(B)
(C)
(C)
101
102
103
104
105
106
107
108
109
110
(C)
(D)
(B)
(D)
()
()
()
()
()
()
111
112
113
114
115
117
118
119
()
()
()
()
()
()
()
73
o
n
.
w
64
.
a
116
()
n
i
.
o
c
.
a
i
d
o
n
.
w
()
n
i
.
o
c
*Maximum Discount*