{
  "translations" :{
    "en": {
      "sc1": "A mistake that people often make is to confuse the upper bound and the worst case.",
      "sc2": "<br>The upper bound of an algorithm indicates the upper or highest growth rate that the algorithm can have for a problem of size $n$.",
      "sc3": "The sequential search algorithm accepts as its input an array of $n$ keys and the target key $K$ to search for.",
      "sc4": "<br> So what is the upper bound of the sequential search algorithm?",
      "sc5": "<br>Do you think this is the correct way to ask this question?",
      "sc6": "Remember that there are three input cases that affect the running time of sequential search.",
      "sc7": "<br>1- When the target key $K$ is located at the first position in the input array.",
      "sc8": "<br>2- When the target key $K$ is located at the last position in the input array.",
      "sc9": "<br>3- The average cost over all possible positions for $K$, which comes out to about $n/2$.",
      "sc10": "In the best case for the algorithm, only a single element is visited. $\\mathbf{T}(n) = 1$",
      "sc11": "<br>Accordingly, an upper bound for the algorithm in the best case is $O(1)$. Even when $n$ increases, the cost for the best case does not <b>grow</b>.",
      "sc12": "In the worst case for the algorithm, $n$ elements must be visited. $\\mathbf{T}(n) = n$",
      "sc13": "<br>So an upper bound for the algorithm in the worst case is $O(n)$. No matter the value of $n$, for some constant $c$, $cn$ is bigger than $n$.",
      "sc14": "In the average case for the algorithm, about $n/2$ elements are visited. $T(n) = \\frac{n}{2}$",
      "sc15": "<br><br>So an upper bound for the algorithm in the average case is also $O(n)$. No matter the value of $n$, for some constant $c$, $cn$ is bigger than $n/2$.",
      "sc16": "Accordingly, the correct way to ask the question is: <br>What is the upper bound of sequential search in the best/average/worst case?",
      "sc17": "<br><br>And the answer should be...",
      "lab1": "$O(1)$ in the <b><u>Best Case.</u></b>",
      "lab2": "$O(n)$ in the <b><u>Worst Case</u></b>.",
      "lab3": "$O(n)$ in the <b><u>Average Case</u></b>."
    }
  }
}
