Given a linked list which is sorted based on absolute values. Sort the list based on actual values. Examples: Input : 1 -> -10 output:… Read More »

## Sort a linked list that is sorted alternating ascending and descending orders?

Given a Linked List. The Linked List is in alternating ascending and descending orders. Sort the list efficiently. Example: Input List: 10 -> 40 ->… Read More »

## Why Quick Sort preferred for Arrays and Merge Sort for Linked Lists?

Why is Quick Sort preferred for arrays? Below are recursive and iterative implementations of Quick Sort and Merge Sort for arrays. Recursive Quick Sort for… Read More »

## Merge Sort for Doubly Linked List

Given a doubly linked list, write a function to sort the doubly linked list in increasing order using merge sort. For example, the following doubly… Read More »

## C Program for Bubble Sort on Linked List

Given a singly linked list, sort it using bubble sort. Input : 10->30->20->5 Output : 5->10->20->30 Input : 20->4->3 Output : 3->4->20 filter_none edit close… Read More »

## QuickSort on Singly Linked List

QuickSort on Doubly Linked List is discussed here. QuickSort on Singly linked list was given as an exercise. Following is C++ implementation for same. The… Read More »

## QuickSort on Doubly Linked List

Following is a typical recursive implementation of QuickSort for arrays. The implementation uses last element as pivot. filter_none edit close play_arrow link brightness_4 code /*… Read More »

## Sort a linked list of 0s, 1s and 2s

Given a linked list of 0s, 1s and 2s, sort it. Examples: Input: 1 -> 1 -> 2 -> 0 -> 2 -> 0 ->… Read More »

## Merge Sort for Linked Lists

Merge sort is often preferred for sorting a linked list. The slow random-access performance of a linked list makes some other algorithms (such as quicksort)… Read More »