This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: COMP170 Tutorial 1 A Quick & Dirty Introduction to Pseudocode One of our primary examples in the first lecture was a short snippet of pseudocode taken from selection sort. Pseudocode is a way of describing computer programs. It’s not really a programming language, (it’s missing many things, e.g., variable declarations) but it suffices for our purposes. Because it’s so simple it’s often used to demonstrate programming/algorithm ideas. If you’ve ever used a programming language such as C++, Fortran, Pascal, Basic, etc., pseudocode should be easily understandable. These notes are meant as a quick introduction to reading pseudocode for those who’ve never programmed before. Pseudocode Components • Variables • Arrays • Conditionals • For Loops • Review of code from class Variables A named location that stores a value A = 5 B = 3 C = A + B B = 4 C = A + B A = 7 A = A + 3 A = A + C A B C Variables A named location that stores a value A = 5 B = 3 C = A + B B = 4 C = A + B A = 7 A = A + 3 A = A + C A B C 5 Variables A named location that stores a value A = 5 B = 3 C = A + B B = 4 C = A + B A = 7 A = A + 3 A = A + C A B C 5 3 Variables A named location that stores a value A = 5 B = 3 C = A + B B = 4 C = A + B A = 7 A = A + 3 A = A + C A B C 5 3 8 Variables A named location that stores a value A = 5 B = 3 C = A + B B = 4 C = A + B A = 7 A = A + 3 A = A + C A B C 5 4 8 Variables A named location that stores a value A = 5 B = 3 C = A + B B = 4 C = A + B A = 7 A = A + 3 A = A + C A B C 5 4 9 Variables A named location that stores a value A = 5 B = 3 C = A + B B = 4 C = A + B A = 7 A = A + 3 A = A + C A B C 7 4 9 Variables A named location that stores a value A = 5 B = 3 C = A + B B = 4 C = A + B A = 7 A = A + 3 A = A + C A B C 10 4 9 Variables A named location that stores a value A = 5 B = 3 C = A + B B = 4 C = A + B A = 7 A = A + 3 A = A + C A B C 19 4 9 Arrays A block of variables accessed as X[i] X: Name of the array i: index in the array B = 2 A[1] = 1 A[2] = B A[3] = 2 * A[1] + 5 A[4] = A[3]  A[2] A[1] = 2 * A[1] A 1 A 2 A 3 A 4 B Arrays A block of variables accessed as X[i] X: Name of the array i: index in the array B = 2 A[1] = 1 A[2] = B A[3] = 2 * A[1] + 5 A[4] = A[3]  A[2] A[1] = 2 * A[1] A 1 A 2 A 3 A 4 B 2 Arrays...
View
Full
Document
This note was uploaded on 08/25/2010 for the course COMP COMP170 taught by Professor M.j.golin during the Spring '10 term at HKUST.
 Spring '10
 M.J.Golin
 Computer Science, Selection Sort

Click to edit the document details