<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>sorting on seth-shi</title><link>https://sethix.com/tags/sorting/</link><description>Recent content in sorting on seth-shi</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Fri, 29 Jan 2021 15:24:18 +0800</lastBuildDate><atom:link href="https://sethix.com/tags/sorting/index.xml" rel="self" type="application/rss+xml"/><item><title>I Have a Technique Called Quick Sort</title><link>https://sethix.com/posts/2021012915/</link><pubDate>Fri, 29 Jan 2021 15:24:18 +0800</pubDate><guid>https://sethix.com/posts/2021012915/</guid><description>Recently while solving a problem on LeetCode (finding the kth largest number), I needed to sort an array. Realized I only knew basic sorting algorithms like Bubble Sort and Insertion Sort. Then I reviewed Quick Sort through animated examples online, and implemented my own version (code is similar to common implementations): // 1. Select a pivot element (can choose the first element or random element) // 2. Use two pointers starting from both ends, right pointer moves first // 3.</description></item><item><title>Sorting Algorithm - Bucket Sort</title><link>https://sethix.com/posts/2020060709/</link><pubDate>Sun, 07 Jun 2020 09:28:23 +0800</pubDate><guid>https://sethix.com/posts/2020060709/</guid><description>Bucket Sort is well-suited for sorting numbers in the range of 0~100, but its efficiency decreases when dealing with data that has a wide value range.
Algorithm Steps Create n empty buckets based on requirements Traverse the input array to find the maximum and minimum values For each element num, calculate bucket index using formula: floor((num - min) / n) If a bucket already contains elements, maintain elements in sorted order (using linked list) Repeat steps 3-4 until all elements are distributed Concatenate all buckets&amp;rsquo; linked lists and output the sorted array package main import ( &amp;#34;fmt&amp;#34; &amp;#34;math&amp;#34; ) func main() { data := []int{111, 9, 2, 4, 9, 3, 3, 5, 7, 1, 8, 2, 11, 22, 99, 192} fmt.</description></item></channel></rss>