Download presentation
Presentation is loading. Please wait.
1
The PlayStation Example
Recall An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate input in a finite amount of time. 👍 Why study Algorithms? The PlayStation Example “computer” problem algorithm input output
2
Presenting an Algorithm
Natural language Does it work ? How about Java Code? Pseudocode
3
Pseudocode Pseudocode is not a computer program, but is more structured than general speech. It is a mixture of natural language and high-level programming constructs that describe the main ideas behind an algorithm. Because pseudocode is designed for a human reader, not a computer, we can communicate high-level ideas without being burdened by low-level implementation details. At the same time, we should not gloss over important steps. Like many forms of human communication.
4
Pseudocode Guidelines
We will adapt the stile in [G] Detailed in subsection 1.9.2 We will allow a lot of freedom as well
5
The ‘Lifecycle’ of a Solution
Problem Understanding Design Pseudocode Coding Testing
6
Testing top-down testing bottom-up testing
7
Testing Programs often tend to fail on special cases e. g.
For example, when array sorting we must double check if our solution still works in these cases: The array has zero length (no elements). The array has one element. All the elements of the array are the same. The array is already sorted. The array is reverse sorted. Good programmers always test for those.
8
Algorithm Design Lifecycle Example
On the Board Fractional Knapsack See notes in my webpage for details link
9
Algorithm Design Lifecycle Example “again”
On the Computer Closing the Loop Link Solution will be available on the pager next Sunday
10
Reading [G] Subsections and 1.9.5 [G] Section 3.1
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.