Design Analysis of Algo MCQS
Design Analysis of Algo MCQS
Design Analysis of Algo MCQS
7. While solving the problem with computer the most difficult step is __________.
A. describing the problem
B. finding out the cost of the software
C. writing the computer instructions
D. testing the solution
Answer:- C
9. The branch of computer that deals with heuristic types of problem is called
_________________.
A. system software
B. real time software
C. artificial intelligence
D. none of these
Answer:- C
23. A large department store has its own charge card. The policy for a customer to
charge an item is that the customer must have a valid charge card and either a
balance of less than Rs.500 or a charge of less than Rs.50.
A. ChargeCard AND (Balance < 500 OR Amount < 50)
B. ChargeCard OR (Balance < 500 AND Amount < 50)
C. ChargeCard OR (Balance < 500 OR Amount < 50)
D. ChargeCard AND (Balance < 500 AND Amount < 50)
Answer:- A
24. Consider the use of PAC for obtaining the solution for converting distance in
Miles to Kilometers. The use of formula �Kilometers = 1.609* Miles� will be in
A. given data section
B. required result section
C. processing required section
D. solution alternative section
Answer:- C
31. The help menus or user manuals are the part of ______________.
A. Program
B. Algorithm
C. Internal Documentation
D. External Documentation
Answer:- D
36. The complexity of three algorithms is given as: O(n), O(n2) and O(n3). Which
should execute slowest for large value of n?
A. O(n)
B. O(n2)
C. O(n3)
D. All will execute in same time.
Answer:-
37. There are four algorithms A1, A2, A3, A4 to solve the given problem with the
order log(n), nlog(n), log(log(n))n/log(n), Which is the best algorithm.
A. A1
B. A2
C. A3
D. A4
Answer:- C
41. In quick sort, the number of partitions into which the file of size n is
divided by a selected record is
a. n
b. n - 1
c. 2
d. n/2
Answer:- C
42. A sort technique is said to be stable when the original relative order of
records with equal keys are retained after sorting.
A. True
B. False
Answer:- A
43. The three factors contributing to the sort efficiency considerations are the
efficiency in coding, machine run time and the space requirement for running the
procedure.
A. True
B. False
Answer:- A
44. How many passes are required to sort a file of size n by bubble sort method?
A. N2
B. N
C. N-1
D. N/2
Answer:- C
45. How many number of comparisons are required in insertion sort to sort a file if
the file is sorted in reverse order?
A. N2
B. N
C. N-1
D. N/2
Answer:- A
46. How many number of comparisons are required in insertion sort to sort a file if
the file is already sorted?
A. N2
B. N
C. N-1
D. N/2
Answer:- C
50. The algorithm like Quick sort does not require extra memory for carrying out
the sorting procedure. This technique is called __________.
A. in-place
B. stable
C. unstable
D. in-partition
Answer:- A
53. The space factor when determining the efficiency of algorithm is measured by
A. Counting the maximum memory needed by the algorithm
B. Counting the minimum memory needed by the algorithm
C. Counting the average memory needed by the algorithm
D. Counting the maximum disk space needed by the algorithm
Answer:- A
54. The time factor when determining the efficiency of algorithm is measured by
A. Counting microseconds
B. Counting the number of key operations
C. Counting the number of statements
D. Counting the kilobytes of algorithm
Answer:- B
55. 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)
B. O (n2 log n)
C. O (n2 + log n)
D. O (n2)
Answer:- A
56. Which of the following case does not exist in complexity theory?
A. Best case
B. Worst case
C. Average case
D. Null case
Answer:- D
58. The recurrence relation capturing the optimal execution time of the Towers of
Hanoi problem with n discs is
A. T(n) = 2T(n - 2) + 2
B. T(n) = 2T(n - 1) + n
C. T(n) = 2T(n/2) + 1
D. T(n) = 2T(n - 1) + 1
Answer:- D
59. Which of the following sorting methods would be most suitable for sorting a
list which is almost sorted?
A. Bubble Sort
B. Insertion Sort
C. Selection Sort
D. Quick Sort
Answer: - B.
60. Suppose we are sorting an array of eight integers using some quadratic sorting
algorithm. After four iterations of the algorithm�s main loop, the array elements
are ordered as shown here:
2 4 5 7 8 1 3 6
A. Insertion sort
B. Selection sort
C. Either of a and b
D. None of the above
Answer: - A.
62. A sort which compares adjacent elements in a list and switches where necessary
is ____.
A. insertion sort
B. heap sort
C. quick sort
D. bubble sort
Answer: - A.
63. The correct order of the efficiency of the following sorting algorithms
according to their overall running time comparison is
A. Insertion>selection>bubble
B. Insertion>bubble>selection
C. Selection>bubble>insertion.
D. bubble>selection>insertion
Answer: - D.
64. A sort which iteratively passes through a list to exchange the first element
with any element less than it and then repeats with a new first element is called
A. insertion sort
B. selection sort
C. heap sort
D. quick sort
Answer: - A.
65. The number of swapping�s needed to sort the numbers 8, 22, 7, 9, 31, 19, 5, 13
in ascending order, using bubble sort is
A. 10
B. 9
C. 13
D. 14
66. The way a card game player arranges his cards as he picks them one by one can
be compared to
A. Quick sort
B. Merge sort
C. Insertion sort
D. Bubble sort
Answer: C
67. Which among the following is the best when the list is already sorted?
A. Insertion sort
B. Bubble sort
C. Merge sort
D. Selection sort
Answer: A
68. As part of the maintenance work, you are entrusted with the work of rearranging
the library books in a shelf in proper order, at the end of each day. The ideal
choice will be
A. Bubble sort
B. Insertion sort
C. Selection sort
D. Merge sort
Answer : B
69. In quick sort, the number of partitions into which the file of size n is
divided by a selected record is
A. n
B. n - 1
C. 2
D. None of the above
Answer:- C.
70. The total number of comparisons made in quick sort for sorting a file of size
n, is
A. O(n log n)
B. O(n2)
C. n(log n)
D. None of the above
Answer:- A.
72. For the improvement of efficiency of quick sort the pivot can be
A. the first element
B. the mean element
C. the last element
D. None of the above
Answer:- B.
76. For sorting a file of size n by straight selection sort, the number of
comparisons made in the first pass is
A. n
B. n - 1
C. n(n - 1)/2
D. None of the above
Answer:- B.
81. Suppose we need to sort a list of employee records in ascending order, using
the social security number (a 9-digit number) as the key (i.e., sort the records by
social security number). If we need to guarantee that the running time will be no
worse than n log n, which sorting methods could we use?
A. mergesort
B. quicksort
C. insertion sort
D. Either mergesort or quicksort
E. None of these sorting algorithms guarantee a worst-case performance of n log n
or better
Answer:- A.
83. The most important reason for including a destructor in a class is:
A. To print a message for debugging purposes
B. To store information about an object before it goes out of scope
C. To free up resources allocated by that class
D. To reset the original object�s pointer to NULL
E. To make your TA happy
Answer:- C.
84. One of these code fragments calls the copy constructor for class A. Which one?
(Assume that doSomething is a void function with a parameter of the appropriate
type.)
A. A a;
B b;
a = b;
B. A array[20];
C. A a;
doSomething(a);
D. A* a;
doSomething(a)
E. A a;
doSomething(&a);
Answer:- C.
85. What is the asymptotic runtime for traversing all nodes in a binary search tree
with n nodes and printing them in order?
A. O(n � log(n))
B. O(n)
C. O( n)
D. O(log(n))
E. O(n^2 )
Answer:- B.
86. Consider a class List that implements an unordered list. Suppose it has as its
representation a dynamically expanding (resizable) array. Which of these operations
might need to delete some dynamically allocated storage to avoid a memory leak?
I. Default Constructor
II. Copy Constructor
III. Destructor
IV. Assignment operator
A. I and II
B. II and III
C. II and IV
D. III and IV
E. II, III, and IV
Answer:- D.
88. Assuming that the hash function for a table works well, and the size of the
hash table is reasonably large compared to the number of items in the table, the
expected (average) time needed to find an item in a hash table containing n items
is
A. O(1)
B. O(log n)
C. O(nlog n)
D. O(n)
E. O( n)
Answer:- A.