Académique Documents
Professionnel Documents
Culture Documents
Announcements
Lab exam this week.
Please reach lab 10 minutes before the scheduled time. Follow all instructions sent by email.
End-sem exam is on 25th November, 8:00 AM Copies can be seen on 28th afternoon.
Lec-40
Recap
Algorithms to compare
GCD based on remainder and subtraction Merge sort and selection sort
GCD
Algorithm based on remainder function takes c log n steps Algorithm based on subtraction takes d n steps
Sorting
Selection sort takes c * n * n steps Merge sort takes d * n * log n steps
Lec-40 Dheeraj Sanghi, CSE Dept., IIT Kanpur ESc101, 2011-12-Monsoon 2
For large values of n, we can ignore linear term Hence number of instructions are bounded by:
c1 * n * n
Lec-40
Lec-40
Lec-40
Lec-40
Lec-40
Lec-40
10
Similarly, we do constant number of operations in printing each number Hence, number of instructions executed: c*n
assuming n to be the numbers to be read, sorted, and printed
Lec-40 Dheeraj Sanghi, CSE Dept., IIT Kanpur ESc101, 2011-12-Monsoon 11
Any Questions?
Lec-40
13