Definitions Flashcards
Sedgewick (2011): Algorithm
The term algorithm is used in computer science to describe
methods for solving problems that are suited for computer
implementation.
Aho, Hopcroft & Ulman (1975): Algorithm
An algorithm is a finite sequence of instructions, each of which
has a clear meaning and can be performed with a finite
amount of effort in a finite length of time.
Levitin (2003): Algorithm
An algorithm is a finite sequence of an ambiguous instructions for solving a problem, i.e, for obtaining the required output for any legitimate input in a finite amount of time.
Iterative Algorithm
Iteration is the repetition of a process in order to generate a sequence of outcomes. The sequence will approach some endpoint or end value. Each repetition of the process is a single iteration, and the outcome of each iteration is then the starting point of the next iteration.
Direct Recursion Algorithm
If a function calls itself, it’s known as direct recursion.
Indirect Recursion Algorithm
Indirect recursion occurs when a function is called not by itself but by another function that it called (either directly or indirectly). For example, if f calls f, that is direct recursion, but if f calls g which calls f, then that is indirect recursion of f.
Divide and Conquer Algorithm
Divide and conquer is an algorithm design paradigm based on multi-branched recursion. A divide-and-conquer algorithm works by recursively breaking down a problem into two or more sub-problems of the same or related type, until these become simple enough to be solved directly.
Dynamic Programming Algorithms
Like divide-and-conquer method, Dynamic Programming solves problems by combining the solutions of subproblems. Moreover, Dynamic Programming algorithm solves each sub-problem just once and then saves its answer in a table, thereby avoiding the work of re-computing the answer every time.
Randomised Algorithms
An algorithm that uses random numbers to decide what to do next anywhere in its logic is called Randomised Algorithm.
Brute Force Algorithms
Brute Force Algorithms refer to a programming style that does not include any shortcuts to improve performance, but instead relies on sheer computing power to try all possibilities until the solution to a problem is found.
Euclid’s Algorithm for GCD
- Step 1: If n = 0, return the value of m as the answer and stop; otherwise, proceed to step 2.
- Step 2: Divide m by n and assign the value of the remainder to r.
- Step 3: Assign the value of n to m and the value of r to n. Go to step 1.
cₒₚ
The cost (time) to execute an algorithm’s basic operation on some computer
C(n)
The number of times the operation needs to be executed
~1: Constant time
Normally the amount of time that a instruction takes under the RAM model
~log n: Logarithmic
It normally occurs in algorithms that transform a bigger problem into a smaller version that whose input size is a ration of the original problem. Common in searching and in some tree algorithms.