CS2251 – DESIGN AND ANALYSIS OF ALGORITHMS. UNIT I ALGORITHM
ANALYSIS. Algorithm analysis – Time space tradeoff – Asymptotic notations ...
QUESTION BANK Dr. NAVALAR NEDUNCHEZHIYAN COLLEGE OF ENGINEERING
II - CSE
THOLUDUR – 606 303, CUDDALORE DIST DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING ANNA UNIVERSITY CHENNAI YEAR: II / SEM IV CS2251 – DESIGN AND ANALYSIS OF ALGORITHMS UNIT I ALGORITHM ANALYSIS Algorithm analysis – Time space tradeoff – Asymptotic notations – Conditional asymptotic notation – Removing condition from the conditional asymptotic notation – Properties of Big-oh notation – Recurrence equations – Solving recurrence equations– Analysis of linear search. UNIT II DIVIDE AND CONQUER, GREEDY METHOD
9
Divide and conquer – General method – Binary search – Finding maximum and minimum – Merge sort – Greedy algorithms – General method – Container loading –Knapsack problem. UNIT III DYNAMIC PROGRAMMING
9
Dynamic programming – General method – Multistage graphs – All-pair shortest paths – Optimal binary search trees – 0/1 Knapsack – Traveling salesperson problem. UNIT IV BACKTRACKING
9
Backtracking – General method – 8 Queens problem – Sum of subsets – Graph coloring – Hamiltonian problem – Knapsack problem. UNIT V TRAVERSALS, BRANCH AND BOUND
9
Graph traversals – Connected components – Spanning trees – Biconnected components – Branch and Bound – General methods (FIFO and LC) – 0/1 Knapsack problem – Introduction to NP-hard and NP-completeness. L: 45 T: 15 Total: 60 TEXT BOOKS 1. Ellis Horowitz, Sartaj Sahni and Sanguthevar Rajasekaran, “Computer Algorithms / C++”, 2nd Edition, Universities Press, 2007. 2. Easwarakumar, K.S., “Object Oriented Data Structures Using C++”, Vikas Publishing House, 2000. REFERENCES 1. Cormen, T.H., Leiserson, C.E., Rivest, R.L. and Stein, C., “Introduction to Algorithms”, 2nd Edition, Prentice Hall of India Pvt. Ltd, 2003. 2. Aho, A.V., Hopcroft J.E. and Ullman, J.D., “The Design and Analysis of Computer Algorithms”, Pearson Education, 1999. 3. Sara Baase and Allen Van Gelder, “Computer Algorithms, Introduction to Design and Analysis”, 3rd Edition, Pearson Education, 2009.
Mrs.J.VANITHA ASST.PROFESSOR/CSE
QUESTION BANK
II - CSE
CS2251-Design and Analysis of Algorithms UNIT-I
(Algorithm Analysis) PART-A
(1 MARKS)
1. What is the correct value to return to the operating system upon the successful completion of a program? a. -1 b. 1 c. 0 d. Programs do not return a value. 2. What is the only function all C++ programs must contain? a. start() b. system() c. main() d. program() 3. What punctuation is used to signal the beginning and end of code blocks? a. { } b. -> and = n0. What is L'Hopital's rule? lim n->oo
t(n) --------
lim t'(n) =
n->oo -------g(n)
g'(n)
PART-C
(16 MARKS)
40.Explain in detail the algorithm design and analysis process.( A.U.NOV’07) (A.U.NOV/MAY’10) 41.Explain in detail the important problem types. 42.Explain in detail the fundamental data structures.( A.U.NOV’06) 43.Write Euclid's algorithm and explain the steps.( A.U.APR’07) 44.Write sieve of Eratosthenes algorithm which generates consecutive primes and explain. 45.Explain in detail the general framework for analyzing an algorithm's efficiency. ( A.U.NOV’08) 46.Explain with examples the worst-case, best-case and the average case efficiencies. (A.U.NOV/MAY’10) (A.U.NOV/MAY’11) 47.What are asymptotic notations? Define and explain the three notations used by computer scientists for analyzing the efficiency of algorithms. (A.U.NOV/MAY’12) 48.What are basic efficiency classes? Explain in detail.( A.U.NOV’09) 49.What is Order of growth? Plot the order of growth for different functions.
UNIT-II (Divide and Conquer Greedy Method) PART-A
(1 MARKS)
50. Streams are Mrs.J.VANITHA ASST.PROFESSOR/CSE
QUESTION BANK II - CSE a. Abstraction to perform input and output operations in sequential media b. Abstraction to perform input and output operations in direct access media c. Objects where a program can either insert or extract characters to and from it 51 Which of the following is known as insertion operator? a. ^ b. Vc. > 52Regarding the use of new line character (/n) and endl manipulator with cout statement a. Both ways are exactly same b. Both are similar but endl additionally performs flushing of buffer c. endl can’t be used with cout d. \n can’t be used with cout 53. Which of the following is output statement in C++? a. print b. Write c. Cout d. Cin 54. Which of the following is input statement in C++? a. cin b. Input c. Get d. none of above 55. By default, the standard output device for C++ programs is a. Printer b. Monitor c. Modem d. Disk 56. By default, the standard input device for C++ program is a. Keyboard b. Mouse c. Scanner d. None of these 57. Which of the following statement is true regarding cin statement? a. cin statement must contain a variable preceded by >> operator b. cin does not process the input until user presses RETURN key c. you can use more than one datum input from user by using cind. all of above 58. Which of the following is extraction operator in C++? a. ^ b. Vc. > 59. When requesting multiple datum, user must separate each by using a. a space b. a tab character c. a new line character d. all of above 60. Cin extraction stops execution as soon as it finds any blank space character a. true b. false 61. Observe the following statements and decide what do they do. string mystring; getline(cin, mystring); a. reads a line of string from cin into mystring b. reads a line of string from mystring into cin c. cin can’t be used this way d. none of above 62. Regarding stringstream identify the invalid statement a. stringstream is defined in the header file b. It allows string based objects treated as stream c. It is especially useful to convert strings to numerical values and vice versa. d. None of above 63. hich of the header file must be included to use stringstream? a. b. c. d. 64. Which of the following header file does not exist? a. b. c. d. 65. If you use same variable for two getline statements a. Both the inputs are stored in that variable b. The second input overwrites the first one c. The second input attempt fails since the variable already got its value d. You can not use same variable for two getline statements 66. The “return 0;” statement in main function indicates a. The program did nothing; completed 0 tasks b. The program worked as expected without any errors during its execution c. not to end the program yet.d. None of above 67. Which of the following is not a reserve keyword in C++? a. mutable b. Default c. Readable d. volatile 68. The size of following variable is not 4 bytes in 32 bit systems a. int b. long int c. short int d. float 69. Identify the correct statement regarding scope of variables a. Global variables are declared in a separate file and accessible from any program . b. Local variables are declared inside a function and accessible within the function only. c. Global variables are declared inside a function and accessible d. Local variables are declared in the main body of the program Answers Mrs.J.VANITHA ASST.PROFESSOR/CSE
QUESTION BANK
II - CSE
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
c
c
b
c
a
b
a
d
d
d
a
a
d
d
c
b
b
c
c
b
PART-B
(2 MARKS)
70.What are recurrence relations? Consider the function M(n) = M(n-1) + 1 Here the equation defines M(n) not explicitly ,i.e. as a function of nabob implicitly as a function of its value at another point, namely n-1. Such equations are called recurrence relations or recurrences. 71.What is the method of backward substitution?( A.U.MAY’10) Among several techniques available for solving recurrence relations, one of the method used is called the method of backward substitution. The method's idea will be clear by referring to the particular case as shown below : M(n) = M(n-1) + 1 for n > 0. M(0) = 0 = [M(n-2) + 1] + 1 = M(n-2) + 2 = [M(n-3) +1] + 2 = M(n-3) + 3 72.Write an algorithm for element uniqueness problem. ALGORITHM Unique Elements(A[0..n-1]) for I
139
140
141
142
140
143
144
145
146
147
148
149
150
151
152
153
154
155
156
a
b
a
d
c
a
a
d
d
c
b
c
a
c
b
d
c
d
b
b
PART-B
(2 MARKS)
157.Define P,NP