Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2K views7 pages

Sorting Algorithms - GeeksforGeeks

The document provides an overview of sorting algorithms, detailing their definitions, types, and applications. It categorizes sorting algorithms into comparison-based, non-comparison-based, and hybrid types, and lists various library implementations across programming languages. Additionally, it includes practice problems categorized by difficulty levels to help users improve their sorting algorithm skills.

Uploaded by

Chen Feng
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
2K views7 pages

Sorting Algorithms - GeeksforGeeks

The document provides an overview of sorting algorithms, detailing their definitions, types, and applications. It categorizes sorting algorithms into comparison-based, non-comparison-based, and hybrid types, and lists various library implementations across programming languages. Additionally, it includes practice problems categorized by difficulty levels to help users improve their sorting algorithm skills.

Uploaded by

Chen Feng
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 7

Courses Tutorials DSA Data Science Web Tech Sign In

DSA Practice Sorting MCQs on Sorting Tutorial on Sorting Bubble Sort Quick Sort Merge Sort Insertion Sort Selection Sort

Next Article: Sorting Algorithms


Introduction Last Updated : 10 Jan, 2025
to Sorting
Techniques
A Sorting Algorithm is used to
– Data
Structure rearrange a given array or list of
and elements in an order. Sorting is
Algorithm provided in library implementation of
Tutorials
most of the programming languages.

Basics of Sorting
Algorithms:
Introduction to Sorting
Applications of Sorting

Sorting Algorithms:
Comparison Based : Selection Sort,
Bubble Sort, Insertion Sort, Merge
Sort, Quick Sort, Heap Sort, Cycle
Sort, 3-way Merge Sort
Non Comparison Based : Counting
Sort, Radix Sort, Bucket Sort, TimSort,
Comb Sort, Pigeonhole Sort
Hybrid Sorting Algorithms : IntroSort,
Tim Sort

Library Implementations:

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understo

https://www.geeksforgeeks.org/sorting-algorithms/?ref=shm 3/19/25, 2 59 PM
Page 1 of 7
:
qsort() in C
sort() in C++ STL
Arrays.sort() in Java with examples
Collections.sort() in Java with
Examples
Sort a List in Python
Sorting in JavaScript

Easy Problems on Sorting:


Check if an array is Sorted
Sort an array of two types
Sort a String
Sort Each Row of a Matrix
Sort a Matrix
Sort a Linked List
Sort in Wave Form
Sort by Frequency
Sort from Different Machines
Check if any two intervals overlap
Missing elements of a range
Sort by set bits counts
Sort even and odd placed in
different orders
Sorting Big Integers
Sort strings by lengths
Merge Two Sorted Arrays
Sort when two halves are sorted
2 Sum - Pair in a Sorted Array
Intersection of two sorted arrays
Union of two sorted arrays
Meeting Rooms

Medium Problems on
Sorting:
Minimum Increments to Make

https://www.geeksforgeeks.org/sorting-algorithms/?ref=shm 3/19/25, 2 59 PM
Page 2 of 7
:
Unique
Merge Overlapping Intervals
Minimum Platforms
Closest Pair of Elements
Closest Pair of Points
Chocolate Distribution Problem
Min and Max Amount to Buy All
Three Way Partitioning
Sort an array of 0s, 1s and 2s
Sort a linked list of 0s, 1s and 2s
Inversion count
K-th Smallest Element
K Smallest Elements
3 Sum - Find Any
3 Sum - Closest Triplet
Smallest Difference Triplet from
Three arrays
Merge K Sorted Arrays
Merge K Sorted Linked Lists
Min Unsorted Subarray to make
array sorted
Sort a nearly sorted array
Sort n numbers in range from 0 to
n^2 – 1
Sort an array of 1 to n
Sort according to order defined by
another
Maximum intervals overlap
Permutation with worst Case of
Merge Sort
Minimum swaps to make two arrays
identical
Permute two arrays such that all
pair suns are greater than K
Bucket Sort To Sort an Array with
Negative Numbers
Convert an Array to reduced form

https://www.geeksforgeeks.org/sorting-algorithms/?ref=shm 3/19/25, 2 59 PM
Page 3 of 7
:
Convert an Array to reduced form
using Vector of pairs
Check if array can be sorted with
conditional swapping of adjacent
4 Sum - Find Any [More problems
an 4 Sum are in Hard Section]

Hard Problems on Sorting:


Merge Without Extra Space
Top K Frequent Elements
3 Sum - Distinct Triplets
4 Sum - Distinct Quadruples
4 Sum - All Quadruples
4 Sum - Closest Quadruple
Surpasser Counts in an Array
Count distinct occurrences as a
subsequence
Minimum consecutive number
subsets
Minimum swaps for Binary Tree to
BST
K-th smallest element after
removing some integers from
natural numbers
Max frequency diff such greater

freq item is also is also greater


Min swaps to reach permuted array
with at most 2 positions left swaps
allowed
Making Array Elements Same
Sort an array after applying an
equation
Array of strings in sorted order
without copying strings

Quick Links :

https://www.geeksforgeeks.org/sorting-algorithms/?ref=shm 3/19/25, 2 59 PM
Page 4 of 7
:
‘Practice Problems’ on Sorting
‘Quizzes’ on Sorting

Recommended:

Learn Data Structure and


Algorithms | DSA Tutorial

Comment Next Article


