Algorithms & Computation Flashcards
What is peak finding?
Finding a number in a sequence that is greater in value than all its neighbors.
How efficient are selection sort and bubble sort in the worst case scenario?
O(n^2).
How does bubble sort work? What about selection sort?
Bubble sort compares a pair and switches their place f the first is larger. Selection sort finds the smallest in the set, moves it to the front, and then recursively repeats after the sorted element.
For an ordered list, binary search is of the complexity
log(n); divide and conquer algorithms tend to be of logarithmic time complexity.
What is merge sort and how efficient is it?
nlog(n) — the set is divided into singleton lists by halving (log(n) component) and then individual sorted by direct comparison (n component).
Describe a stochastic process.
In a stochastic process there is an element of randomness and unpredictability. A random walk is an example of a stochastic process and models many physical systems, for example molecule diffusion. Stochastic processes are in contrast to deterministic processes.
What is memoization?
Storing the solutions to subroutines in memory to avoid having to recompute them later, as part of dynamic programming.
A technique for reducing exponential time problems to polynomial time by reducing them to subroutines whose solutions are stored and later retrieved from memory is:
dynamic programming.
RAM is basically a huge array of memory, maybe 4GB these days. What is the time complexity of data access in RAM if you know the address?
Constant time.
What is document distance?
An algorithmic approach to comparing two text documents to determine how similar they are. One way to solve document distance is to create a vector for each document representing the frequency of all the words.
What is a method of optimizing a data structure which tracks if items are connected?
Creating a weighted tree, which could be modeled as an array with each entry representing the parent node. In the weighted tree, a union of nodes always attaches the smaller of the two to the larger, producing a flatter tree structure overall. The proven most optimized solution is weighted quick union with path compression, which reduces the problem from 30 years to 6 seconds. This is why algorithm design is critical, having a supercomputer would not help you much here.
Modeling percolation experiences a phase transition at a point that cannot be calculated mathematically, but determined computationally by
a weighted quick union with path compression algorithm which models the connections.
Describe how the scientific method can be applied to algorithmic design.
Mathematical or conceptual theory can form a basis for design which can then be tested and evaluated empirically to determine performance and then iteratively improved.
Algorithms that divide the input in half progressively are typically characterized by what order of growth?
logarithmic; log(n)
A simple looping algorithm has what time complexity?
Linear, O(n)