Department of Computer Science & Engineering ANJUMAN COLLEGE OF ENGINEERING & TECHNOLOGY Department of Computer Science & Engineering Subject:-Design & Analysis of Algorithms Prepared By: Prof.. Naisha Taban Khan
Syllabus: Unit 1: Mathematical foundations, summation of arithmetic and geometric series, n, n2 , bounding summations using integration, Recursion and Induction: recurrence relations, solutions of recurrence relations using techniques of characteristic equation, generating functions, master method and substitution method. Complexity calculation of various standard functions, principles of designing algorithms. Unit 2: Asymptotic notations of analysis of algorithms, analyzing control structures, worst case and average case analysis, amortized analysis, application of amortized analysis, Sorting networks, comparison networks, bio-tonic sorting network, advanced data structures like Fibonacci heap, disjoint set representation. Unit 3: Divide and conquer basic strategy, binary search, quick sort, merge sort, matrix operations, Multiplication Algorithm Greedy method – basic strategy, Knapsack Problem, application to job sequencing with deadlines problem, minimum cost spanning trees, single source shortest path, Optimal Search Patterns.
Unit 4: Dynamic Programming basic strategy, multistage graphs, all pairs shortest path, single source shortest paths, optimal binary search trees, traveling salesman problem, Longest Common Subsequence problem, 0/1 Knapsack Problem, Chained Matrix Multiplication . Unit 5: Basic Traversal and Search Techniques, breadth first search and depth first search, connected components. Backtracking basic strategy, 8-Queen’s problem, graph coloring, Hamiltonian cycles etc, Introduction to Approximation algorithm. Unit 6: Recursively enumerable (r.e.) set, recursive sets, Decidability and solvability, Post correspondence Problem (PCP), Introduction to recursive function theory, primitive recursive functions, Ackerman function.
COURSE OUTCOMES: CO1: Examine the correctness of algorithms using inductive proofs and design the solutions to recursive relations.ns. CO2: Explain Asymptotic Analysis and elaborate the methods of Amortized Analysis. CO3: Explain different algorithm design techniques like Divide and Conquer & Greedy strategy and make use of algorithms that employ this paradigm. CO4: Determine the Dynamic Programming paradigm and solve Dynamic Programming algorithms and simplify them. CO5: Design and illustrate the different traversal techniques and build different graph computations. CO6: Explain Polynomial and Non polynomial time complexities and elaborate the deterministic and non deterministic algorithms.
Unit-III : Knapsack Problem CO3: Explain different algorithm design techniques like Divide and Conquer & Greedy strategy and make use of algorithms that employ this paradigm. The knapsack problem is an optimization problem. When it is solved using Greedy method, available input will be considered one by one. Knapsack means a container with maximum capacity W, and a set S consisting of n items given. Each item i has some weight wi and profit value pi (all wi , pi and W are integer values). The objective is to store the object in Knapsack either completely or fractionally to achieve maximum profit.
Applications of Knapsack Problem: Memory or Storage management. Demand Paging. Approches: There are three approches: Based on Weight: Select the object on the basis that it may use knapsack property as slow as possible (select minimum weight object first). Based on Profit: Select the object depending on the profit at each stage, most profitable remaining object will be selected first. 3. Based on Profit and Weight: Select the object whose profit per unit weight is as high as possible.
Problem 1: Find the optimal solution for Knapsack problem where Capacity = 100 & Number of objects = 5 Solution: i/p 1 2 3 4 5 Wi 10 20 30 40 50 Pi 66 60 i/p 1 2 3 4 5 Wi 10 20 30 40 50 Pi 66 60 Pi/Wi 1.5 2.2 1.2
Based on Weight: i/p Profit Weight Capacity Left 1 20 10 100-10=90 2 30 90-20=70 3 66 70-30=40 4 40 40-40=0 Total Profit 156
Based on Profit: i/p Profit Weight Capacity Left 3 66 30 100-30=70 5 60 50 70-50=20 4 40(required weight / Total Weight)=20 30(required weight / Total Weight)=20 20-20=0 Total Profit 146
Based on Profit & Weight: i/p Profit Weight Capacity Left 3 66 30 100-30=70 1 20 10 70-20=50 2 60-20=40 5 60(required weight / Total Weight)=48 50(required weight / Total Weight)=40 40-40=0 Total Profit 164
For this Knapsack Problem 3rd approach which is based on profit & weight gives maximum profit. Analysis: Fractional Knapsack has time complexity O(NlogN) where N is the number of items in S.