Algorithms Flashcards
An algorithm
A series of steps taken to complete a task.
Two ways to present algos
Flow charts
Pseudo code
Decomposition is
Breaking down on large problem into several smaller sub problems
Decomposition advs
Easier for teams to tackle problems
Easier to solve
Abstraction
Removal of unecessary details from a problem
Abstraction is used in what and advs
Weather models
Makes it less cluttered and easier to see the problem
Computational thinking concepts
Algorithmic thinking
Abstraction
Decomposition
Algorithm symbols for Start/End Process Input/output Decisions
Oval
Rectangle
Parallelogram
Diamond with yes down and no to the side
3 basic programming constructs
Sequence
Iteration
Selection
Sequence
The order in which execution occurs
Selection (pseudocode)
If then else (pseudo code)
Choose between two options
Iteration (pseudocode) and types
Repetition of instructions
For loop - definite amount of times action must be repeated eg for 5
Repeat until - indefinite iteration - condition controlled - until it is true wont move on
While loop - action occurs only while the condition is true
Two search algorithms are
Linear search
Binary search
Linear search is
When data is unsorted, you start at the beginning and search through every item till you find it. Eg
Start at first name
Repeat
Examine current name
IF it’s the one you’re looking for THEN
END IF
UNTIL found = true
Binary search is
If the list is sorted in binary or alphabetical order. Repeatedly divide the the data in half till there is only item in the list
Eg
We are trying to find the number 100
We start at fifty
If the number at fifty is lower then we discard everything in the first half and keep on halving the second half till we find it