Sorting
Re-arranging similar elements in a preferred order:
Either - increasing order or - decreasing order or - Lexicographic order
Simplest sorting technique to arrange elements in the ascending order:
Example: 7, 4, 8, 2, 5, 3, 9
Example: 4 3 2 10 12 1 5 6
Example: 4 3 2 10 12 1 5 6
Overall time complexity is around n^2.
MERGE SORT ( A, p, r)
Time complexity of MergeSort is around n\log{n}.
We will come back to the analysis and correctness proof little later!
O-notation
For a given function g(n), we denote by O(g(n)) the set of functions
O(g(n)) = \{f(n) : \text{there exists positive constants } c \text{ and } n_0 \text{ such that } 0\leq f(n)\leq cg(n) \text{ for all } n\geq n_0\}.
\Omega-notation
For a given function g(n), we denote by \Omega(g(n)) the set of functions
\Omega(g(n)) = \{f(n) : \text{there exists positive constants } c \text{ and } n_0 \text{ such that } 0\leq cg(n)\leq f(n) \text{ for all } n\geq n_0\}.
\Theta-notation
For a given function g(n), we denote by \Theta(g(n)) the set of functions
\Theta(g(n)) = \{f(n) : \text{there exists positive constants } c_1, c_2, \text{ and } n_0 \text{ such that } 0\leq c_1g(n)\leq f(n)\leq c_2g(n) \text{ for all } n\geq n_0\}.
Thank You!
Let’s discuss questions, clarifications, or any topics from today’s lecture.
CS F364: Design & Analysis of AlgorithmsTulasimohan Molli