I have an algorithm that goes something like this $$\begin{align}&\mathbf{ALGORITHM}\operatorname{BruteForceMedian}(A[0..n-1])\\&\mbox{// Returns the median value in a given array $A$ of $n$ numbers. This is}\\&\mbox{// the $k$th element, where $k=|n/2|$, if the array was sorted.}\\&k\leftarrow|n/2|\\&\mathbf{for}\ i\ \mathbf{in}\ 0\ \mathbf{to}\ n-1\ \mathbf{do}\\&\quad\text{numsmaller}\leftarrow0\quad\hbox{// How many elements are smaller than $A[i]$}\\&\quad\text{numeral}\leftarrow0\qquad\hbox{// How many elements are equal to $A[i]$}\\&\quad\mathbf{for}\ j\ \mathbf{in}\ 0\ \mathbf{to}\ n-1\ \mathbf{do}\\&\qquad\mathbf{if}\ A[j]<A[i]\ \mathbf{then}\\&\qquad\quad\text{numsmaller}\leftarrow\text{numsmaller}+1\\&\qquad\mathbf{else}\\&\qquad\quad\mathbf{if}\ A[j]=A[i]\ \mathbf{then}\\&\qquad\qquad\text{numequal}\leftarrow\text{numequal}+1\\&\quad\mathbf{if}\ \text{numsmaller}<k\ \mathbf{and}\ k\le(\text{numsmaller}+\text{numequal})\ \mathbf {then}\\&\qquad\mathbf{return}\ A[i]\end{align}$$I figure as this is a nested loop algorithm its efficiency class would be $O(n^2)$. I am just confused as to what the algorithm's Basic Operation should be. Is it the comparison operator down the bottom that (when correct) returns the median value of the array?
What's the basic operation of a brute force median algorithm?
algorithms;complexity theory