SlideShare a Scribd company logo
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
1.int main() {
2. int a[] = {181, 289, 390, 121, 145, 736, 514, 888, 122};
3. int n = sizeof(a) / sizeof(a[0]);
4. printf("Before sorting array elements are - n");
5. printArray(a,n);
6. radixsort(a, n);
7. printf("After applying Radix sort, the array elements are -
n");
8. printArray(a, n);
9.}
1.#include <stdio.h>
2.
3.int getMax(int a[], int n) {
4. int max = a[0];
5. for(int i = 1; i<n; i++) {
6. if(a[i] > max)
7. max = a[i];
8. }
}
return max; //maximum element from the array
}
1.void countingSort(int a[], int n, int place) // function t implement counting sor
t
2.{
3. int output[n + 1];
4. int count[10] = {0};
5.
6. // Calculate count of elements
7. for (int i = 0; i < n; i++)
8. count[(a[i] / place) % 10]++;
9.
10. // Calculate cumulative frequency
11. for (int i = 1; i < 10; i++)
12. count[i] += count[i - 1];
13.
14. // Place the elements in sorted order
15. for (int i = n - 1; i >= 0; i--) {
16. output[count[(a[i] / place) % 10] - 1] = a[i];
17. count[(a[i] / place) % 10]--;
18. }
19.
20. for (int i = 0; i < n; i++)
21. a[i] = output[i]; }
1.// function to implement radix sort
2.void radixsort(int a[], int n) {
3.
4. // get maximum element from array
5. int max = getMax(a, n);
6.
7. // Apply counting sort to sort eleme
nts based on place value
8. for (int place = 1; max / place > 0;
place *= 10)
9. countingSort(a, n, place); }
1.// function to print array elements
2.void printArray(int a[], int n) {
3. for (int i = 0; i < n; ++i) {
4. printf("%d ", a[i]);
5. }
6. printf("n");
7.}
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx
Data structure.pptx

More Related Content

PDF
Data Structure Radix Sort
PPTX
Analysis of algorithms
PDF
codes.txt.pdf code presentation engineering
PDF
So I am writing a CS code for a project and I keep getting cannot .pdf
PPTX
Merge radix-sort-algorithm
PPTX
Merge radix-sort-algorithm
PDF
#include stdio.h #include string.h Function swaps to po.pdf
Data Structure Radix Sort
Analysis of algorithms
codes.txt.pdf code presentation engineering
So I am writing a CS code for a project and I keep getting cannot .pdf
Merge radix-sort-algorithm
Merge radix-sort-algorithm
#include stdio.h #include string.h Function swaps to po.pdf

Similar to Data structure.pptx (20)

PPTX
LectureSlidData_sturcture_algorithm_v2.pptx
PDF
Sorting Algorithms and their implementations
PPTX
Quick and radix sort
PPTX
Advance Algorithm_unit_2_czcbcnhgjy.pptx
DOC
Sorting programs
DOCX
PPTX
Radix and shell sort
PDF
programs
DOCX
PDF
C++ Searching & Sorting5. Sort the following list using the select.pdf
DOCX
DAA Lab File C Programs
PDF
Program of sorting using shell sort #include stdio.h #de.pdf
PDF
1D Array
PPTX
sorting1.pptx
PPTX
Radix Sort
DOCX
ADA FILE
PPT
Counting Sort and Radix Sort Algorithms
PPTX
Radix sort
LectureSlidData_sturcture_algorithm_v2.pptx
Sorting Algorithms and their implementations
Quick and radix sort
Advance Algorithm_unit_2_czcbcnhgjy.pptx
Sorting programs
Radix and shell sort
programs
C++ Searching & Sorting5. Sort the following list using the select.pdf
DAA Lab File C Programs
Program of sorting using shell sort #include stdio.h #de.pdf
1D Array
sorting1.pptx
Radix Sort
ADA FILE
Counting Sort and Radix Sort Algorithms
Radix sort

More from SajalFayyaz (10)

PPT
Data structure.ppt
PPTX
data structure 9.pptx
PPTX
Data structure 8.pptx
PPTX
Data structure.pptx
PPTX
Data structure 6.pptx
PPTX
Data Structure.pptx
PPTX
Data structure.pptx
PPTX
data structure3.pptx
PPTX
Data structure.pptx
PPTX
Data Structure.pptx
Data structure.ppt
data structure 9.pptx
Data structure 8.pptx
Data structure.pptx
Data structure 6.pptx
Data Structure.pptx
Data structure.pptx
data structure3.pptx
Data structure.pptx
Data Structure.pptx

Recently uploaded (20)

PPTX
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PDF
Foundation of Data Science unit number two notes
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PPTX
Supervised vs unsupervised machine learning algorithms
PPTX
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
PDF
Fluorescence-microscope_Botany_detailed content
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
PDF
Clinical guidelines as a resource for EBP(1).pdf
PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PPTX
Business Acumen Training GuidePresentation.pptx
PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
PPTX
Acceptance and paychological effects of mandatory extra coach I classes.pptx
PPTX
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PPTX
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
PPTX
climate analysis of Dhaka ,Banglades.pptx
PPTX
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
PDF
Lecture1 pattern recognition............
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
Foundation of Data Science unit number two notes
Data_Analytics_and_PowerBI_Presentation.pptx
Supervised vs unsupervised machine learning algorithms
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
Fluorescence-microscope_Botany_detailed content
Business Ppt On Nestle.pptx huunnnhhgfvu
Clinical guidelines as a resource for EBP(1).pdf
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
Business Acumen Training GuidePresentation.pptx
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
Acceptance and paychological effects of mandatory extra coach I classes.pptx
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
climate analysis of Dhaka ,Banglades.pptx
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
Lecture1 pattern recognition............

Data structure.pptx

  • 44. 1.int main() { 2. int a[] = {181, 289, 390, 121, 145, 736, 514, 888, 122}; 3. int n = sizeof(a) / sizeof(a[0]); 4. printf("Before sorting array elements are - n"); 5. printArray(a,n); 6. radixsort(a, n); 7. printf("After applying Radix sort, the array elements are - n"); 8. printArray(a, n); 9.}
  • 45. 1.#include <stdio.h> 2. 3.int getMax(int a[], int n) { 4. int max = a[0]; 5. for(int i = 1; i<n; i++) { 6. if(a[i] > max) 7. max = a[i]; 8. } } return max; //maximum element from the array }
  • 46. 1.void countingSort(int a[], int n, int place) // function t implement counting sor t 2.{ 3. int output[n + 1]; 4. int count[10] = {0}; 5. 6. // Calculate count of elements 7. for (int i = 0; i < n; i++) 8. count[(a[i] / place) % 10]++; 9. 10. // Calculate cumulative frequency 11. for (int i = 1; i < 10; i++) 12. count[i] += count[i - 1]; 13. 14. // Place the elements in sorted order 15. for (int i = n - 1; i >= 0; i--) { 16. output[count[(a[i] / place) % 10] - 1] = a[i]; 17. count[(a[i] / place) % 10]--; 18. } 19. 20. for (int i = 0; i < n; i++) 21. a[i] = output[i]; }
  • 47. 1.// function to implement radix sort 2.void radixsort(int a[], int n) { 3. 4. // get maximum element from array 5. int max = getMax(a, n); 6. 7. // Apply counting sort to sort eleme nts based on place value 8. for (int place = 1; max / place > 0; place *= 10) 9. countingSort(a, n, place); }
  • 48. 1.// function to print array elements 2.void printArray(int a[], int n) { 3. for (int i = 0; i < n; ++i) { 4. printf("%d ", a[i]); 5. } 6. printf("n"); 7.}