{"id":17355,"date":"2020-07-22T18:19:40","date_gmt":"2020-07-22T12:49:40","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/"},"modified":"2024-09-03T11:24:43","modified_gmt":"2024-09-03T05:54:43","slug":"selection-sort-algorithm","status":"publish","type":"post","link":"https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/","title":{"rendered":"Selection Sort Algorithm in C, in Java, in C++, in Python &#038; Examples"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"what-is-selection-sdort\"><strong>What is Selection Sdort<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It is a simple sort algorithm that revolves around the comparison<\/li>\n\n\n\n<li>In each iteration, one element gets placed<\/li>\n\n\n\n<li>We choose the minimum element in the array and place is at the beginning of the array by swapping with the front element<\/li>\n\n\n\n<li>We can also do this by choosing maximum element and placing it at the rear end<\/li>\n\n\n\n<li>Selection sort basically selects an element in every iteration and place it at the appropriate position<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"selection-sort-pseudocode\"><strong>Selection Sort Pseudocode<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set min\u00a0 index to the first index of an unsortedddddddddddddddd array<\/li>\n\n\n\n<li>Iterate the entire unsorted array and do the comparison with min<\/li>\n\n\n\n<li>If element present at the min is greater than the element present at the current index then update min with a current index<\/li>\n\n\n\n<li>Once the iteration is complete, swap the element of min index with the first element of the unsorted part<\/li>\n\n\n\n<li>For descending order, instead of maintaining the smallest element index, maintain the largest element index<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"selection-sort-algorithm\"><strong>Selection sort Algorithm<\/strong><br><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>SelectionSort(arr, n)\n  iterate (n - 1) times\n  set the first unsorted element index as the min\n \t for each of the unsorted elements\n    \t\tif element &lt; currentMin\n     \t\t\tset element's index as new min\n \t swap element at min with first unsorted position\nend selectionSort\n\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"selection-sort-algorithm-dry-run\"><strong>Selection sort Algorithm Dry Run<\/strong><br><\/h2>\n\n\n\n<p>Input:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>0<\/td><td>1<\/td><td>2<\/td><td>3<\/td><td>4<\/td><\/tr><tr><td>23<\/td><td>10<\/td><td>16<\/td><td>11<\/td><td>20<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>First step - marking of sorted part\t<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>0<\/td><td>1<\/td><td>2<\/td><td>3<\/td><td>4<\/td><\/tr><tr><td>10<\/td><td>23<\/td><td>16<\/td><td>11<\/td><td>20<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>After i=1<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>0<\/td><td>1<\/td><td>2<\/td><td>3<\/td><td>4<\/td><\/tr><tr><td>10<\/td><td>11<\/td><td>16<\/td><td>23<\/td><td>20<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>After i=2<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>0<\/td><td>1<\/td><td>2<\/td><td>3<\/td><td>4<\/td><\/tr><tr><td>10<\/td><td>11<\/td><td>16<\/td><td>23<\/td><td>20<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>After i=3<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>0<\/td><td>1<\/td><td>2<\/td><td>3<\/td><td>4<\/td><\/tr><tr><td>10<\/td><td>11<\/td><td>16<\/td><td>20<\/td><td>23<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>After i=4, no iteration is required as the last element is already sorted<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>0<\/td><td>1<\/td><td>2<\/td><td>3<\/td><td>4<\/td><\/tr><tr><td>10<\/td><td>11<\/td><td>16<\/td><td>20<\/td><td>23<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"selection-sort-time-complexity\"><strong>Selection sort Time Complexity<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In the worst case, in every iteration, we have to traverse the entire array for finding min elements and this will continue for all n elements. Hence this will perform n^2 operations in total.\u00a0<\/li>\n\n\n\n<li>In the best case that is sorted array, we can do some modification by using lag to check whether the lament is already sorted or not<\/li>\n\n\n\n<li>Best Time Complexity: O(n)<\/li>\n\n\n\n<li>Average Time Complexity: O(n^2)<\/li>\n\n\n\n<li>Worst Time Complexity: O(n^2)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"selection-sort-space-complexity\"><strong>Selection sort Space Complexity<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>No auxiliary space is required in Selection Sort implementation that is we are not using any arrays, linked list, stack, queue, etc to store our elements<\/li>\n\n\n\n<li>Hence space complexity is: O(1)<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"selection-sort-in-c\"><strong>Selection sort in C&nbsp;<\/strong><br><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n\nvoid swap(int *a, int *b) {\n  int tmp = *a;\n  *a = *b;\n  *b = tmp;\n}\n\n\/\/selection sort function\nvoid selectionSort(int arr&#91;], int n) {\n  for (int j = 0; j&lt; n - 1; j++) {\n    int min = j;\n    for (int i = j + 1; i &lt; n; i++) {\n\n      if (arr&#91;i] &lt; arr&#91;min])\n        min = i;\n    }\n\n    swap(&amp;arr&#91;min], &amp;arr&#91;j]);\n  }\n}\n\nvoid display(int arr&#91;], int n) {\n  for (int i = 0; i &lt; n; ++i) {\n    printf(\"%d  \", arr&#91;i]);\n  }\n  printf(\"\\n\");\n}\n\nint main() {\n  int arr&#91;] = {20, 12, 10, 15, 2};\n  int n = sizeof(arr) \/ sizeof(arr&#91;0]);\n  printf(\"Elements before sorting: \\n\");\n  selectionSort(arr, n);\n  printf(\"Elements after sorting:\\n\");\n  display(arr, n);\n}\n\n\n\n\n\n\nOutput of the program:\nElements before sorting:\n2  12  10  15  20  \n\nElements after sorting:\n2  12  10  15  20  \n\n\n\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"selection-sort-in-java\"><strong>Selection sort in Java<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>class SelectionSort {\n \/\/selection sort function\n void selectionSort(int arr&#91;]) {\n    int size = arr.length;\n\n    for (int j = 0; j &lt; size - 1; j++) {\n      int min = j;\n\n      for (int i = j + 1; i &lt; size; i++) {\n\n           if(arr&#91;i]&lt;arr&#91;min])\n                min = i;\n        \n      }\n\n      int tmp = arr&#91;j];\n      arr&#91;j] = arr&#91;min];\n      arr&#91;min] = tmp;\n    }\n }\n  \n  \/\/ method for printing the elements \n  void display(int arr&#91;]) {\n     int size = arr.length;\n\t for (int i = 0; i &lt; size; i++)\n\t\tSystem.out.print(arr&#91;i]+\" \");\n\tSystem.out.println();\n\t\n   }\n\n  public static void main(String args&#91;]) {\n    int&#91;] arr = { 20, 12, 10, 15, 2 };\n    SelectionSort ss = new SelectionSort();\n    System.out.println(\"Elements after sorting: \");\n    ss.display(arr);\n    ss.selectionSort(arr);\n    System.out.println(\"Elements before sorting: \");\n    ss.display(arr);\n  }\n}\n\n\n\n\nOutput of the program:\nElements before sorting:\n2  12  10  15  20  \n\nElements after sorting:\n2  12  10  15  20  \n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"selection-sort-in-c\"><strong>Selection sort in C++&nbsp;<\/strong><br><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\nvoid swap(int *a, int *b) {\n  int temp = *a;\n  *a = *b;\n  *b = temp;\n}\n\nvoid display(int arr&#91;], int n) {\n  for (int i = 0; i &lt; n; i++) {\n    cout &lt;&lt; arr&#91;i] &lt;&lt; \" \";\n  }\n  cout &lt;&lt; endl;\n}\n\n\/\/selection sort function\nvoid selectionSort(int arr&#91;], int n) {\n  for (int j = 0; j &lt; n - 1; j++) {\n    int min = j;\n    for (int i = j + 1; i &lt; n; i++) {\n\n      if (arr&#91;i] &lt; arr&#91;min])\n        min = i;\n    }\n\n    swap(&amp;arr&#91;min], &amp;arr&#91;j]);\n  }\n}\n\nint main() {\n  int arr&#91;] = {20, 12, 10, 15, 2};\n  int n = sizeof(arr) \/ sizeof(arr&#91;0]);\n  cout &lt;&lt; \"Elements before sorting:\\n\";\n  display(arr, n);\n  selectionSort(arr, n);\n  cout &lt;&lt; \"Elements after sorting:\\n\";\n  display(arr, n);\n}\n\n\n\n\nOutput of the program:\nElements before sorting:\n2  12  10  15  20  \n\nElements after sorting:\n2  12  10  15  20  \n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"selection-sort-in-python\"><strong>Selection sort in Python<\/strong><br><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/selection sort function\ndef selectionSort(arr, n):\n   \n    for stp in range(n):\n        min = stp\n\n        for i in range(stp + 1, n):\n         \n            if arr&#91;i] &lt; arr&#91;min]:\n                min = i\n         \n        (arr&#91;stp], arr&#91;min]) = (arr&#91;min], arr&#91;stp])\n\n\narr = &#91;-2, 45, 0, 11, -9]\nn = len(arr)\nprint('Elements before sorting:')\nprint(arr)\nselectionSort(arr, n)\nprint('Elements after sorting:')\nprint(arr)\n\n\nOutput of the program:\nElements before sorting:\n2  12  10  15  20  \n\nElements after sorting:\n2  12  10  15  20  \n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"selection-sort-example\"><strong>Selection Sort Example<\/strong><br><\/h2>\n\n\n\n<p><strong>Example1<\/strong><\/p>\n\n\n\n<p>Find kth smallest element in the array<\/p>\n\n\n\n<p>Input<\/p>\n\n\n\n<p>5<\/p>\n\n\n\n<p>12 45 17 99 34&nbsp;<\/p>\n\n\n\n<p>2<br><\/p>\n\n\n\n<p>Output<\/p>\n\n\n\n<p>17<br><\/p>\n\n\n\n<p><strong>JAVA Code<\/strong><br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.*;\n\nclass Solution {\n  \/\/selection sort function\n static void findKSmallest(int arr&#91;],int n,int k) {\n    if(k&gt;n){\n        System.out.println(\"No such element possible\");\n        return;        \n    }\n    \n    for (int j = 0; j &lt; k ; j++) {\n      int min = j;\n\n      for (int i = j + 1; i &lt; n; i++) {\n\n           if(arr&#91;i]&lt;arr&#91;min])\n                min = i;\n        \n      }\n\n      int tmp = arr&#91;j];\n      arr&#91;j] = arr&#91;min];\n      arr&#91;min] = tmp;\n    }\n    System.out.println(\"answer is : \"+arr&#91;k-1]);\n }\n\n  public static void main(String args&#91;]) {\n    Scanner in=new Scanner(System.in);\n    int n=in.nextInt();\n    int&#91;] arr=new int&#91;n];\n    for(int i=0;i&lt;n;i++)\n        arr&#91;i]=in.nextInt();\n    int k=in.nextInt();\n    findKSmallest(arr,n,k);\n  }\n}\n<\/code><\/pre>\n\n\n\n<p><strong>C++ code<\/strong><br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\nvoid swap(int *a, int *b) {\n  int temp = *a;\n  *a = *b;\n  *b = temp;\n}\n\n\/\/selection sort function\nvoid findKSmallest(int arr&#91;], int n, int k) {\n if(k&gt;n){\n      printf(\"No such element possible\");\n      return;\n  }\n  for (int j = 0; j &lt; k; j++) {\n    int min = j;\n    for (int i = j + 1; i &lt; n; i++) {\n\n      if (arr&#91;i] &lt; arr&#91;min])\n        min = i;\n    }\n\n    swap(&amp;arr&#91;min], &amp;arr&#91;j]);\n  }\n  \n  cout&lt;&lt;arr&#91;k-1];\n}\n\nint main() {\n  int n,k;\n  cin&gt;&gt;n;\n  int arr&#91;n];\n  for(int i=0;i&lt;n;i++)\n    cin&gt;&gt;arr&#91;i];\n  cin&gt;&gt;k;\n  findKSmallest(arr,n,k);\n}\n\n<\/code><\/pre>\n\n\n\n<p><strong>C Code<\/strong><br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\n\nvoid swap(int *a, int *b) {\n  int tmp = *a;\n  *a = *b;\n  *b = tmp;\n}\n\n\/\/selection sort function\nvoid findKSmallest(int arr&#91;], int n, int k) {\n  if(k&gt;n){\n      printf(\"No such element possible\");\n      return;\n  }\n  for (int j = 0; j&lt; k; j++) {\n    int min = j;\n    for (int i = j + 1; i &lt; n; i++) {\n\n      if (arr&#91;i] &lt; arr&#91;min])\n        min = i;\n    }\n\n    swap(&amp;arr&#91;min], &amp;arr&#91;j]);\n  }\n  printf(\"answer is %d\",arr&#91;k-1]);\n\n}\n\n\n\nint main() {\n  int n,k;\n  scanf(\"%d\",&amp;n);\n  int arr&#91;n];\n  for(int i=0; i&lt;n; i++)\n      scanf(\"%d\",&amp;arr&#91;i]);\n  scanf(\"%d\",&amp;k);\n\n  findKSmallest(arr, n ,k);\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"selection-sort-vs-bubble-sort-vs-insertion-sort\"><strong>Selection sort vs Bubble sort vs Insertion sort<\/strong><br><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>In terms of algorithm<\/strong>\n<ul class=\"wp-block-list\">\n<li>In Insertion sort, adjacent elements are compared and sorted if they are in the wrong order.<\/li>\n\n\n\n<li>In the Selection Sort, we select the smallest element and swap it with the 0th index element in the first iteration. This selection continues for n-1 elements and the single element is already sorted and we will have array sorted by 1 element in every iteration<\/li>\n\n\n\n<li>In Insertion sort, we create partitions of sorted and unsorted parts. One by one element from the sorted art is taken and sent to the unsorted part for checking and placing it to the right position in sorting using swaps.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>In terms of time and space complexity<\/strong>\n<ul class=\"wp-block-list\">\n<li>All 3 sorts have O(n2) time complexity. But via flag variables we can reduce the time complexity of Insertion and insertion to O(n) is the best case.<\/li>\n\n\n\n<li>Space Complexity is the same for all i.e., O(1)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><br><\/td><td><strong>Best<\/strong><\/td><td><strong>Average<\/strong><\/td><td><strong>Worst<\/strong><\/td><td><strong>Space<\/strong><\/td><\/tr><tr><td><strong>Selection<\/strong><\/td><td>O(n2)<\/td><td>O(n2)<\/td><td>O(n2)<\/td><td>O(1)<\/td><\/tr><tr><td><strong>Bubble<\/strong><\/td><td>O(n)<\/td><td>O(n2)<\/td><td>O(n2)<\/td><td>O(1)<\/td><\/tr><tr><td><strong>Insertion<\/strong><\/td><td>O(n)<\/td><td>O(n2)<\/td><td>O(n2)<\/td><td>O(1)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>In terms of speed<\/strong>\n<ul class=\"wp-block-list\">\n<li>Insertion sort may work best with an already sorted array and there is no need for any extra flag.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>In terms of in-place<\/strong>\n<ul class=\"wp-block-list\">\n<li>In-place states that the algorithm is in-place if it does not need extra memory barring some variable creation which counts to constant space.<\/li>\n\n\n\n<li>Selection, Insertion, and Insertion are in-place algorithms and do not require any auxiliary memory.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>In terms of stability<\/strong>\n<ul class=\"wp-block-list\">\n<li>Stability states that the algorithm is stable if the relative ordering of the same elements in the input and output array remains the same.<\/li>\n\n\n\n<li>Insertion and Insertion are stable algorithms but the naive selection is not as swapping may cost stability.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Selection<\/strong><\/td><td><strong>Bubble<\/strong><\/td><td><strong>Insertion<\/strong><\/td><\/tr><tr><td>Select smallest in every iteration do single swap<\/td><td>The adjacent swap of every element with the other element where ordering is incorrect<\/td><td>Take and put the element one by one and put it in the right place in the sorted part.<\/td><\/tr><tr><td>Best case time complexity is O(n2)<\/td><td>Best case time complexity is O(n)<\/td><td>Best case time complexity is O(n)<\/td><\/tr><tr><td>Works better than Insertion as no of swaps are significantly low<\/td><td>Worst efficiency as too many swaps are required in comparison to selection and insertion<\/td><td>Works better than Insertion as no of swaps are significantly low<\/td><\/tr><tr><td>It is in-place<\/td><td>It is in-place<\/td><td>It is in-place<\/td><\/tr><tr><td>Not stable<\/td><td>Stable<\/td><td>Stable<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Selection Sdort Selection Sort Pseudocode Selection sort Algorithm Selection sort Algorithm Dry Run Input: 0 1 2 3 4 23 10 16 11 20 First step - marking of sorted part 0 1 2 3 4 10 23 16 11 20 After i=1 0 1 2 3 4 10 11 16 23 20 [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":17450,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[36858],"content_type":[],"class_list":["post-17355","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-sorting-algorithm"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Selection Sort Algorithm in C, in Java, in C++, in Python &amp; Examples<\/title>\n<meta name=\"description\" content=\"Selection Sort Algorithm: Let&#039;s know a detailed tutorial on selection sort algorithm and covers C, C++, Java, and Python codes for selection and sort.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Selection Sort Algorithm in C, in Java, in C++, in Python &amp; Examples\" \/>\n<meta property=\"og:description\" content=\"Selection Sort Algorithm: Let&#039;s know a detailed tutorial on selection sort algorithm and covers C, C++, Java, and Python codes for selection and sort.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-22T12:49:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-03T05:54:43+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Blog-Featured-image-set-july-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"700\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Great Learning Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Great_Learning\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Great Learning Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/selection-sort-algorithm\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/selection-sort-algorithm\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"Selection Sort Algorithm in C, in Java, in C++, in Python &#038; Examples\",\"datePublished\":\"2020-07-22T12:49:40+00:00\",\"dateModified\":\"2024-09-03T05:54:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/selection-sort-algorithm\\\/\"},\"wordCount\":767,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/selection-sort-algorithm\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/Blog-Featured-image-set-july-1.jpg\",\"keywords\":[\"sorting algorithm\"],\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/selection-sort-algorithm\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/selection-sort-algorithm\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/selection-sort-algorithm\\\/\",\"name\":\"Selection Sort Algorithm in C, in Java, in C++, in Python & Examples\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/selection-sort-algorithm\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/selection-sort-algorithm\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/Blog-Featured-image-set-july-1.jpg\",\"datePublished\":\"2020-07-22T12:49:40+00:00\",\"dateModified\":\"2024-09-03T05:54:43+00:00\",\"description\":\"Selection Sort Algorithm: Let's know a detailed tutorial on selection sort algorithm and covers C, C++, Java, and Python codes for selection and sort.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/selection-sort-algorithm\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/selection-sort-algorithm\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/selection-sort-algorithm\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/Blog-Featured-image-set-july-1.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/Blog-Featured-image-set-july-1.jpg\",\"width\":1000,\"height\":700,\"caption\":\"SelectionSort_GL\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/selection-sort-algorithm\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"IT\\\/Software Development\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/software\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Selection Sort Algorithm in C, in Java, in C++, in Python &#038; Examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Selection Sort Algorithm in C, in Java, in C++, in Python & Examples","description":"Selection Sort Algorithm: Let's know a detailed tutorial on selection sort algorithm and covers C, C++, Java, and Python codes for selection and sort.","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:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/","og_locale":"en_US","og_type":"article","og_title":"Selection Sort Algorithm in C, in Java, in C++, in Python & Examples","og_description":"Selection Sort Algorithm: Let's know a detailed tutorial on selection sort algorithm and covers C, C++, Java, and Python codes for selection and sort.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","article_published_time":"2020-07-22T12:49:40+00:00","article_modified_time":"2024-09-03T05:54:43+00:00","og_image":[{"width":1000,"height":700,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Blog-Featured-image-set-july-1.jpg","type":"image\/jpeg"}],"author":"Great Learning Editorial Team","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/Great_Learning","twitter_site":"@Great_Learning","twitter_misc":{"Written by":"Great Learning Editorial Team","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"Selection Sort Algorithm in C, in Java, in C++, in Python &#038; Examples","datePublished":"2020-07-22T12:49:40+00:00","dateModified":"2024-09-03T05:54:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/"},"wordCount":767,"commentCount":0,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Blog-Featured-image-set-july-1.jpg","keywords":["sorting algorithm"],"articleSection":["IT\/Software Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/","url":"https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/","name":"Selection Sort Algorithm in C, in Java, in C++, in Python & Examples","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Blog-Featured-image-set-july-1.jpg","datePublished":"2020-07-22T12:49:40+00:00","dateModified":"2024-09-03T05:54:43+00:00","description":"Selection Sort Algorithm: Let's know a detailed tutorial on selection sort algorithm and covers C, C++, Java, and Python codes for selection and sort.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Blog-Featured-image-set-july-1.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Blog-Featured-image-set-july-1.jpg","width":1000,"height":700,"caption":"SelectionSort_GL"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/selection-sort-algorithm\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"IT\/Software Development","item":"https:\/\/www.mygreatlearning.com\/blog\/software\/"},{"@type":"ListItem","position":3,"name":"Selection Sort Algorithm in C, in Java, in C++, in Python &#038; Examples"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Blog-Featured-image-set-july-1.jpg",1000,700,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Blog-Featured-image-set-july-1-150x150.jpg",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Blog-Featured-image-set-july-1-300x210.jpg",300,210,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Blog-Featured-image-set-july-1-768x538.jpg",768,538,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Blog-Featured-image-set-july-1.jpg",1000,700,false],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Blog-Featured-image-set-july-1.jpg",1000,700,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Blog-Featured-image-set-july-1.jpg",1000,700,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Blog-Featured-image-set-july-1.jpg",640,448,false],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Blog-Featured-image-set-july-1.jpg",96,67,false],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Blog-Featured-image-set-july-1.jpg",150,105,false]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"What is Selection Sdort Selection Sort Pseudocode Selection sort Algorithm Selection sort Algorithm Dry Run Input: 0 1 2 3 4 23 10 16 11 20 First step - marking of sorted part 0 1 2 3 4 10 23 16 11 20 After i=1 0 1 2 3 4 10 11 16 23 20&hellip;","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/17355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=17355"}],"version-history":[{"count":8,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/17355\/revisions"}],"predecessor-version":[{"id":104931,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/17355\/revisions\/104931"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/17450"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=17355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=17355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=17355"},{"taxonomy":"content_type","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/content_type?post=17355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}