{"id":20704,"date":"2020-08-02T14:38:55","date_gmt":"2020-08-02T21:38:55","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=20704"},"modified":"2023-12-01T03:57:17","modified_gmt":"2023-12-01T11:57:17","slug":"java-quicksort","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/java-quicksort\/","title":{"rendered":"Java Quicksort: A Beginner\u2019s Guide"},"content":{"rendered":"\n<p>It can be difficult to wrap your head around the quicksort sorting algorithm. It\u2019s not as intuitive as other sorts like an insertion sort or a bubble sort.<br><\/p>\n\n\n\n<p>Quicksorts are an efficient way of sorting smaller lists. In this guide, we\u2019re going to talk about how to build a quicksort in <a href=\"https:\/\/careerkarma.com\/blog\/how-to-code-in-java\/\">Java<\/a>. We\u2019ll walk through an example quicksort to get you started.<br><\/p>\n\n\n\n<p>Without further ado, let\u2019s begin!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is a Java Quicksort?<\/h2>\n\n\n\n<p>A quicksort is a sorting algorithm that devices an <a href=\"https:\/\/careerkarma.com\/blog\/java-array\/\">array<\/a> into subarrays which are recursively called to sort each element in the list.<br><\/p>\n\n\n\n<p>Slow down! In a quicksort, we start by selecting a number called a pivot. We compare this pivot number to every number in the list.<br><\/p>\n\n\n\n<p>If an item is greater than the pivot, it is moved to the right of the pivot; otherwise, it is moved to the left. Then, all the items greater than and lesser than the pivot are divided into two lists. The sorting algorithm repeats until every item has been the pivot at least one time.<br><\/p>\n\n\n\n<p>The quicksort is more advanced than other sorts. It\u2019s best to try out this sort only if you have a good understanding of recursion and more basic sorting algorithms.&nbsp;<br><\/p>\n\n\n\n<p>The quick sort is more efficient than a merge sort when sorting smaller arrays. On larger arrays, a merge sort is more efficient.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Does a Quicksort Work?<\/h2>\n\n\n\n<p>We can\u2019t begin to write a Java quicksort without first walking through the algorithm. We\u2019ll take it step-by-step so that you can follow along.<br><\/p>\n\n\n\n<p>The first step in a quicksort is to select a pivot from an array. We\u2019re going to select the last item in a list as our pivot for convenience. The pivot can be any item in an array.<br><\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td>12<\/td><td>8<\/td><td>3<\/td><td>1<\/td><td>0<\/td><td><strong>5<\/strong><\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>5 is our pivot number.<br><\/p>\n\n\n\n<p>Then, the items smaller than the pivot are moved to the left of the pivot. The items greater than the pivot are moved to the right:<br><\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td>3<\/td><td>1<\/td><td>0<\/td><td><strong>5<\/strong><\/td><td>12<\/td><td>8<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>Next, we divide the list into two smaller lists. The items to the left of the pivot make one list. The items to the right of the pivot make another list. The pivot is sorted so it does not move down into a new list.<br><\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td>3<\/td><td>1<\/td><td>0<\/td><td><br><\/td><td>12<\/td><td>8<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>We perform the same process as above on both of these small lists until each is sorted. The numbers in bold are the pivot numbers.<br><\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td>Second Sort<\/td><td>3<\/td><td>1<\/td><td><strong>0<\/strong><\/td><td><br><\/td><td>12<\/td><td><strong>8<\/strong><\/td><\/tr><tr><td><br><\/td><td><strong>0<\/strong><\/td><td>3<\/td><td>1<\/td><td><br><\/td><td><strong>8<\/strong><\/td><td>12<\/td><\/tr><tr><td>Third Sort<\/td><td><br><\/td><td>3<\/td><td><strong>1<\/strong><\/td><td><br><\/td><td><br><\/td><td><strong>12<\/strong><\/td><\/tr><tr><td><br><\/td><td><br><\/td><td><strong>1<\/strong><\/td><td>3<\/td><td><br><\/td><td><br><\/td><td><br><\/td><\/tr><tr><td><br><\/td><td><br><\/td><td><br><\/td><td><strong>3<\/strong><\/td><td><br><\/td><td><br><\/td><td><br><\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>If we combine all of our values, we get a sorted list:<br><\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td>0<\/td><td>1<\/td><td>3<\/td><td>5<\/td><td>8<\/td><td>12<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>Our list has been successfully sorted!<br><\/p>\n\n\n\n<p>Quick sorts use a recursive algorithm. This is because each list is divided into sublists on which the same quicksort is performed. Because quicksorts use recursion, they use the divide-and-conquer approach to sort a list.<br><\/p>\n\n\n\n<p>The initial list is sorted based on the value of each number relative to the pivot number. Next, it is <strong>divided<\/strong> into subarrays. These subarrays are then subject to the same sorting algorithm using a recursive function. This is where the <strong>conquer<\/strong> step comes in.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Build a Java Quicksort<\/h2>\n\n\n\n<p>Now that you\u2019re familiar with how a quicksort works, we can discuss how to implement it in Java. We\u2019ll start by importing the Arrays library and defining a class for our code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.Arrays;\n\nclass QuickSort {\n}\n<\/pre><\/div>\n\n\n\n<p>The Arrays library allows us to print out the value of an array. Next, we\u2019re going to define a <a href=\"https:\/\/careerkarma.com\/blog\/java-methods\/\">function<\/a> called \u201cprepare\u201d. This function will move elements based on their value relative to the pivot. This process is called preparing, or partitioning, our data.<br><\/p>\n\n\n\n<p>Elements greater than the pivot will move to the right of the pivot. Elements less than the pivot will move to the left.<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>int prepare(int numbers[], int low, int high) {\n\tint pivot = numbers[high];\n\tint item = low - 1;\n\n\tfor (int i = low; i &lt; high; i++) {\n\t\tif (numbers[i] &lt;= pivot) {\n\t\t\titem++;\n\t\t\tint swap = numbers[item];\n\t\t\tnumbers[item] = numbers[i];\n\t\t\tnumbers[i] = swap;\n\t\t}\n\t}\n\n\tint swap = numbers[item + 1];\n\tnumbers[item + 1] = numbers[high];\n\tnumbers[high] = swap;\n\treturn (item + 1);\n}\n<\/pre><\/div>\n\n\n\n<p>We start by defining the pivot number. This number is equal to the last item in our list. Next, we use a <a href=\"https:\/\/careerkarma.com\/blog\/java-for-each-loops\/\">for loop<\/a> to iterate through every item in the \u201cnumbers\u201d list. If a number is lower than the pivot, it is moved after the pivot number. Otherwise, the number is moved before the pivot number.<br><\/p>\n\n\n\n<p>We\u2019re not done yet. This function only prepares our data. We\u2019ve still got to perform the actual sort. Let\u2019s define a new function for our sort:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>void sorting(int numbers[], int low, int high) {\n\tif (low &lt; high) {\n\t\tint pivot = prepare(numbers, low, high);\n\n\t\tsorting(numbers, low, pivot - 1);\n\t\tsorting(numbers, pivot + 1, high);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>As long as the value of \u201clow\u201d is less than \u201chigh\u201d, the contents of our sorting() method runs. This ensures that our sorting algorithm stops when our list is sorted.<br><\/p>\n\n\n\n<p>The <code>sorting()<\/code> function calls our <code>prepare()<\/code> function to prepare the array. Next, it calls itself again twice. The first time, sorting() is called to sort the lower half of the list. The second time, sorting() sorts the upper half of the list.<br><\/p>\n\n\n\n<p>This happens until every item in the list is sorted. Because the sorting() function calls itself, it is considered a recursive function.<br><\/p>\n\n\n\n<p>The final step is to write a main program that calls our sorting() function:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>public static void main(String args[]) {\n\tint[] numbers = { 12, 8, 3, 1, 0, 5 };\n\tint to_sort = numbers.length;\n\n\tQuickSort new_sort = new QuickSort();\n\tnew_sort.sorting(numbers, 0, to_sort - 1);\n\t\n\tSystem.out.println(Arrays.toString(numbers));\n}\n<\/pre><\/div>\n\n\n\n<p>We define a <a href=\"https:\/\/careerkarma.com\/blog\/java-variables\/\">variable<\/a> called \u201cnumbers\u201d which contains the list of numbers we want to sort. We use the .length method to calculate the length of this list. Next, we initialize a new instance of our QuickSort class. We then call the sorting() method to sort our list of numbers.<br><\/p>\n\n\n\n<p>The \u201cto_sort &#8211; 1\u201d is specified as the high value in the sorting() function. This is because lists are indexed from 0 and so we need to subtract one from the length of the list so that we don\u2019t try to sort a value that does not exist.<br><\/p>\n\n\n\n<p>Next, we print the sorted array to the console. The <code>Arrays.toString()<\/code> method converts the value of \u201cnumbers\u201d into a string that Java can print to the console.<br><\/p>\n\n\n\n<p>Let\u2019s run our code altogether:<br><\/p>\n\n\n\n<p><code>[0, 1, 3, 5, 8, 12]<br><\/code><\/p>\n\n\n\n<p>Our list has been sorted!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Complexity Review<\/h2>\n\n\n\n<p>We&#8217;re not done yet. We have to review the complexity of the quicksort algorithm before concluding. In the best and average cases, the quicksort performs at O(n*log n). <\/p>\n\n\n\n<p>In the worst case, the quicksort performs at O(n^2). This happens when the pivot element is either the largest or smallest item in a list. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The quicksort algorithm is an efficient method at sorting lists. While it does not outperform the merge sort on larger lists, it is powerful when used on smaller lists.<br><\/p>\n\n\n\n<p>Quicksorts are implemented using a recursive function. This is a function that calls itself repeatedly until a problem has been solved.<br>Now you\u2019re ready to implement a quicksort algorithm in <a href=\"https:\/\/careerkarma.com\/blog\/java-frameworks\/\">Java like an expert<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"It can be difficult to wrap your head around the quicksort sorting algorithm. It\u2019s not as intuitive as other sorts like an insertion sort or a bubble sort. Quicksorts are an efficient way of sorting smaller lists. In this guide, we\u2019re going to talk about how to build a quicksort in Java. We\u2019ll walk through&hellip;","protected":false},"author":240,"featured_media":20705,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17289],"tags":[],"class_list":{"0":"post-20704","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-java"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Java","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Java Quicksort: A Beginner\u2019s Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"A quicksort is a divide and conquer algorithm that sorts a list of values. On Career Karma, learn how to implement a Java quicksort.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/java-quicksort\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Quicksort: A Beginner\u2019s Guide\" \/>\n<meta property=\"og:description\" content=\"A quicksort is a divide and conquer algorithm that sorts a list of values. On Career Karma, learn how to implement a Java quicksort.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/java-quicksort\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-02T21:38:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T11:57:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/ern-gan-zXpWDBnO3wk-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"667\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-quicksort\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-quicksort\\\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Java Quicksort: A Beginner\u2019s Guide\",\"datePublished\":\"2020-08-02T21:38:55+00:00\",\"dateModified\":\"2023-12-01T11:57:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-quicksort\\\/\"},\"wordCount\":1070,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-quicksort\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/ern-gan-zXpWDBnO3wk-unsplash.jpg\",\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-quicksort\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-quicksort\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-quicksort\\\/\",\"name\":\"Java Quicksort: A Beginner\u2019s Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-quicksort\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-quicksort\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/ern-gan-zXpWDBnO3wk-unsplash.jpg\",\"datePublished\":\"2020-08-02T21:38:55+00:00\",\"dateModified\":\"2023-12-01T11:57:17+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"A quicksort is a divide and conquer algorithm that sorts a list of values. On Career Karma, learn how to implement a Java quicksort.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-quicksort\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-quicksort\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-quicksort\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/ern-gan-zXpWDBnO3wk-unsplash.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/ern-gan-zXpWDBnO3wk-unsplash.jpg\",\"width\":1000,\"height\":667},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-quicksort\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Java Quicksort: A Beginner\u2019s Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/author\\\/jamesgallagher\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Java Quicksort: A Beginner\u2019s Guide | Career Karma","description":"A quicksort is a divide and conquer algorithm that sorts a list of values. On Career Karma, learn how to implement a Java quicksort.","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:\/\/careerkarma.com\/blog\/java-quicksort\/","og_locale":"en_US","og_type":"article","og_title":"Java Quicksort: A Beginner\u2019s Guide","og_description":"A quicksort is a divide and conquer algorithm that sorts a list of values. On Career Karma, learn how to implement a Java quicksort.","og_url":"https:\/\/careerkarma.com\/blog\/java-quicksort\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-08-02T21:38:55+00:00","article_modified_time":"2023-12-01T11:57:17+00:00","og_image":[{"width":1000,"height":667,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/ern-gan-zXpWDBnO3wk-unsplash.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/java-quicksort\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/java-quicksort\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Java Quicksort: A Beginner\u2019s Guide","datePublished":"2020-08-02T21:38:55+00:00","dateModified":"2023-12-01T11:57:17+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-quicksort\/"},"wordCount":1070,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-quicksort\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/ern-gan-zXpWDBnO3wk-unsplash.jpg","articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/java-quicksort\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/java-quicksort\/","url":"https:\/\/careerkarma.com\/blog\/java-quicksort\/","name":"Java Quicksort: A Beginner\u2019s Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-quicksort\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-quicksort\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/ern-gan-zXpWDBnO3wk-unsplash.jpg","datePublished":"2020-08-02T21:38:55+00:00","dateModified":"2023-12-01T11:57:17+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"A quicksort is a divide and conquer algorithm that sorts a list of values. On Career Karma, learn how to implement a Java quicksort.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/java-quicksort\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/java-quicksort\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/java-quicksort\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/ern-gan-zXpWDBnO3wk-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/ern-gan-zXpWDBnO3wk-unsplash.jpg","width":1000,"height":667},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/java-quicksort\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/careerkarma.com\/blog\/java\/"},{"@type":"ListItem","position":3,"name":"Java Quicksort: A Beginner\u2019s Guide"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/20704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=20704"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/20704\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/20705"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=20704"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=20704"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=20704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}