Latest News
|
|
UNIT 6
TOPICS TO BE COVERED IN THIS UNIT:
- Searching - Linear and binary search methods
- Bubble sort
- Selection sort
- Insertion sort
- Quick sort
- Merge sort
TEACHING MATERIAL
Unit 6 Teaching Aids - Click Here
TUTORIAL MATERIAL
Tutorial-1
- Write algorithm for binary search using recursive function..
-
The concept of order (Big O) is important because
- it can be used to decide the best algorithm that solves a given
problem.
- It determines the minimum size of a problem that can be solved
in a given system, in a given amount of time
- It is the lower bound of the growth rate of the algorithm
- It is the average bound of the growth rate of the algorithm
-
The average time complexity of insertion sort is
- O(n2)
- O(n)
- O(1)
- O(log n)
-
If n=16, then the value of O(n log n) is
- 16
- 32
- 64
- 128
-
Which of the following sorting algorithms does not have a worst case running time complexity of O(n2)?
- Insertion sort
- Merge sort
- Quick sort
- Bubble sort
-
What are the advantages in insertion sort than bubble sort.
-
There are 3 different algorithms A1,A2,A3 to solve a given problem with the
order log(n), log(log(n)) ,n*log(n) respectively. Which is the best algorithm?
- A1
- A2
- A3
-
The way a card game player arranges his cards as he picks them up one by one , is an example of
- bubble sort
- selection sort
- insertion sort
- merge sort
Tutorial-2
-
Which of the following sorting methods will be the best if number of swapping done, is the only measure of efficiency?
- bubble sort
- insertion sort
- selection sort
- heap sort
-
Which of the following sorting methods sorts a given set of items that is already in sorted order or in reverse sorted order with equal speed?
- Heap sort
- Quick sort
- Insertion sort
- Selection sort
-
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
- bubble sort
- insertion sort
- selection sort
- heap sort
-
Sorting is not useful for
- report generation
- minimizing the storage needed
- making searching easier and efficient
- responding to queries easily
-
Trace the arrangement of elements in the end of each pass while using bubble-sort for the below list
5 6 2 9 1 4
-
Trace the arrangement of elements in the end of each pass while using insertion sort for the below list
22 13 17 15 19 8
-
A machine needs a minimum of 100 sec. to sort 1000 names by quick sort. The minimum time needed to sort 100 names will be approximately
- 50.2 sec
- 6.7 sec
- 72.7 sec.
- 11.2 sec
-
A machine took 200 sec to sort 200 names, using bubble sort.
In 800 sec. it can approximately sort _ _ _ _ _ _ _ _ _ names
- 400
- 800
- 750
- 1600
PRACTICE PROBLEMS
Beginner problems
-
What do you mean by sorting? Mention the different types of sorting.
-
Explain linear search with a good example.
-
What is the time complexity of binary search?
-
Trace out all passes and steps by hand to sort the following list in bubble sort
5 2 1 8 7
-
Write algorithm for performing selection sort.
-
Write a program to sort elements of an array using Insertion sort.
Intermediate problems
-
Formulate recursive algorithm for binary search with its timing analysis.
-
Write a program to explain selection sort. Which type of technique does it belong?
-
Compare the advantage and disadvantage of bubble, insertion and selection sort.
-
Sort the following numbers using selection sort and give the required steps.
96,31,27,42,34,76,61,10,4
(a) Distinguish between linear and binary search methods.
(b) Write an algorithm for non-recursive binary search method.
-
Write an algorithm for two-way merge sort. Analyze its time complexity.
-
Derive the time complexity of merge sort.
-
(a) Explain Quick sort with algorithm.
(b) Analyze the worst case performance of Quick sort and compare with Selection sort.
Advanced problems
-
Write a program to sort the elements whose worst case is O (n2) and average case is
O (n log n).
-
Write an algorithm for routine merge(x, lb1, ub1, ub2) that assumes that x [lb1] through
x [ub1] and x[ub1 + 1] through x[ub2] are sorted and merges the two into x[lb1]
through x[ub2].
-
Trace through the steps by hand to sort the following list in Quick sort.
28 7 39 3 63 13 61 17 50 21
-
Write in detail about the following: (a) Selection sort (b) Merge Sort.
-
Suppose that the list contains the integers 3 7 13 17 28 50 21 39 61 63 in this order.
Trace through the steps of binary search to determine what comparisons of keys are done
in searching.
To locate 17
To locate 16
-
Write about Sorting Efficiency, and explain O - notation Analysis.
This Page Is Designed By Rakesh
|