CS/SE310 Analysis of Algorithms
Fall 2019
Instructor Noman Nazar
Lectures Days: Wed, Sat Contact Email: [email protected]
Time: 3:30 – 4:45
Office Hall STD404, 2nd Floor, TA <Name> TBA
STD Buiding, UMT <Office Hours and Venue> TBA
Office Hours: TBA
Lab NA
Pre- CS/SE200-Discrete Moodle
Requisites Mathematics Group
CS/SE210-Data Structures
and Algorithms
Course Course objectives are the following, in order of importance:-
Objectives To familiarize the students with techniques of analysis
To enable the students to choose and apply a relevant analysis technique for
an algorithm they encounter
To impart design ideas that go hand-in-hand with the analysis of algorithms
To familiarize the students with major paradigms of algorithms
To familiarize the students with commonly employed algorithms and their
analysis
Textbooks Cormen, Leisorson, Rivest & Stein, “Introduction To Algorithms”, 2nd
Edition, Prentice Hall of India
Technology C/C++/Java
Midterms Single Midterm Examination Final Single Final Examination that will
from the material covered be comprehensive, i.e., will be
during the first 7 weeks assessing the whole course
contents
Classroom Review recommended material before coming to class
Policy No disturbances
Keep mobiles switched off.
Plagiarism will result in negative marking
Grading Assignments: 5 in number, 20%
Policy Quizzes: 6 in number, 20%
Midterms: 1 in number, 20%
Final: 1 in number, 40%
Tentative Course Plan:
Week Contents
1 What is an algorithm?
Few examples of algorithms
Role of algorithms in computing
Implementation of algorithms and technology
Need for efficiency
Example of how efficiency makes a difference
Expressing an algorithm
Pseudocode conventions
Few examples on pseudocoded algorithms
o Evenness/Oddness of a number
o Finding if a number divides another number
o Finding LCM of two numbers
2 What is analysis of an algorithm?
Factors affecting analysis
Counting steps and examples
o Generating Primes
o Checking whether a number is a Perfect Number
Estimate from costly operations
Variations inherent in algorithms
o Example: Searching a List/Array
Need for Worst/Average/Best cases
Need for envelopes/families of time complexity
The Order concept
Big-O notation and definition
Big-O examples applied on algebraic expressions
o Quadratic
o Cubic
o Polynomial
o Logarithmic
o Rule of thumb
3 Graphing the time values for an algorithm
Relation between discrete expressions and their continuous counterparts
Trends extractable from the continuous counterparts
Asymptotic analysis
Big-O revised
Theta and Omega notations and definitions
Few examples applied on algebraic expressions
Asymptotic trends illustrated with graphs
Sorting algorithms, their common use and rich variety of algorithmic principles
o Selection Sort and analysis
Bubble Sort and analysis
Insertion Sort and analysis using Tabular approach
4 Shifting the approach: Divide and Conquer
Principle of Merging
Merge algorithm and complexity
Terminology introduced: in-place/out-place; auxiliary memory
Merge Sort explanation with diagrams
Estimate of complexity
Merge Sort algorithm
Estimate of complexity of Merge Sort using Tabular approach
Reviewing Divide and Conquer features encountered in Merge Sort
General features of Divide and Conquer problems
Limitations of Divide and Conquer approach
Revisiting Merge Sort complexity and forming a recurrence based on Divide
and Conquer features
Solving the recurrence using iteration method
5 Recurrences and their relation to Divide and Conquer algorithms
Solving recurrences: Iteration method
o 2-3 examples
Solving recurrences: Recursion trees
o 2-3 examples
Solving recurrences: Master’s theorem
o 4-5 examples
Preparing for Quick Sort: Concept of a Pivot and Partition
6 Partition algorithm
Quick Sort algorithm
Worst and Average cases of Quick Sort
Partition analysis
Quick Sort analysis
Variations on Quick Sort
7 Shifting the approach: Linear Time Sorting
The Counting Principle
Counting Sort and analysis
The Bucket Principle
Bucket Sort and analysis
The use of Radix as basis for bucket
Radix Sort and analysis
Revision
8 Mid Term Examination
Shifting the approach: Greedy algorithms
Example: Fractional Knapsack problem and solution
Features of greedy algorithms evident in knapsack problem
Concepts of solution space and optimal solution
General structure of greedy algorithms
Example: Shortest job first problem
9 Greedy algorithm example: Huffman codes
Where greedy algorithms fail through example of making change
Analysis of failure
Shifting the approach: Dynamic Programming
Dynamic programming introduced through making change problem’s alternate
solution
Examples on dynamic programming: knapsack revisited
Matrix Chain Multiplication
o Multiplying matrices in a chain
o Costs incurred
o Similarity to putting Parentheses
o Data Structures to be used
o The DP algorithm approach
10 Matrix chain algorithm pseudocode
Filling the DP table
Tracing the optimal solution
Dynamic Programming applicability in general and features of DP problems
Shifting the approach: Amortized Analysis
Amortized analysis introduced through example of a binary counter
Aggregate analysis
11 Amortized analysis: Other methods
o Accounting method
o Potential method
Other examples
o Multistacks
o Dynamic tables
Graphs
Representing graphs
o Matrix
o List
Common types of graphs
o Simple/Multi/Pseudo
o Directed/Undirected
o Weighted/Unweighted
Example of elementary graph algorithm: Connectedness
Graph Searches and Traversals
12 Breadth-First Search
Properties
Depth-first Search
Recursive and Non-recursive representations
Properties
Classification of Edges
13 DFS applications
o Topological Sorting
o Strongly-connected Components
Minimal Spanning Trees
Kruskal’s algorithm
Prim’s algorithm
14 Shortest Paths
Dijkstra’s algorithm
Floyd-Warshall algorithm
Revision
15 Shifting the approach: Randomized algorithms
Example: Hiring problem and analysis
Random walks
Monte-Carlo algorithms
Example: Fission modeling, Probable primes
Las Vegas algorithms
Example: Verifying Matrix products