{
  "translations": {
    "en": {
      "sc1": "What is the cost of Bubblesort?",
      "sc2": "The number of comparisons made by the inner for loop on the $i^{th}$ iteration is always $n-i$.",
      "sc3": "Consider the following example of an array with 6 elements:",
      "sc4": "At $i=0$ we have 5 comparisons. Let's mark this with 5 boxes.",
      "sc9": "At $i=1$ we have 4 comparisons, so 4 boxes.",
      "sc13": "At $i=2$ we have 3 comparisons, so 3 boxes.",
      "sc17": "At $i=3$ we have 2 comparisons, so 2 boxes.",
      "sc20": "At $i=4$ we have only 1 comparison, so 1 box.",
      "sc21": "The total amount of comparisons will be the surface area of this shape.",
      "sc22": "The total area will be the sum of the areas of the big triangle $+$ the series of ($n-1$) small traingles.",
      "sc23": "So, the total area is $\\frac{(n-1)(n-1)}{2} + \\frac{(n-1)}{2} = \\frac{n(n-1)}{2}$.",
      "sc24": "Therefore, the worst case running time of Bubble sort is $\\theta(n^2).$"
    }
  },
  "code": {
    "java_generic": [{
      "url": "../../../SourceCode/Java_Generic/Sorting/Bubblesort.java",
      "lineNumbers": false,
      "startAfter": "/* *** ODSATag: Bubblesort *** */",
      "endBefore": "/* *** ODSAendTag: Bubblesort *** */",
      "top": 145,
      "left": 180,
      "tags": {
        "loop": 3
      }
    }],
    "java": [{
      "url": "../../../SourceCode/Java/Sorting/Bubblesort.java",
      "lineNumbers": false,
      "startAfter": "/* *** ODSATag: Bubblesort *** */",
      "endBefore": "/* *** ODSAendTag: Bubblesort *** */",
      "top": 145,
      "left": 180,
      "tags": {
        "loop": 3
      }
    }],
    "c++": [{
      "url": "../../../SourceCode/C++/Sorting/Bubblesort.cpp",
      "lineNumbers": false,
      "startAfter": "/* *** ODSATag: Bubblesort *** */",
      "endBefore": "/* *** ODSAendTag: Bubblesort *** */",
      "top": 145,
      "left": 180,
      "tags": {
        "loop": 3
      }
    }]
  }
}
