Introduction to Algorithms/Variables

From Wikiversity
Jump to navigation Jump to search

This is a lesson in in the course, Introduction to Algorithms, which is a part of The School of Computer Science

Objective[edit | edit source]

Books-aj.svg aj ashton 01f.png

Variables[edit | edit source]

In the above example it is fairly simple to follow the piece of toast through the algorithm, but if you imagine that the algorithm could become more complex, and thus the progress of the toast much harder to follow. In order that, at any point in the algorithm, it is clear what is being talked about, names are often given to things. For example

Algorithm for making buttered toast (3.0)

 LET A = a loaf of bread
 LET T = a toaster
 LET P = a plate
 LET B = some butter
 LET S = cut slice from A
 get A
 move the S to T
 turn on T
 wait for T
 move the S to P
 spread S with B

Assignments[edit | edit source]

Crystal Clear app kedit.svg

Smiley green alien cry.svg Completion status: this resource is a stub, which means that pretty much nothing has been done yet.