{"id":11172,"date":"2022-12-22T11:06:18","date_gmt":"2022-12-22T11:06:18","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=11172"},"modified":"2023-08-29T06:12:38","modified_gmt":"2023-08-29T06:12:38","slug":"bubble-sort-program-in-python","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/","title":{"rendered":"Bubble Sort Program in Python"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671607224782-Bubble%20Sort%20in%20Python.jpg\" alt=\"\" \/><\/p>\n<p>Bubble Sort, a fundamental sorting algorithm, embodies the essence of simplicity in programming. It&#8217;s a stepping stone for beginners to grasp sorting logic and gain insights into algorithm efficiency. In this article, we delve into the world of Bubble Sort in Python, dissecting its mechanics, implementation, and performance considerations. Whether you&#8217;re a coding novice seeking clarity or a programmer looking to refresh your understanding this article will guide you about bubble sort, the bubble sort algorithm in python, and the time and space complexity of the bubble sort program in python.<\/p>\n<h2>What is Bubble Sort in Python?<\/h2>\n<p>The bubble sort algorithm compares adjacent elements and swaps them to sort the list. The bubble sort uses two for loops to sort the list. The first for loop (outer for loop) is used to traverse the list n times. The Second for loop (inner for loop) is used to traverse the list and swap elements if necessary.<\/p>\n<h2>Bubble Sort Algorithm Python:-<\/h2>\n<p>Let\u2019s understand how the bubble sort algorithm python works using an example and visualizing the algorithm. The process of sorting the list in ascending using the bubble sort algorithm python is given below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671607224884-Bubble%20Sort%20in%20Python1.png\" alt=\"\" \/><\/p>\n<p>Now Let\u2019s see how n-1 (n=size of a list) list passes work on a list.<\/p>\n<p><strong>First pass (i=0)<\/strong><br \/>\n<img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671607224884-Bubble%20Sort%20in%20Python2.png\" alt=\"\" \/><\/p>\n<ul>\n<li>First, we will run the inner loop for n-i-1 (5-0-1 = 4) times and we will compare each adjacent pair.<\/li>\n<li>For j=0, compare j=0 (l[0]=4) and j+1=1 (l[1]=3) here l[j]&gt;l[j+1] so we will swap two elements because we want higher elements on the right side to sort a list.<\/li>\n<li>For j=1, l[1] (4) &lt; l[2] (9) so we will not swap elements because the higher element (9) is already on the right side.<\/li>\n<li>For j=2, l[2] (9) &gt; l[3] (1) so we will swap elements.<\/li>\n<li>For j=3, l[3] (9) &gt; l[4] (5) so we will swap elements.<\/li>\n<li>After performing the first pass we can see that the last element of a list (9) is already at its right position so in further passes we will not touch that element.<\/li>\n<\/ul>\n<p><strong>Second pass (i=1)<\/strong><br \/>\n<img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671607224890-Bubble%20Sort%20in%20Python3.png\" alt=\"\" \/><\/p>\n<ul>\n<li>In the second pass (i=1), we will run inner loop n-i-1 time ( 5-1-1 =3) which one less than the first pass it is because the last element is already sorted in the second pass so we will not consider the last element.<\/li>\n<li>For j=0, l[0] (3) &lt; l[1] (4) so we will not swap elements.<\/li>\n<li>For j=1, l[1] (4) &gt; l[2] (1) so we will swap elements.<\/li>\n<li>For j=2, l[2] (4) &lt; l[3] (5) so we will not swap elements<\/li>\n<li>After the completion of the second pass, we can see that the last two elements of an list ( [5,9] ) are in their right position.<\/li>\n<\/ul>\n<p><strong>Third pass (i=2)<\/strong><br \/>\n<img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671607224890-Bubble%20Sort%20in%20Python4.png\" alt=\"\" \/><\/p>\n<ul>\n<li>In the third pass ( i=2 ), we will run the inner loop n-i-1 (5-2-1 = 2) times.<\/li>\n<li>For j=0, l[0] (3) &gt; l[1] (1) so we will swap elements.<\/li>\n<li>For j=1, l[1] (3) &lt; l[2] (4) so we will not swap elements.<\/li>\n<li>After performing the third pass we can see that the last three elements ( [4,5,9] ) are in their right positions.<\/li>\n<\/ul>\n<p><strong>Fourth pass (i=3)<\/strong><br \/>\n<img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671607224890-Bubble%20Sort%20in%20Python5.png\" alt=\"\" \/><\/p>\n<ul>\n<li>In the fourth pass (i=3 ), we will run the inner loop n-i-1 (5-3-1=1) times.<\/li>\n<li>For j=0, l[0] (1) &lt; l[1] (3) so we will not swap elements.<\/li>\n<li>After performing the fourth pass we can see that our list is sorted.<\/li>\n<\/ul>\n<p>Sorting happens in place in bubble sort python which means if there are two elements with the same values so after performing the bubble sort program in python the order of that two elements will be the same.  Let\u2019s understand this with an example list= [4,6,3,6,5] here two same elements are 6 at index 2 and 4 now after performing bubble sort list= [3,4,5,6,6] now two elements which is same are 6 at index 4 and 5 so element  6 at index 4 is element 6 at index 2 before performing sorting and element 6 at index 5 is the element at index 4 before performing sorting.<\/p>\n<h2>Bubble Sort Program in Python:-<\/h2>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_11170 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_11170 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_11170 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_11170 .wpsm_nav-tabs > li.active > a, #tab_container_11170 .wpsm_nav-tabs > li.active > a:hover, #tab_container_11170 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_11170 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_11170 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_11170 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_11170 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_11170 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_11170 .wpsm_nav-tabs > li > a:hover , #tab_container_11170 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_11170 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_11170 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_11170 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_11170 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_11170 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_11170 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_11170 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_11170 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_11170 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_11170 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_11170 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_11170\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_11170\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_11170_1\" aria-controls=\"tabs_desc_11170_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Python<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_11170\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_11170_1\">\r\n\t\t\t\t\t\t\t\t<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">def bubble_sort(list1):   \r\n    for i in range(0,len(list1)-1):  \r\n        for j in range(len(list1)-1):  \r\n            if(list1[j]&gt;list1[j+1]):  \r\n                temp = list1[j]  \r\n                list1[j] = list1[j+1]  \r\n                list1[j+1] = temp  \r\n    return list1  \r\n  \r\nlist1 = [5, 3, 8, 6, 7, 2]  \r\nprint(\"The unsorted list is: \", list1)  \r\nprint(\"The sorted list is: \", bubble_sort(list1))<\/pre>\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_11170 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_11170 a\"),jQuery(\"#tab-content_11170\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Output<\/strong><\/p>\n<pre><code>The unsorted list is:  [5, 3, 8, 6, 7, 2]\nThe sorted list is:  [2, 3, 5, 6, 7, 8]<\/code><\/pre>\n<p>There is one problem with the above bubble sort program in python when a given list is already sorted the above program will still finish all the two loops so the time complexity becomes O(n^2) though the list is already sorted. Let\u2019s see how can we optimize the above bubble sort program in python.<\/p>\n<h3>Optimized Bubble Sort Program in Python:-<\/h3>\n<p>We can observe one thing if our list is already sorted then no swap will be performed so we can use this observation to write an optimized bubble sort program in python.<\/p>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_11171 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_11171 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_11171 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_11171 .wpsm_nav-tabs > li.active > a, #tab_container_11171 .wpsm_nav-tabs > li.active > a:hover, #tab_container_11171 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_11171 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_11171 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_11171 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_11171 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_11171 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_11171 .wpsm_nav-tabs > li > a:hover , #tab_container_11171 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_11171 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_11171 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_11171 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_11171 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_11171 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_11171 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_11171 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_11171 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_11171 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_11171 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_11171 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_11171\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_11171\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_11171_1\" aria-controls=\"tabs_desc_11171_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Python<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_11171\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_11171_1\">\r\n\t\t\t\t\t\t\t\t<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">def bubble_sort(list1):  \r\n    has_swapped = True  \r\n  \r\n    while(has_swapped):  \r\n        has_swapped = False  \r\n        for i in range(len(list1) - 1):  \r\n            if list1[i] &gt; list1[i+1]:  \r\n                # Swap  \r\n                list1[i], list1[i+1] = list1[i+1], list1[i]  \r\n                has_swapped = True  \r\n    return list1  \r\n  \r\nlist1 = [5, 3, 8, 6, 7, 2]  \r\nprint(\"The unsorted list is: \", list1)  \r\nprint(\"The sorted list is: \", bubble_sort(list1))<\/pre>\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_11171 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_11171 a\"),jQuery(\"#tab-content_11171\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<h2>Time Complexity Analysis of Bubble Sort Python<\/h2>\n<p><strong>Best:- O(n)<\/strong> when the given list is already sorted at that time program using only one loop.<br \/>\n<strong>Average:- O(n^2)<\/strong> when the given list is not sorted.<br \/>\n<strong>Worst:- O(n^2)<\/strong> when the given list is reverse sorted at that time we have to perform a swap for each comparison. So the total swaps performed will be n*(n-1)\/2<\/p>\n<h2>Auxiliary Space complexity of bubble sort python<\/h2>\n<p><strong>Auxiliary space complexity:- O(1)<\/strong> it\u2019s because we are not using any extra list to perform bubble sort python. We are only using variables so the space complexity is O(1) to perform the bubble sort algorithm python.<\/p>\n<p><strong>Conclusion<\/strong><br \/>\nWhile Bubble Sort is straightforward and easy to implement, its performance limitations make it impractical for large datasets. Its time complexity of O(n^2) discourages its use for real-world scenarios where efficiency is paramount. However, mastering Bubble Sort&#8217;s logic is crucial for understanding sorting algorithms&#8217; basic principles and serves as a foundation for exploring more sophisticated sorting methods. As you advance in your coding journey, you&#8217;ll encounter more efficient sorting algorithms that offer better performance for larger datasets.<\/p>\n<h2>FAQs Related to Bubble Sort in Python<\/h2>\n<p><strong>1. How does Bubble Sort work?<\/strong><br \/>\nThe algorithm repeatedly steps through the list, comparing adjacent elements. If they&#8217;re out of order, they&#8217;re swapped. This process continues until the entire list is sorted.<\/p>\n<p><strong>2. What is the time complexity of Bubble Sort?<\/strong><br \/>\nBubble Sort has a worst-case and average-case time complexity of O(n^2), where n is the number of elements in the list. This makes it inefficient for larger datasets.<\/p>\n<p><strong>3. When should I use Bubble Sort?<\/strong><br \/>\nBubble Sort is primarily used for educational purposes and understanding sorting logic. It&#8217;s not recommended for real-world applications due to its poor performance with large datasets.<\/p>\n<p><strong>4. Are there more efficient sorting algorithms?<\/strong><br \/>\nYes, there are several sorting algorithms that offer better performance than Bubble Sort. Algorithms like Quick Sort, Merge Sort, and Heap Sort have lower time complexities and are preferred for larger datasets.<\/p>\n<p><strong>5. Why is Bubble Sort inefficient?<\/strong><br \/>\nBubble Sort compares and swaps elements in a pairwise manner, resulting in many unnecessary swaps. This contributes to its quadratic time complexity.<\/p>\n<p><strong>Other Python Programs<\/strong><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-reverse-a-number\/\" title=\"Python program to reverse a number\">Python program to reverse a number<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/heap\/python-program-for-heap-sort\/\" title=\"Python program for heap sort\">Python program for heap sort<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-check-armstrong-number\/\" title=\"Python program to check armstrong number\">Python program to check armstrong number<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-check-leap-year\/\" title=\"Python program to check leap year\">Python program to check leap year<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-convert-celsius-to-fahrenheit\/\" title=\"Python program to convert celsius to fahrenheit\">Python program to convert celsius to fahrenheit<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-find-factorial-of-a-number\/\" title=\"Python program to find factorial of a number\">Python program to find factorial of a number<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-reverse-a-linked-list\/\" title=\"Python program to reverse a linked list\">Python program to reverse a linked list<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/python-program-to-find-the-middle-of-a-linked-list-using-only-one-traversal\/\" title=\"Python Program to find the middle of a linked list using only one traversal\">Python Program to find the middle of a linked list using only one traversal<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-add-two-numbers\/\" title=\"Python Program to Add Two Numbers\">Python Program to Add Two Numbers<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-check-palindrome-number\/\" title=\"Python Program to Check Palindrome Number\">Python Program to Check Palindrome Number<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/python-program-to-print-the-fibonacci-series\/\" title=\"Python Program to Print the Fibonacci Series\">Python Program to Print the Fibonacci Series<\/a><br \/>\n<a href=\"prepbytes.com\/blog\/python\/python-loop-program\/\" title=\"Python Loop Program\">Python Loop Program<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/python\/anagram-program-in-python\/\" title=\"Anagram Program in Python\">Anagram Program in Python<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bubble Sort, a fundamental sorting algorithm, embodies the essence of simplicity in programming. It&#8217;s a stepping stone for beginners to grasp sorting logic and gain insights into algorithm efficiency. In this article, we delve into the world of Bubble Sort in Python, dissecting its mechanics, implementation, and performance considerations. Whether you&#8217;re a coding novice seeking [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[154],"tags":[],"class_list":["post-11172","post","type-post","status-publish","format-standard","hentry","category-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Bubble Sort Program in Python<\/title>\n<meta name=\"description\" content=\"We will learn about bubble sort, the bubble sort program &amp; algorithm in python, and the time and space complexity of the bubble sort program in python.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bubble Sort Program in Python\" \/>\n<meta property=\"og:description\" content=\"We will learn about bubble sort, the bubble sort program &amp; algorithm in python, and the time and space complexity of the bubble sort program in python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-22T11:06:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-29T06:12:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671607224782-Bubble%20Sort%20in%20Python.jpg\" \/>\n<meta name=\"author\" content=\"Prepbytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prepbytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Bubble Sort Program in Python\",\"datePublished\":\"2022-12-22T11:06:18+00:00\",\"dateModified\":\"2023-08-29T06:12:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/\"},\"wordCount\":1203,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671607224782-Bubble%20Sort%20in%20Python.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/\",\"name\":\"Bubble Sort Program in Python\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671607224782-Bubble%20Sort%20in%20Python.jpg\",\"datePublished\":\"2022-12-22T11:06:18+00:00\",\"dateModified\":\"2023-08-29T06:12:38+00:00\",\"description\":\"We will learn about bubble sort, the bubble sort program & algorithm in python, and the time and space complexity of the bubble sort program in python.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671607224782-Bubble%20Sort%20in%20Python.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671607224782-Bubble%20Sort%20in%20Python.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/python\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Bubble Sort Program in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\",\"name\":\"Prepbytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"caption\":\"Prepbytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Bubble Sort Program in Python","description":"We will learn about bubble sort, the bubble sort program & algorithm in python, and the time and space complexity of the bubble sort program in python.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/","og_locale":"en_US","og_type":"article","og_title":"Bubble Sort Program in Python","og_description":"We will learn about bubble sort, the bubble sort program & algorithm in python, and the time and space complexity of the bubble sort program in python.","og_url":"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2022-12-22T11:06:18+00:00","article_modified_time":"2023-08-29T06:12:38+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671607224782-Bubble%20Sort%20in%20Python.jpg","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Bubble Sort Program in Python","datePublished":"2022-12-22T11:06:18+00:00","dateModified":"2023-08-29T06:12:38+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/"},"wordCount":1203,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671607224782-Bubble%20Sort%20in%20Python.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/","url":"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/","name":"Bubble Sort Program in Python","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671607224782-Bubble%20Sort%20in%20Python.jpg","datePublished":"2022-12-22T11:06:18+00:00","dateModified":"2023-08-29T06:12:38+00:00","description":"We will learn about bubble sort, the bubble sort program & algorithm in python, and the time and space complexity of the bubble sort program in python.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671607224782-Bubble%20Sort%20in%20Python.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1671607224782-Bubble%20Sort%20in%20Python.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/bubble-sort-program-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/prepbytes.com\/blog\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Bubble Sort Program in Python"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e","name":"Prepbytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","caption":"Prepbytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/11172","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=11172"}],"version-history":[{"count":3,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/11172\/revisions"}],"predecessor-version":[{"id":17754,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/11172\/revisions\/17754"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=11172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=11172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=11172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}