Download presentation
Presentation is loading. Please wait.
Published byAllison Baker Modified over 6 years ago
1
Design and Analysis of Computer Algorithm (CS575-01)
Problems Strategy Efficiency Analysis Order Algorithm: Applying a technique to a problem results in a step-by-step procedure for solving problem. The step-by-step procedure is called an algorithm for the problem.
2
Examples Example: - Sort a list S of n numbers in non-decreasing order. The answer is the numbers in sorted sequence. - Determine whether the number x is in the list S of n numbers. The answer is yes if x is in S, and no if it is not - solution: Sequential search; Binary search - Add array members - Matrix multiplication
3
Importance of Algorithm Efficiency
Time Storage Example - Sequential search versus binary search Basic operation: comparison Number of comparisons is grown in different rate - nth Fibonacci sequence Recursive versus iterative
4
Example: search strategy
Sequential search vs. binary search Problem: determine whether x is in the sorted array S of n keys Inputs: positive integer n, sorted (non-decreasing order) array of keys S indexed from 1 to n, a key x Output: location, the location of x in S (0 if x is not in S)
5
Example: search strategy
Sequential search: Basic operation: comparison Void Seqsearch(int n, const keytype S[], keytype x, index& location) { location=1; while(location<=n && S[location] != x) location++; if(location > n) location = 0; }
6
Example: search strategy
Binary search: Basic operation: comparison Void Binsearch(int n, const keytype S[], keytype x, index& location) { index low, high, mid; low = 1; high =n; location=0; while(low<=high && location ==0) mid = floor((low+high)/2); if(x==S[mid]) location = mid; else if (x< S[mid]) high = mid -1; else(low = mid +1); }
7
Example: number of comparisons
Sequential search: n ,048,576 Binary search: lg(n) Eg: S[1],…, S[16],…, S[24], S[28], S[30], S[31], S[32] (1st) (2nd) (3rd) (4th) (5th) (6th)
8
Analysis of Algorithm Complexity
Input size Basic operation Time complexity - T(n) : Every-case time complexity - W(n): Worst-case time complexity - A(n): Average-case time complexity - B(n): Best-case time complexity n is the input size T(n) example - Add array members; Matrix multiplication; Exchange sort T(n) = n-1; n*n*n n(n-1)/2
9
Math preparation Induction Logarithm Sets Permutation and combination
Limits Series Asymptotic growth functions and recurrence Probability theory
10
Programming preparation
Data structure C C++
11
Presenting Commonly used algorithms
Search (sequential, binary) Sort (mergesort, heapsort, quicksort, etc.) Traversal algorithms (breadth, depth, etc.) Shortest path (Floyd, Dijkstra) Spanning tree (Prim, Kruskal) Knapsack Traveling salesman Bin packing
12
Well known problem Problem: Given a map of North America, find the best route from New York to Orlando? Well known problem: what is it? Many efficient algorithms Choose appropriate one (e.g., Floyd’s algorithm for shortest paths using dynamic programming)
13
Another well known problem
Problem: You got a job as a paper person. You want to find the shortest tour from your home to every person on your list? Well known problem: what is it? One solution to traveling salesperson problem: dynamic programming
14
Another well known problem (continued)
No efficient algorithm to general problem Many heuristic and approximation algorithms (e.g., greedy heuristic) Choose appropriate one
15
Another well known problem (continued)
Computer Graphics Scan conversion Flood Filling Ray tracing, …
16
Another well known problem (continued)
Computational Geometry Find a convex hull Delaunay triangulation Voronoi Diagram Choose an efficient one
17
Design Methods or Strategies
Divide and conquer Greedy Dynamic programming Backtrack Branch and bound Linear Programming
18
Not addressed (Advanced algorithms)
Genetic algorithms Neural net algorithms Algebraic methods
19
The theory of NP completeness
Many common problems are NP-complete ( traveling salesperson, knapsack,...) (NP: non-deterministic polynomial) Fast algorithms for solving NP-complete problems probably don’t exist Techniques such as approximation algorithms are used (e.g., minimum spanning tree prim’s algorithm with triangle inequality)
20
Are algorithms useful? Hardware Software Economics Biomedicine
Computational geometry (graphics) Decision making ….. “Great algorithms are the poetry of computation”
21
Software Text processing Networks Data bases Compilers
String matching, spell checking, and pretty print,… Networks Minimum spanning trees, routing algorithms, … Data bases Compilers
22
Engineering Optimization problem (e.g., finite element, energy minimization, dynamic simulation). Best feature selection for object representation and biometrics recognition (e.g., Genetic Algorithm) Mathematics: geometric simulation and approximation (e.g., algorithm approximation) Graphics visualization (e.g., area filling and scan conversion, 3D key framing). Signal analysis: FFT, Huffman coding, encryption, decryption…
23
Economics Transportation problems Scheduling problems
Shortest paths, traveling salesman, knapsack, bin packing Scheduling problems Location problems (e.g., Voronoi Diagram) Manufacturing decisions
24
Social decisions The matching problem Assigning residents to hospitals
Matching residents to medical program
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.