Skip to main content

43 docs tagged with "sorting"

View all tags

Accounts Merge

Solution for LeetCode 721: Accounts Merge, utilizing Graph Traversal and Disjoint Set Union (DSU) to group connected components.

Arrays - Bubble Sort in DSA

Bubble Sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted. The algorithm, which is a comparison sort, is named for the way smaller elements 'bubble' to the top of the list. Although the algorithm is simple, it is too slow and impractical for most problems even when compared to insertion sort. It can be practical if the input is usually in sort order but may occasionally have some out-of-order elements nearly in position.

Arrays - Bubble Sort in DSA

Bubble Sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted. The algorithm, which is a comparison sort, is named for the way smaller elements 'bubble' to the top of the list. Although the algorithm is simple, it is too slow and impractical for most problems even when compared to insertion sort. It can be practical if the input is usually in sort order but may occasionally have some out-of-order elements nearly in position.

Arrays - Circular Sort

Circular Sort (often called Cycle Sort) is an in-place sorting algorithm that minimizes memory writes by placing elements in their exact positions.

Arrays - Cyclic Sort

Cyclic Sort is an O(n) in-place sorting algorithm specifically designed for arrays containing numbers in a given continuous range (e.g., 1 to N).

Arrays - Heap Sort

Heap Sort is an efficient comparison-based sorting algorithm based on a binary heap data structure. It sorts by building a max-heap from the data and repeatedly extracting the maximum element.

Arrays - Heap Sort

Heap Sort is an efficient comparison-based sorting algorithm based on a binary heap data structure. It sorts by building a max-heap from the data and repeatedly extracting the maximum element.

Arrays - Insertion Sort

Insertion Sort is a simple sorting algorithm that builds the final sorted array one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort.

Arrays - Insertion Sort

Insertion Sort is a simple sorting algorithm that builds the final sorted array one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort.

Arrays - Merge Sort in DSA

Merge Sort is a divide-and-conquer sorting algorithm that divides the array into smaller subarrays, sorts them recursively, and then merges them back together in sorted order. It is a stable and efficient algorithm with $O(n log n)$ time complexity in all cases.

Arrays - Quick Sort

Quick Sort is a highly efficient and commonly used sorting algorithm that employs a divide-and-conquer strategy. It is well-suited for large datasets and typically outperforms other algorithms like insertion sort and bubble sort.

Arrays - Quick Sort

Quick Sort is a highly efficient and commonly used sorting algorithm that employs a divide-and-conquer strategy. It is well-suited for large datasets and typically outperforms other algorithms like insertion sort and bubble sort.

Arrays - Selection Sort in DSA

Selection Sort is an in-place comparison sorting algorithm that divides the input list into two parts: the sublist of items already sorted and the sublist of items remaining to be sorted. It repeatedly finds the minimum element from the unsorted part and puts it at the beginning of the unsorted part. The algorithm maintains two subarrays in a given array. The subarray which is already sorted and the remaining subarray which is unsorted. In every iteration of selection sort, the minimum element from the unsorted subarray is picked and moved to the sorted subarray.

Arrays - Selection Sort in DSA

Selection Sort is an in-place comparison sorting algorithm that divides the input list into two parts: the sublist of items already sorted and the sublist of items remaining to be sorted. It repeatedly finds the minimum element from the unsorted part and puts it at the beginning of the unsorted part. The algorithm maintains two subarrays in a given array. The subarray which is already sorted and the remaining subarray which is unsorted. In every iteration of selection sort, the minimum element from the unsorted subarray is picked and moved to the sorted subarray.

Arrays - Shell Sort in DSA

Shell Sort is a generalization of insertion sort that allows the exchange of far-apart elements. It uses a gap sequence to progressively reduce the gap and efficiently sort the array. It offers improved performance compared to simple sorting algorithms with O(n log n) to O(n log² n) time complexity.

Bubble Sort

Learn about Bubble Sort, a simple comparison-based sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order.

Bubble Sort in Swift

Learn how to implement Bubble Sort in Swift, with complete code examples, explanation, and complexity analysis.

Bucket sort

Thsi page containes Bucket Sort, with codes in python, java and c++

Bucket sort

Thsi page containes Bucket Sort, with codes in python, java and c++

Heap Tree Algorithm

The Heap Tree is a specialized binary tree used for efficient priority queue operations and sorting.

Insertion Sort

Learn about Insertion Sort, a simple and intuitive comparison-based sorting algorithm that builds the sorted array one element at a time.

Insertion Sort in Swift

Learn how to implement Insertion Sort in Swift, with complete code examples, explanation, and complexity analysis.

Maximum Building Height

Finding the maximum possible height of a building given a set of restrictions using a two-pass constraint propagation approach.

Maximum Ice Cream Bars

Finding the maximum number of ice cream bars that can be bought with a given amount of coins using a greedy approach.

Merge K Sorted Arrays

Given k sorted arrays with each of size k arranged in the form of a matrix of size k * k. The task is to merge them into one sorted array.

Merge Sort

Merge Sort is a divide-and-conquer sorting algorithm that splits the array into smaller subarrays, sorts them, and merges them back. Learn with interactive visualization, characteristics, complexity analysis, and C++ implementation.

Merge Sort

Learn about Merge Sort, a stable divide-and-conquer sorting algorithm that guarantees O(n log n) performance in all cases.

Merge Sort in Swift

Learn how to implement Merge Sort in Swift, with complete code examples, explanation, and complexity analysis.

Merge Sort vs Quick Sort

Understanding the differences, complexities, and optimal use cases for Merge Sort and Quick Sort.

Quick Sort

Learn about Quick Sort, one of the most efficient sorting algorithms using divide-and-conquer with an average O(n log n) time complexity.

Quick Sort in Swift

Learn how to implement Quick Sort in Swift, with complete code examples, explanation, and complexity analysis.

Radix sort

This page explains Radix sort, with code implementations and resources for further learning.

Radix sort

This page explains Radix sort, with code implementations and resources for further learning.

Randomized Quick Sort

Randomized quicksort is a sorting algorithm that is an extension of quicksort, but with a random pivot selection

Selection Sort

Learn about Selection Sort, a simple comparison-based sorting algorithm that repeatedly selects the minimum element from the unsorted portion.

Selection Sort in Swift

Learn how to implement Selection Sort in Swift, with complete code examples, explanation, and complexity analysis.

Shell Sort

Learn about Shell Sort, an in-place comparison-based sorting algorithm that generalizes insertion sort to allow the exchange of items that are far apart.

Strand Sort

An overview of the Strand Sort Algorithm and its applications in programming.