8525 Unit 1 Flashcards
Algorithm definition
An algorithm is a set of instructions for solving a problem or completing a task
Abstraction definition
Involves removing unnecessary detail from a problem so that you can focus on the essential components
E.g. London Underground
Decomposition definition
Involves breaking down a large problem into smaller sub-problems
Decomposition advantages
Problem becomes easier to solve
Some modules may be reusable in other programs, saving development time
Can collaborate
Computational thinking
The use of computers to solve problems
Start/end flowchart symbol
Rounded rectangle looking thing
__________
(__________)
Input/output flowchart symbol
Parallelogram
Sub-process flowchart symbol
_____________
|__|_____|__|
Rectangle with two lines in the middle
Process flowchart symbol
Rectangle
Decision flowchart symbol
Rhombus with one arrow coming out on the right and one arrow going down
Labelled true/yes and false/no
What is a flowchart
A diagram that shows the inputs, outputs and processes in an algorithm
All programs are composed of three basic structures:
Sequence
Selection
Iteration
What is a sequence
A series of steps which are completed one after another
What is selection
Selection is the ability to choose difference paths through a program
What is iteration
Means repeating a part of a program
Referred to as repetition or looping
Data types
Integer—whole number—1475,0,-5
Real—number with a decimal point—56.75, 6.0, -2.5, 0.0
Character—a single alphabetic/numeric/symbol character
String—one or more characters enclosed in quote marks
Iteration statements
FOR…ENDFOR
WHILE…ENDWHILE
REPEAT…UNTIL
Write a search algorithm for numbers <- [5,1,9,8,7,6,4,10]
In linear search
numbers <- [5,1,9,8,7,6,4,10]
searchItem <- STRING_TO_INT(USERINPUT)
FOR i <- 0 TO LEN(numbers) - 1
IF numbers[i] = searchItem THEN
OUTPUT “searchItem found”
ENDIF
ENDFOR