Diamonds present decisions
that the program will make
(Iteration)
The parallelogram
represents Data, this
is inputs and outputs.
The oval shape is to
represent that
terminator, the start
and finish of the
program.
Python commands and other useless codey stuff
Print ("Hello Again") will print
what ever is in the speech
marks to the user
'While' will create a
loop that will finish
after a condition if
met, this is why it
is a condition loop
Always make sure to add :
at the end of any orange
commands etc in your code
Stuff about variables
CamelCase Is when an
identifier may contain capital
letters that are not only used
on the firtst letter, like
FirstName or LastName (May
user underscores as well eg:
last_name)
Variables hold VALUES
Always make sure
identifiers are
accuratley named
Sorts
Merge Sorts
1. If there is only one
item in the list then stop
2. Divide the list in two
parts. 3. Recursively
divide these lists until the
size f each becomes one
4. Recursively merge the
lists with the items in the
correct numerical order
When splitting an odd number
Searches
Linear Search
A linear search is a simple,
sequential search. It starts
at the beginning of the list
and moves through the
items, one by one, until it
finds a matching value or
reaches the end without
finding one.
Binary Search
The binary search algorithm
searches an ordered list to
find an item by looking at the
middle (median) item and
comparing it with the search
value.
Linear VS Binary
How efficient are the algorithms? Suppose we have
a sorted list of 100 items. For a linear search, the
best case would be for the search item to be the
first item of the list and so require only one
comparison. The worst case would be for the item
to be at the end of the list and so it would have to
examine all of them and 100 comparisons would be
needed. For a binary search, the best case would be
for the search item to be the middle item of the
list. The worst case would be for the item to be the
last possible division, i.e. the median items selected
could be: 51, 26, 13, 7, 4, 2, 1. Therefore in the worst
case, the binary search would find the search item
after only seven comparisons.
Data Type Stuff
Opposite to a
variable is a
constant
Integer is a
whole
number
from 0 to
infinity
A Float is a
number with
numbers on
either side of the
decimal point
A Real number is
also a decimal but
can contain
values such as
root 2 and
integers