ITA - Week 1 Flashcards
What is an algorithm
An algorithm is a sequence of unambiguous instructions for solving a problem
What is the brute force approach
Trying every path to find the best solution
Algorithms vs Programs
Algorithm - Free from grammatical rules and content is most important
Program - Must obey syntax to be acceptable
What is pseudocode
A mixture of natural language and programming language-like constructs used to describe an algorithm
Comments in pseudocode
// - single line
What does x
X gets the value of 0
Pseudocode array differences to programming languages
In pseudocode, arrays start from 1 rather than 0
How to find maximum number in a list
max(numbers)
What is the sieve of Eratosthenes
Lists all prime numbers not exceeding a value
How does the sieve of Eratosthenes work
Starts by stating 2 is prime
Crosses out all multiples of 2
Next number not crossed out is prime
Crosses out all multiples of next number etc.
What is Euclid’s algorithm
Finds greatest common denominator of two non negative, not both zero integers
What is the formula for Euclid’s algorithm
when n /= 0 do
r