CSE 130 1-29-10 Lecture 3
Published on: Sat Jan 30 2010
This was a general overview of good practices. The first important note was to think with Time Efficiency. The professor pointed out how there are two ways to “sum to N”. One is to keep adding 1 each time until you each N, the other way is to use the Gaussian Summation Formula. While the Gaussian Summation Formula was something I had not heard of before, the point of the assignment was really to teach us about the assignment of an expression to a variable
Assignment Statement
Ex: sum = ( n* (n+1) )/2
Assigns the value of an expression to a variable
It is the only statement that does computation
Control Statement
Decide who does the work
Summary of Programs
1. Input and Output
2. Initialization
3. Computation using an Expression
4. Some kind of loop/iterative statement
5. A decision making statement (If – Then – Else)
- These are essential
Problem Solving Process
- Analysis (Of Input, Output, Specifications)
- Design (KISS)
- Implementation (Think about Future Maintenance)
- Testing (Individually (Modular) and Collectively)
Tips
- Find out as Much as you can (Research the problem, obtain more info)
- Reuse what has been done before (What succeeded, what Failed)
- Expect Future reuse (Create a Library?)
- Break complex problems into sub problems
Algorithm building blocks
0. Input & Output
1. Expressions
2. Conditional
3. Iteration
4. Subprogram invocation