{
  "translations": {
    "en": {
      "sc1": "Finally, consider the average case cost.",
      "sc2": "When record $i$ is processed, the number of times through the inner for loop depends on how far out of order the record is.",
      "sc3": "The inner for loop is executed once for each value greater than the value of record $i$ that appears in positions $0$ to $i-1$.",
      "sc4": "To calculate the average cost, we want to determine what is the average number of inversions will be for the record in position $i$.",
      "sc5": "This could be 0, or 1, or 2, or anything up to $i$. On average, it is $i/2$ positions out of order.",
      "sc6": "And since this had to be done for the records from $1$ to $n-1$, then we have the total cost as:",
      "sc7": "This can be solved as:",
      "sc8": "Therefore, the average case running time of insertion sort is $\\Theta(n^2)$."
    }
  },
  "code": {
    "java_generic": [{
      "url": "../../../SourceCode/Java_Generic/Sorting/Insertionsort.java",
      "lineNumbers": false,
      "startAfter": "/* *** ODSATag: Insertionsort *** */",
      "endBefore": "/* *** ODSAendTag: Insertionsort *** */",
      "tags": {
        "loops": [2, 3],
        "loop1": 2,
        "loop2": 3
      }
    }],
    "c++": [{
      "url": "../../../SourceCode/C++/Sorting/Insertionsort.cpp",
      "lineNumbers": false,
      "startAfter": "/* *** ODSATag: Insertionsort *** */",
      "endBefore": "/* *** ODSAendTag: Insertionsort *** */",
      "tags": {
        "loops": [2, 3],
        "loop1": 2,
        "loop2": 3
      }
    }],
    "java": [{
      "url": "../../../SourceCode/Java/Sorting/Insertionsort.java",
      "lineNumbers": false,
      "startAfter": "/* *** ODSATag: Insertionsort *** */",
      "endBefore": "/* *** ODSAendTag: Insertionsort *** */",
      "tags": {
        "loops": [2, 3],
        "loop1": 2,
        "loop2": 3
      }
    }],
    "python": [{
      "url": "../../../SourceCode/Python/Sorting/Insertionsort.py",
      "startAfter": "/* *** ODSATag: Insertionsort *** */",
      "endBefore": "/* *** ODSAendTag: Insertionsort *** */",
      "tags": {
        "sig": 1,
        "outloop": 2,
        "inloop": 4,
        "swap": 5,
        "end": 6
      }
    }]
  }
}
