principleMinor
Examples of higher order algorithms ($\mathcal{O}(n^4)$ or larger)
Viewed 0 times
orderlargerexamplesalgorithmshighermathcal
Problem
In most computer science cirriculums, students only get to see algorithms that run in very lower time complexities. For example these generally are
However it can be shown that
$$
\mathcal{O}(1)\subset \mathcal{O}(\log n)\subset \ldots \subset \mathcal{O}(n^3)\subset \mathcal{O}(n^4)\subset\mathcal{O}(n^5)\subset\ldots\subset \mathcal{O}(n^k)\subset\ldots
$$
so it would be expected that there would be more well known problems that are in higher order time complexity classes, such as $\mathcal{O}(n^8)$.
What are some examples of algorithms that fall into these classes $\mathcal{O}(n^k)$ where $k\geq 4$?
- Constant time $\mathcal{O}(1)$: Ex sum of first $n$ numbers
- Logarithmic time $\mathcal{O}(\log n)$: Ex binary searching a sorted list
- Linear time $\mathcal{O}(n)$: Ex Searching an unsorted list
- LogLinear time $\mathcal{O}(n\log n)$: Ex Merge Sort
- Quadratic time $\mathcal{O}(n^2)$: Ex Bubble/Insertion/Selection Sort
- (Rarely) Cubic time $\mathcal{O}(n^3)$: Ex Gaussian Elimination of a Matrix
However it can be shown that
$$
\mathcal{O}(1)\subset \mathcal{O}(\log n)\subset \ldots \subset \mathcal{O}(n^3)\subset \mathcal{O}(n^4)\subset\mathcal{O}(n^5)\subset\ldots\subset \mathcal{O}(n^k)\subset\ldots
$$
so it would be expected that there would be more well known problems that are in higher order time complexity classes, such as $\mathcal{O}(n^8)$.
What are some examples of algorithms that fall into these classes $\mathcal{O}(n^k)$ where $k\geq 4$?
Solution
Brute-force algorithms can be considered as a good example to achieve the mentioned running times (i.e. $\Omega(n^4)$).
Suppose given the sequence $\sigma=\langle a_1,a_2,\dots , a_n\rangle$
of real numbers, you want to find, if exists $k$ elements ($k\geq
4$, and $k$ is
constant ) from $\sigma$ such that $$\sum_{i=1}^{k}a_i=0.$$
Obviously, a simple brute-force algorithm for this problem check all $\binom{n}{k}$ subsets of the input and detect whether the elements in at least one of them sum to $0$. If $k$ is a constant then $\binom{n}{k}=\Theta(n^k)$. For example if $k=10$ then the running time of your algorithm is $\Theta(n^{10}).$ Finally, you find algorithm for your desired running time.
Suppose given the sequence $\sigma=\langle a_1,a_2,\dots , a_n\rangle$
of real numbers, you want to find, if exists $k$ elements ($k\geq
4$, and $k$ is
constant ) from $\sigma$ such that $$\sum_{i=1}^{k}a_i=0.$$
Obviously, a simple brute-force algorithm for this problem check all $\binom{n}{k}$ subsets of the input and detect whether the elements in at least one of them sum to $0$. If $k$ is a constant then $\binom{n}{k}=\Theta(n^k)$. For example if $k=10$ then the running time of your algorithm is $\Theta(n^{10}).$ Finally, you find algorithm for your desired running time.
Context
StackExchange Computer Science Q#131467, answer score: 3
Revisions (0)
No revisions yet.