Organizing elements in a specific order, often ascending or descending.
Problem Statement: Given a linked list, sort its nodes based on the data value in them. Return the head of the sorted linked list. Examples Input: 3->4->2->1->5 Output: 1->2->3->4->5 Explanation: T...
Problem Statement: Given an array of N integers, write a program to implement the Recursive Bubble Sort algorithm. Examples Example 1: Input: N = 6, array[] = {13,46,24,52,20,9} Output: 9,13,20,24,...
Problem Statement: Given an array of N integers, write a program to implement the Recursive Insertion Sort algorithm. Examples Example 1: Input: N = 6, array[] = {13,46,24,52,20,9} Output: 9,13,20,...
Problem Statement: Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. Examples Example 1: Input: nums = [1, 2,...
Problem Statement: Given an array of integers nums, sort the array in non-decreasing order using the heap sort algorithm. Sort the given array itself, there is no need to return anything. A sorted...
Bucket Sort : Detailed Explanation . You would wonder, why we need bucket sort even though we have sorting algorithms that work in O(nlogn). Bucket sort can be very useful when the data is uniforml...
Problem Statement: Given an array nums, return the kth largest element in the array. Examples Example 1: Input: nums = [1, 2, 3, 4, 5], k = 2 Output: 4 Explanation: The 2nd largest number in the li...
Problem Statement: Given an unsorted array of size n, sort the array using radix sort. Examples Input: arr[] = {326, 311, 3, 4, 120, 65} Output: {3, 4, 65, 120, 311, 326} Explanation: The array is...
Problem Statement: Given an array sort the elements of the array using count sort. Introduction to Count Sort Count sort is one of the non-comparison stable sorting algorithms which sorts elements...
Problem Statement: Given an array of length N consisting of only 0s and 1s in random order. Modify the array to segregate 0s on the left and 1s on the right side of the array. Examples Input : N =...