# Daa Quiz

10 Questions | Total Attempts: 541  Settings  .

• 1.
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

• 2.
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

• 3.
The worst-case time complexity of Quick Sort is________.
• A.

O(n2)

• B.

O(log n)

• C.

O(n)

• D.

O(n logn)

• 4.
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)

• 5.
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

• 6.
Consider the following function f: int f(int n) { int s = 0; while(n > 1) { n = n/2; s++; } return s; } What is the asymptotic complexity in terms of n?
• A.

O(nlog n)

• B.

O(n)

• C.

O(log n)

• D.

O(n^2 )

• 7.
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

• 8.
The concept of order Big O is important because
• A.

It can be used to decide the best algorithm that solves a given problem

• B.

It determines the maximum size of a problem that can be solved in a given amount of time

• C.

It is the lower bound of the growth rate of algorithm

• D.

Both A and B

• 9.
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

• 10.
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

Related Topics Back to top