L01S_COMP170_t1

L01S_COMP170_t1 - COMP170 Tutorial 1 A Quick &...

Info iconThis preview shows pages 1–14. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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. Its not really a programming language, (its missing many things, e.g., variable declarations) but it suffices for our purposes. Because its so simple its often used to demonstrate programming/algorithm ideas. If youve 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 whove 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

Page1 / 65

L01S_COMP170_t1 - COMP170 Tutorial 1 A Quick &...

This preview shows document pages 1 - 14. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online