1.3 Algorithms
Enduring Understanding
Developers create and innovate using an iterative design process that is user-focused, that incorporates implementation/feedback cycles, and that leaves ample room for experimentation and risk-taking.
Essential Questions
What makes a computer a computer?
How do video games group the different actions for a player based on what key is pressed on the keyboard or controller?
How do apps group different actions together based on user interaction, such as pressing buttons?
What types of problems can be solved more easily with a computer, and what types can be solved more easily without a computer? Why?
Lesson Objectives
Explain how a program or code segment functions.
Identify input(s) to a program.
Identify output(s) produced by a program.
For errors in an algorithm or program: a. Identify the error. b. Correct the error.
Identify inputs and corresponding expected outputs or behaviors that can be used to check the correctness of an algorithm or program.
Essential Knowledge
A program is a collection of program statements that performs a specific task when run by a computer. A program is often referred to as software.
A code segment refers to a collection of program statements that are part of a program.
A program needs to work for a variety of inputs and situations.
The behavior of a program is how a program functions during execution and is often described by how a user interacts with it.
A program can be described broadly by what it does, or in more detail by both what the program does and how the program statements accomplish this function.
Program input is data sent to a computer for processing by a program. Input can come in a variety of forms, such as tactile, audio, visual, or text.
An event is associated with an action and supplies input data to a program.
Events can be generated when a key is pressed, a mouse is clicked, a program is started, or by any other defined action that affects the flow of execution.
Inputs usually affect the output produced by a program.
In event-driven programming, program statements are executed when triggered rather than through the sequential flow of control.
Input can come from a user or other programs.
Program output is any data sent from a program to a device. Program output can come in a variety of forms, such as tactile, audio, visual, or text.
Program output is usually based on a program’s input or prior state (e.g., internal values).
A logic error is a mistake in the algorithm or program that causes it to behave incorrectly or unexpectedly.
A syntax error is a mistake in the program where the rules of the programming language are not followed.
A run-time error is a mistake in the program that occurs during the execution of a program. Programming languages define their own run-time errors.
An overflow error is an error that occurs when a computer attempts to handle a number that is outside of the defined range of values.
The following are effective ways to find and correct errors: § test cases § handtracing § visualizations § debuggers § adding extra output statement(s)
In the development process, testing uses defined inputs to ensure that an algorithm or program is producing the expected outcomes. Programmers use the results from testing to revise their algorithms or programs.
Defined inputs used to test a program should demonstrate the different expected outcomes that are at or just beyond the extremes (minimum and maximum) of input data.
Program requirements are needed to identify appropriate defined inputs for testing.