Introduction to
Sorting
More info
Techniques –
Data Structure
Advertise with us and Algorithm
Tutorials

Similar Reads

Sorting Algorithms
A Sorting Algorithm is used to rearrange a given
array or list of elements in an order. Sorting is
provided in library implementation of most of the
3 min read languages. Basics of Sorting
programming
Algorithms:Introduction to Sorting Applications of
Introduction to Sorting Techniques
Sorting Sorting Algorithms:Comparison –:
Based
Selection Sor
Data
SortingStructure and Algorithm
refers to rearrangement Tutorials
of a given array or
list of elements according to a comparison
operator on the elements. The comparison
3 minisread
operator used to decide the new order of
elements in the respective data structure. Why
Sorting Algorithms are ImportantThe sorting
Most Common
algorithm Sorting
is important Algorithms
in Com

Selection Sort
Selection Sort is a comparison-based sorting
algorithm. It sorts an array by repeatedly selecting
the smallest (or largest) element from the
8 min portion
unsorted read and swapping it with the first
unsorted element. This process continues until the
entire array is sorted. First we find the smallest
element a

https://www.geeksforgeeks.org/sorting-algorithms/?ref=shm 3/19/25, 2 59 PM
Page 5 of 7
:
Bubble Sort Algorithm
Bubble Sort is the simplest sorting algorithm that
works by repeatedly swapping the adjacent
elements if they are in the wrong order. This
8 min read
algorithm is not suitable for large data sets as its
average and worst-case time complexity are quite
Insertion
high. We sort Sort
the Algorithm
array using multiple passes.
After the fi
Insertion sort is a simple sorting algorithm that
works by iteratively inserting each element of an
unsorted list into its correct position in a sorted
9 min
portion ofread
the list. It is like sorting playing cards in
your hands. You split the cards into two groups:
Merge Sort
the sorted - Data
cards and theStructure
unsortedand
cards. T
Algorithms Tutorials
Merge sort is a sorting algorithm that follows the
divide-and-conquer approach. It works by
recursively dividing the input array into smaller
15 min and
subarrays readsorting those subarrays then
merging them back together to obtain the sorted
QuickInSort
array. simple terms, we can say that the process
of merge sort i
QuickSort is a sorting algorithm based on the
Divide and Conquer that picks an element as a
pivot and partitions the given array around the
13 min
picked read
pivot by placing the pivot in its correct
position in the sorted array. Table of Content How
Heap Sort - Data
does QuickSort Structures
Algorithm and of
work? Working
Partition Algorith
Algorithms
Heap sort is a Tutorials
comparison-based sorting technique
based on Binary Heap Data Structure. It can be
seen as an optimization over selection sort where
14 min
we first read
find the max (or min) element and swap it
with the last (or first). We repeat the same process
Counting
for Sort elements.
the remaining - Data Structures and
In Heap Sort, we use
Algorithms
Counting Sort Tutorials
is a non-comparison-based sorting
algorithm. It is particularly efficient when the range
of input values is small compared to the number of
9 min read
elements to be sorted. The basic idea behind
Counting Sort is to count the frequency of each
distinct element in the input array and use that info

https://www.geeksforgeeks.org/sorting-algorithms/?ref=shm 3/19/25, 2 59 PM
Page 6 of 7
:
Company Languages DSA Data Web Python
About Us Python Data Science & Technologies Tutorial
Corporate & Legal Java Structures HTML Python
Communications ML
Address: Privacy C++ Algorithms CSS Programming
Data Science
A-143, 7th Floor, Policy PHP DSA for JavaScript Examples
With Python
Sovereign Corporate In Media GoLang Beginners TypeScript Python
Data Science
Tower, Sector- 136, Contact Us SQL Basic DSA
For Beginner ReactJS Projects
Noida, Uttar Pradesh
Advertise R Language Problems NextJS Python
(201305) Machine
with us Android DSA Bootstrap Tkinter
Learning
GFG Tutorial Roadmap Web Design Web
Registered Address: ML Maths
Corporate Tutorials Top 100 DSA Scraping
K 061, Tower K, Gulshan Data
Vivante Apartment, Solution Archive Interview OpenCV
Sector 137, Noida, Visualisation
Placement Problems Tutorial
Gautam Buddh Nagar, Pandas
Uttar Pradesh, 201305 Training DSA Python
NumPy
Program Roadmap by Interview
NLP
GeeksforGeeks Sandeep Question
Deep
Community Jain Django
Learning
All Cheat
Sheets

Computer DevOps System Inteview School GeeksforGeeks


Science Git Design Preparation Subjects Videos
Advertise with us
Operating Linux High Level Competitive Mathematics DSA
Systems AWS Design Programming Physics Python
Computer Docker Low Level Top DS or Chemistry Java
Network Kubernetes Design Algo for CP Biology C++
Database Azure UML Company- Social Web
Management GCP Diagrams Wise Science Development
System DevOps Interview Recruitment English Data Science
So!ware Roadmap Guide Process Grammar CS Subjects
Engineering Design Company- Commerce
Digital Logic Patterns Wise World GK
Design OOAD Preparation
Engineering System Aptitude
Maths Design Preparation
So!ware Bootcamp Puzzles
Development Interview
So!ware Questions
Testing

@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

https://www.geeksforgeeks.org/sorting-algorithms/?ref=shm 3/19/25, 2 59 PM
Page 7 of 7
:

You might also like