0% found this document useful (0 votes)
27 views4 pages

CDS Q3

The document discusses various algorithms for sorting data including bubble sort, merge sort, quick sort, selection sort, insertion sort, and radix sort. It provides examples of how to determine the number of comparisons or swaps needed for each algorithm to sort different sets of data. Some key points made are that merge sort uses a divide and conquer strategy, insertion sort would be most efficient for sorting a small set of items that are already nearly sorted, and quick sort has the worst time complexity of nlog(n).

Uploaded by

Jaydeep S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views4 pages

CDS Q3

The document discusses various algorithms for sorting data including bubble sort, merge sort, quick sort, selection sort, insertion sort, and radix sort. It provides examples of how to determine the number of comparisons or swaps needed for each algorithm to sort different sets of data. Some key points made are that merge sort uses a divide and conquer strategy, insertion sort would be most efficient for sorting a small set of items that are already nearly sorted, and quick sort has the worst time complexity of nlog(n).

Uploaded by

Jaydeep S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ALGORITMS

SORTING (Set: 1)
1. The number of swappings needed to sort the numbers: 8, 22, 7, 9, 31, 19, 5, 13 in ascending
order using bubble sort is—

(a) 11 (b) 12
(c) 13 (d) 14

2. Given 2 sorted list of size ‘m’ and ‘n’ respectively. The no. of comparisons needed in the
worst case by the merge sort algorithm will be—

(a) m × n (b) maximum of m, n


(c) minimum of m, n (d) m + n -1

3. The average successful switch time taken by binary search on a sorted array of 10 items is—

(a) 2.6 (b) 2.7


(c) 2.8 (d) 2.9

4. The average successful search time for sequential search on ‘n’ items is—

(a) n/ 2 (b) (n-1)/ 2


(c) (n+1)/ 2 (d) log (n) +1

5. Sorting is useful for—

(a) report generation (b) minimizing the storage needed


(c) making searching easier and efficient (d) both (a) and (c)

6. Choose the correct statement—

(a) Internal sorting is used if the no. of items to be sorted is very large
(b) External sorting is used if the no. of items to be sorted is very large
1
(c) External sorting needs auxiliary storage
(d) Internal sorting needs auxiliary storage

(a) (ii) and (iii) (b) (i) and (iv)


(c) (ii) only (d) (i) and (iii) only

7. A sorting technique that generates that records with the same primary key occurs in the same
order in the sorted list as in the original unsorted list is said to be—

(a) stable (b) consistent


(c) external (d) linear

8. The way a card game player arranges his cards as he picks them up one by one, is an example
of—

(a) bubble sort (b) selection sort


(c) insertion sort (d) merge sort

9. You want to check whether a given set of items is sorted. Which of the following sorting
methods will be the most efficient if it is already in sorted order?

(a) Bubble sort (b) Selection sort


(c) Insertion sort (d) Merge sort

10. The average no. of comparisons performed by the merge sort algorithm, in merging 2 sorted
lists of length 2 is—

(a) 8/ 3 (b) 8/ 5
(c) 11/ 7 (d) 11/ 6

11. Which of the following sorting methods will be the best if no. of swapping done, is the only
measure of efficiency?

(a) Bubble sort (b) Selection sort


(c) Insertion sort (d) Quick sort
2
12. You are asked to sort 15 randomly generated numbers. One should prefer—

(a) Bubble sort (b) Quick sort


(c) Merge sort (d) Heap sort

13. As part of 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) Heap sort

14. The max. no. of comparisons needed to sort 7 items using radix sort is (assume each item is a
4 digit decimal number)

(a) 280 (b) 40


(c) 47 (d) 38

15. Which of the following algorithm exhibits the unnatural behaviour that, minimum no. of
comparisons are needed if the list to be sorted is in the reverse sorted order and maximum no. of
comparisons are needed if they are already in sorted order?

(a) Heap sort (b) Radix sort


(c) Binary Insertion sort (d) There can’t be any such sorting method

16. Which of the following sorting algorithm has the worst time complexity of nlog(n) ?

(a) Heap sort (b) Quick sort


(c) Insertion sort (d) Selection sort

3
17. Merge sort uses—

(a) divide and conquer strategy (b) backtracking approach


(c) heuristic search (d) greedy approach

18. For merging 2 sorted lists of size m and n into a sorted list of size m + n, we require
comparisons of—

(a) 0(m) (b) 0(n)


(c) 0(m+n) (d) 0(log(m) + log(n))

19. Which of the following design technique is used in the quick sort?

(a) Dynamic programming (b) Backtracking


(c) Divide and conquer (d) Greedy method

You might also like