90 likes | 176 Views
CSCI 1001. overview of. computer science. ALGORITHMS. Algorithm. “A well-ordered collection of unambiguous and effectively computable operations that, when executed, produces a result and halts in a finite amount of time.”. How do we describe an algorithm?. PSEUDOCODE.
E N D
CSCI 1001 overview of computer science ALGORITHMS
Algorithm “A well-ordered collection of unambiguous and effectively computable operations that, when executed, produces a result and halts in a finite amount of time.” How do we describe an algorithm?
PSEUDOCODE Sequential operations “Set variable = expression” “get variable” “input: variable” “print variable” • “output variable” Conditional operations if boolean expression then operation sequence else alternate operation sequence
PSEUDOCODE Iterative operations while boolean expression sequence of operations for each variable in list of values sequence of operations
Finding common friends input: list of names, alice1…alicek input: list of names, bob1…bobm • go through both lists and if you find a • name in common, print it out.
Finding common friends input: list of names, alice1…alicek input: list of names, bob1…bobm set i = 0 set j = 0 while i < k while j < m if alicei = bobj then print alicei set j to j+1 set k to k+1
( ) xkcd. com
FLOWCHARTS Sequential operation Conditional True False
http://cs1001.us/ Please read Sections 1 and 2 of the Python chapter for Monday