design and analysis of algorithms computational complexity n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Design and Analysis of Algorithms & Computational Complexity PowerPoint Presentation
Download Presentation
Design and Analysis of Algorithms & Computational Complexity

Loading in 2 Seconds...

play fullscreen
1 / 10

Design and Analysis of Algorithms & Computational Complexity - PowerPoint PPT Presentation


  • 124 Views
  • Uploaded on

Design and Analysis of Algorithms & Computational Complexity. CS490 Koji Tajii. Designing a program means…. 1. Specify what you exactly want to do. What kind of input and output? What is the Precondition and Post condition? 2. Design the Algorithm Pseudocode

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Design and Analysis of Algorithms & Computational Complexity' - jonah


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
designing a program means
Designing a program means…
  • 1. Specify what you exactly want to do.
    • What kind of input and output?
    • What is the Precondition and Post condition?
  • 2. Design the Algorithm
    • Pseudocode
    • What kind of Data structures are needed?
  • 3. Translate the program into a programming language
    • C++ JAVA, etc…
  • 4. Test and Debug
    • Does it actually work?
algorithmic design techniques
Algorithmic Design Techniques
  • Divide and Conquer
    • Decomposing tasks into smaller subtasks
  • Dynamic Programming
    • Break down problems into stages
    • Keep track of what’s going on at each stage as states
    • Determine the best solution by taking into consideration the states of the previous stage
  • Greedy
    • Always choosing the best local solution at the time to eventually get to the final solution.
time and space complexity
Time and Space Complexity
  • Efficiency of program is determined by its speed and amount of memory space it takes.
  • Faster and smaller is better but…
big o notation
Big-O Notation
  • Order of an algorithm
    • Rough approximation of number of operations a program will execute to determine its speed

2

worst average best case scenario
Worst, Average, Best Case Scenario
  • Worst Case
    • Maximum Number of Operations
  • Average Case
    • Average Number of Operations
  • Best Case
    • Fewest Number of Operations
  • Probability of occurrence?
    • Unless the best-case behavior occurs with high probability, it is generally not used
    • The worst case occurs often
example 1
Example 1

void search(const int a[], int first, int size, int target, bool& found, int& location)

{

int middle;

if(size == 0)

found = false;

else

{

middle = first + size/2;

if (target == a[middle])

{

location = middle;

found = true;

}

else if (target < a[middle])

search(a, first, size/2, target, found, location);

else

search(a, middle+1, (size-1)/2, target, found, location);

}

}

example 2
Example 2

Void Sort(int A[], int N)

{

bool sorted = false’

for(int Pass = 1; (Pass < N) && !sorted; ++Pass)

{

Sorted = true;

for(int Index = 0; Index < N-Pass; ++Index)

{

int NextIndex = Index + 1;

if(A[Index] > A[NextIndex])

{

swap(A[Index], A[NextIndex]);

Sorted = false;

}

}

}

}

references
References
  • Main Michael & Savitch Walter. Data Structures and Other Objects using C++. Addison-Wesley. 1997.
  • Walls & Millors. Data Abstraction and Problem Solving with C++. 2nd ed. Addison-Wesley. 1998
  • http://mat.gsia.cmu.edu/classes/dynamic/dynamic.html