90 likes | 179 Views
Discover the concept of algorithms as a series of well-defined and executable operations that yield results efficiently. Learn about pseudocode for sequential, conditional, and iterative setups. Practical examples like finding common friends are included. Dive into the basics of flowcharts too for visualizing algorithmic steps. Access Python chapter Sections 1 and 2 to enhance your understanding.
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