हेल्लो दोस्तों! आज हम इस पोस्ट में data structure में Radix sort in Hindi (रेडिक्स सॉर्ट क्या है?) के बारें में पढेंगे और इसका example को भी देखेंगे तो चलिए शुरू करते हैं:-
Radix Sort in Hindi
Radix sort एक integer sorting algorithm है जो अलग-अलग अंकों (digits) की keys की grouping करके integer keys के साथ डेटा को sort करता है। Radix sort, numbers की array को sort करने के लिए counting sort का प्रयोग subroutine की तरह करता है.
दूसरे शब्दों में कहें तो, “Radix sort एक sorting तकनीक है जिसमें सबसे पहले समान place value के अलग-अलग digits की grouping करके elements को sort किया जाता है. फिर उसके बाद elements को उनके घटते या बढ़ते क्रम के अनुसार sort किया जाता है.”
इसका उदाहरण:-
नीचे आपको youtube की video दी गयी है जिससे आप इसके example को आसानी से समझ सकते हैं:-
Radix sort algorithm
Algorithm: Radix-Sort (list, n)
shift = 1
for loop = 1 to keysize do
for entry = 1 to n do
bucketnumber = (list[entry].key / shift) mod 10
append (bucket[bucketnumber], list[entry])
list = combinebuckets()
shift = shift * 10
इसकी complexity:-
रेडिक्स सॉर्ट की time complexity:- O(d(n+k)).
radix sort c language example
#include <stdio.h>
int getMax(int array[], int n) {
int max = array[0];
for (int i = 1; i < n; i++)
if (array[i] > max)
max = array[i];
return max;
}
void countingSort(int array[], int size, int place) {
int output[size + 1];
int max = (array[0] / place) % 10;
for (int i = 1; i < size; i++) {
if (((array[i] / place) % 10) > max)
max = array[i];
}
int count[max + 1];
for (int i = 0; i < max; ++i)
count[i] = 0;
for (int i = 0; i < size; i++)
count[(array[i] / place) % 10]++;
for (int i = 1; i < 10; i++)
count[i] += count[i - 1];
for (int i = size - 1; i >= 0; i--) {
output[count[(array[i] / place) % 10] - 1] = array[i];
count[(array[i] / place) % 10]--;
}
for (int i = 0; i < size; i++)
array[i] = output[i];
}
void radixsort(int array[], int size) {
int max = getMax(array, size);
for (int place = 1; max / place > 0; place *= 10)
countingSort(array, size, place);
}
void printArray(int array[], int size) {
for (int i = 0; i < size; ++i) {
printf("%d ", array[i]);
}
printf("\n");
}
int main() {
int array[] = {121, 432, 564, 23, 1, 45, 788};
int n = sizeof(array) / sizeof(array[0]);
radixsort(array, n);
printArray(array, n);
}
references:-
Summary (सारांश)
यह article Radix Sort in Hindi (रेडिक्स सॉर्ट क्या है?) को बहुत ही सरल भाषा में समझाता है। इसमें बताया गया है कि Radix Sort एक integer sorting algorithm है जो अलग-अलग digits को group करके numbers को sort करता है। यह counting sort को subroutine की तरह use करता है। इस article में आपको मिलेगा: - Radix Sort का पूरा algorithm और उसकी step-by-step explanation - एक example video का link जिससे concept आसानी से समझ में आ जाएगा - Time complexity O(d(n+k)) की जानकारी - C language में radix sort का practical code example इस article को पढ़ने के बाद students सीखेंगे: - Radix sort कैसे काम करता है और यह अन्य sorts से कैसे अलग है - Place value (units, tens, hundreds) के आधार पर sorting की प्रक्रिया - Counting sort को radix sort में कैसे implement किया जाता है Exam preparation के लिए यह article बहुत helpful है क्योंकि: - इसमें algorithm और code दोनों दिए गए हैं - Complexity analysis से numerical questions हल करने में मदद मिलती है -
- Example से concept clear होता है
- Code implementation से programming questions के लिए तैयारी होती है
निवेदन:- अगर आपके लिए यह article उपयोगी रहा हो तो इसे अपने दोस्तों के साथ अवश्य share कीजिये और आपके इससे related कोई भी questions हैं तो आप नीचे कमेंट करके बता सकते हैं.