KonkurStudy
همه مباحث

الگوریتم‌های مرتب‌سازی

Sorting Algorithms

مباحث الگوریتم‌های مرتب‌سازی.

طراحی الگوریتم کنکور ارشد علوم کامپیوتر

اهمیت
۰/۵

کارت‌ها · 10

مفهومطراحی الگوریتم
Insertion Sort on Nearly-Sorted Arrays

Insertion sort is adaptive: it runs in Θ(n) on nearly-sorted input where merge/quicksort still pay Θ(nlog n) .

insertion-sortadaptive-sortingnearly-sortedcomparison-count
مفهومطراحی الگوریتم
k-Way Merge Time Complexity

Merging k sorted lists with n total elements costs Θ(nlog k) , which is O(n) only when k is constant.

k-way-mergemergemin-heaplower-bound
فرمولطراحی الگوریتم
Median-Pivot Quicksort Recurrence

Picking the exact median as pivot gives a perfectly balanced split, yielding T(n)=2T(n/2)+f(n)+Θ(n)=O((n+f(n))log n) .

quicksortmedianpivot-selectionrecurrence
مفهومطراحی الگوریتم
Counting Quicksort Comparisons on a Fixed-Size Array

On an array of size n, Quicksort's comparison count is a random quantity ranging from nlog n (best) to n(n-1)/2 (worst), determined entirely by how each pivot splits its subarray.

quicksortcomparison-countpartitionrecurrence
قضیهطراحی الگوریتم
Bubble Sort Swap Count Equals Inversions

Bubble sort (and any sort that only swaps adjacent out-of-order elements) performs exactly as many swaps as there are inversions in the input — so you can count swaps without simulating the passes.

bubble-sortinversionsswap-countsorting
مفهومطراحی الگوریتم
Time Complexity of Elementary Sorts (Bubble vs. Selection)

Bubble, selection, and insertion sort all run in Theta(n^2) on a random array; what distinguishes them is whether their cost depends on the input — selection sort is always Theta(n^2), bubble and insertion can drop to Theta(n) on sorted data.

sortingbubble-sortselection-sortinsertion-sort
الگوریتمطراحی الگوریتم
Dutch National Flag Three-Way Partition

Sort an array of three distinct key values into low-mid-high order in a single linear, in-place pass using three pointers.

dutch-national-flagthree-way-partitionin-placetwo-pointer
مفهومطراحی الگوریتم
Counting Merge-Sort Calls, Merges, and Comparisons

Model one run of merge sort as a recursion tree with n leaves: there are n-1 internal (splitting) nodes, so merge is called n-1 times, total mergesort invocations are 2n-1, and the worst-case element comparisons are at most nceil(log2 n) - 2^ceil(log2 n) + 1. Don't confuse 'total calls' with 'recursive calls'.

merge-sortsortingrecursion-treecomparison-counting
مفهومطراحی الگوریتم
Merge Sort with a Constant-Size Insertion-Sort Cutoff

Stopping merge-sort recursion at blocks of a constant size k and finishing each block with insertion sort keeps the running time at Θ(nlog n) ; the cutoff only shaves a constant factor. The bound changes only when k is allowed to grow with n .

merge-sortinsertion-sortcutoffcoarsening
مفهومطراحی الگوریتم
Radix Sort and the Stable-Subroutine Requirement

LSD radix sort is correct only if the per-digit auxiliary sort is stable, so heapsort and quicksort cannot be plugged in while stable counting sort can.

radix-sortstable-sortauxiliary-sortcounting

سوالات · 18