


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of the concepts covered in a university course on the analysis of algorithms. The motivation behind the study of algorithms, the difference between programs and algorithms, and the importance of measuring algorithmic running time. It also introduces various techniques for comparing functions, such as upper and lower bounds, and discusses the efficiency of different types of algorithms, including iterative, recursive, brute force, and divide and conquer algorithms. The document also covers various techniques for solving recurrences and provides examples of recursive algorithms, such as merge sort and quick sort.
Typology: Study notes
1 / 4
This page cannot be seen from the preview
Don't miss anything!



General Motivation: Objective of the course: how to design and analyze algorithms Algorithms: recipes for solving problems , they are realized by programs Programs: sequences of instructions
One alternative: take a program and count the number of instructions (this may be depend on implementation)
We need some measure how to compare them which would be independent of machine, details and it would depend on the METHOD used to solve the problem
In general given a program the number of instructions will depend on input:
We want to compare algorithms in the same class: (trying to solve the same problems, without worrying about details of speed of computer, implementation)
Running time -> Number of instructions as a function of input size n:
Algorithm 1 takes f(n) steps, algorithm 2 takes g(n) steps, we Want to compare them = > compare functions f, g, for large n
Order of growth of functions:
Definitions of classes of functions Upper bound, lower bound, tight bound, not tight upper (lower) bound
Facts: polynomials are dominated by higher order terms
To show it from definition choosec andno such that inequalities hold
Facts:Facts:^ exponential functions grow faster then polynomials
Comparing functions using limits (L’Hospital rule):
Longest running time on any input Regardless of the input it will takeat mostat most w(n) steps It is the upper bound of the algorithm on any input
Lower bound on the worst-case running time There is some input that the algorithm will perform at leastat least f(n) steps
Worst case result on a particular array Best case result on a particular array If we make statement about the algorithm, it has to be for any input
Types of algorithms: Iterative (multiple loops)
Compute exact running time (bounding summations)
Iterative (multiple loops) Compute exact running time (bounding summations)
Recursive algorithms – partition into smaller sub-problems
To establish the running time, we need to solve the recurrent equations. Techniques for solving recurrences:
Examples of recursive algorithms: (Merge Sort, Quick Sort, Binary Search, Selection, Tower of Hanoi etc., number of bits in n’s binary represent.)
MinMin MaxMax^
worst case (at most) and best casen-
Selection problemSelection problem^ expected average running time randomized partition
Selection problemSelection problem^ average case running time quick sort idea
Implicit data structure (correspondence heap – array) Heap properties
Build HeapBuild Heap
Loose bound upper bound
Tighter bound
HeapifyHeapify
Heap SortHeap Sort (^) extract max, replace root, Heapify(A,1)
Heapsort is
Need to know how these work Does it depend on whether array is sorted or not?