CLASS -11 COMPUTER SCIENCE
CHAPTER- 10 UNDERSTANDING SORTING
🔔To download textbook pdf click on the ''DOWNLOAD'' button below -
NOTES FOR COMPLETE UNDERSTANDING -
- Sorting means to make groups of the objects as per need.
- Order of sorting can be of ascending or descending order .
- In this chapter we will study sorting in details and will see two sorting techniques: 1. Bubble Sort 2. Insertion Sort
- What is Sorting ?
- “In computer, sorting is a procedure to arrange elements in ascending or descending order ”.
- Consider the following sequence -
- Seq = [16,8,11,1,3,4] Its new sequence arranged in ascending order will be Seq = [1,3,4,8,11,16 ] And its new sequence arranged in descending order will be Seq = [16,11,8,4,3,1]
- There are various techniques of sorting like-
- Selection Sort,
- Bubble Sort,
- Insertion Sort,
- Heap Sort,
- Quick Sort etc.
- Only two sorting techniques are in our syllabus- • Bubble sort • Insertion sort
- Bubble Sort :
- In Bubble Sort, we compare two adjacent elements and if the elements are not in correct order then these elements got exchanged. After every pass the element with big value secures its correct position.
- The concept of above program can be understood by dry run and debugger tool of python can also be used for it.
- Detection of number of operations in Bubble Sort :
- Number of Operations in any sorting technique is an important issue because more number of operations means more time will be required by CPU .
- Two programs with distinct logic can produce the similar output with different number of operations.
- Insertion Sort :
- In this insertion Sort , two first values gets in order.
- We refer it as sub-sequence which is to be sorted.
- From rest of the unsorted list of values , each value will be taken one by one and will be inserted at right position in sorted sub-sequence.
- The concept of above program can be understood by dry run and debugger tool of python can also be used for it.
- Application of Bubble Sort and Insertion Sort :
- Bubble sort is considered a simple and easier way of sorting algorithm but it is not considered as a perfect algorithm.
- For a small database, insertion sort is better and more preferred than bubble sort.
- For the sorting of a sequential file , bubble sort is better data is stored in sequential format.
- Insertion sort is generally used to sort small databases. When the database is nearly all sorted then this technique work faster as not much memory is needed.
- In small sequences, less number of swapping is there thus insertion sort is more preferred as compared to bubble sort.
🔔MORE MATERIALS TO BE UPLOADED STAY TUNED🔔