Professional Documents
Culture Documents
Announcements
Monday sections will do lab 12 on 5th November (Saturday) y ( y) instead of 7th November (Idul Zuha) Lab exam in the week of 14th to 18th November End-sem exam is on 25th November, 8:00 AM Copies can be seen on 28th afternoon afternoon.
Lec-36
Lec-36
Recap
Sorting Algorithms
Insertion Sort Bubble Sort Merge Sort
Lec-36
Take the (i+1)th element Find the right place for this element amongst the first i+1 positions in the array, and place it there
This can be done by comparing with previous element and if the new element is larger, exchange Keep doing this, till you dont need to exchange.
Lec-36
Lec-36
Lec-36
Lec-36
Lec-36
Lec-36
Selection Sort
The basic algorithm works as follows:
Find the minimum value in the list Swap it with the value in the first position Repeat these two steps for the remainder of the list (starting at the second position and advancing each time)
Lec-36
10
Lec-36
11
Lec-36
12
Lec-36
13
Lec-36
14
Lec-36
15
Lec-36
17
Lec-36
18
Let the number be: 81234567 Half H lf way mark is between 4th and 5th di i (3 and 4) ki b d digits d A palindrome is: 81233218, but it is smaller Increment 8123 (half number) to 8124 and now the palindrome is: 81244218
Dheeraj Sanghi, CSE Dept., IIT Kanpur ESc101, 2011-12-Monsoon 19
10
Lec-36
20
Any Questions?
Lec-36
21
11