Algorithms and Algorithmic Thinking
Instructions on making a Jam Sandwich
Origins of Algorithms Dinsdag 6 augustus 2002 is de Nederlandse informaticus Edsger Wybe Dijkstra overleden. Hij werd over de hele wereld beroemd door zijn ideeën over gestructureerd programmeren.
“Peeling Potatoes for a Family Supper” We observe the cook doing this “He gets the potato basket from the cellar, gets the pan from the cupboard, peels the potatoes returns the basket to the cellar” Sequence
“Go to the other side of the road” “Go to Hell” Meaningful Instructions Effective
Meaningful Instructions Unambiguous A wedding journalist reported that the four bridesmaids wore the same dress.
Instructions “He gets the potato basket from the cellar, gets the pan from the cupboard, peels the potatoes returns the basket to the cellar” get the potato basket from the cellar, get the pan from the cupboard, peel the potatoes return the basket to the cellar Sequence Correct Order
Jordan does something different get the potato basket from the cellar, get the pan from the cupboard, IF clothes are light colored THEN put on an apron peel the potatoes return the basket to the cellar IF some condition THEN some action Selection
“peel the potatoes” Halting
“peel the potatoes” IF number of peeled potatoes is not sufficient THEN peel a potato
“peel the potatoes” WHILE the number of potatoes is insufficient DO peel a potato get the potato basket from the cellar, get the pan from the cupboard, IF clothes are light colored THEN put on an apron WHILE the number of potatoes is insufficient DO peel a potato return the basket to the cellar WHILE condition is true DO an action Iteration
“peel the potatoes” WHILE condition is true DO an action Instruction Blocks WHILE condition is true DO action1 action2 action3
Algorithms – a definition Sequence of Instructions (ordered) Instructions are Effective and Unambigous Sequence must Halt in a finite time On halting, the sequence must have a Result Instructions may be Simple Actions Selections Iterations action IF condition THEN action WHILE condition is true DO action
DanielBobGrantAnneCarolNathanSue Sequential Search Algorithm - Example
DanielBobGrantAnneCarolNathanSue Sequential Search Algorithm - Example
Daniel BobNathan AnneCarolGrantSue Binary Search (Tree Representation) L LL H HH
Password Cracker Passwords created with lower case only a…z
Computational Thinking
Pseudo-code and Code there is a list of numbers get the length of the list set the value of sum to zero while the end of the list has not been reached get the next value in the list add this to the sum display the sum int numArray[2]; int len; int index; int sum; numArray[0] = 3; numArray[1] = 4; length = numArray.length; index = 0; sum = 0; while(index <= length) { sum = sum + numArray[index]; index = index + 1; } printf(“Sum is %d”, sum);
get the potato basket from the cellar, get the pan from the cupboard, peel the potatoes return the basket to the cellar
I Have A Lovely Bunch Of Coconuts
x = 5 Y = 3 Temp = X X = Y Y = Temp
Music Algorithmic?