SlideShare une entreprise Scribd logo
1  sur  5
Télécharger pour lire hors ligne
G H PATEL COLLEGE OF ENGINEERING & TECHNOLOGY
GCET, V. V. Nagar – 388 120 1 | P a g e
DATA STRUCTURE OPEN ENDED PROBLEM
Topic: Radix Sort.
Prepared by: - Tejoy Vachhrajani (160110116057)
Khyati Valera (160110116059)
Bhavik Vashi (160110116061)
Submitted to: - Prof. Dipti Mathpal
Class: B.E. (IT) 2nd
Year
Batch: - 1C16
1. INTRODUCTION
In computer science, radix sort is a non-comparative integer sorting algorithm that sorts
data with integer keys by grouping keys by the individual digits which share the same
significant position and value. A positional notation is required, but because integers can
represent strings of characters (e.g., names or dates) and specially formatted floating point
numbers, radix sort is not limited to integers. Radix sort dates back as far as 1887 to the
work of Herman Hollerith on tabulating machines.
Most digital computers internally represent all of their data as electronic representations of
binary numbers, so processing the digits of integer representations by groups of binary digit
representations is most convenient. Two classifications of radix sorts are least significant
digit (LSD) radix sorts and most significant digit (MSD) radix sorts. LSD radix sorts process the
integer representations starting from the least digit and move towards the most significant
digit. MSD radix sorts work the other way around.
This is a C Program to implement Radix Sort. The idea of Radix Sort is to do digit by digit sort
starting from least significant digit to most significant digit. Radix sort uses counting sort as a
subroutine to sort.
Here is source code of the C Program to Implement Radix Sort. The C program is successfully
compiled and run on a Linux system. The program output is also shown below.
G H PATEL COLLEGE OF ENGINEERING & TECHNOLOGY
GCET, V. V. Nagar – 388 120 2 | P a g e
THE ALGORITHM
The program implementation is done by using the below
algorithm.
Step 1: Find the largest number in array as LARGE
Step 2: [INITIALIZE] Set NOP = Number of digits in LARGE.
Step 3: Set PASS=0
Step 4: Repeat Step 5 while PASS<=NOP-1.
Step 5: Set i=0 and initialize the bucket
Step 6: Repeat steps 7 to 9 while i<n-1
Step 7: Set digit=digit at PASSth place in A[i]
Step 8: Add A[i] to bucket numbered digit
Step 9: Increment bucket count for bucket number digit
(End of Loop)
Step 10: Collect the numbers in the bucket
(End of Loop)
Step 11: End
G H PATEL COLLEGE OF ENGINEERING & TECHNOLOGY
GCET, V. V. Nagar – 388 120 3 | P a g e
Program :-
1. #include<stdio.h>
2. #include<conio.h>
3.
4. int getMax(int arr[], int n) {
5. int mx = arr[0];
6. int i;
7. for (i = 1; i < n; i++)
8. if (arr[i] > mx)
9. mx = arr[i];
10. return mx;
11. }
12.
13. void countSort(int arr[], int n, int exp) {
14. int output[n]; // output array
15. int i, count[10] = { 0 };
16.
17. // Store count of occurrences in count[]
18. for (i = 0; i < n; i++)
19. count[(arr[i] / exp) % 10]++;
20.
21. for (i = 1; i < 10; i++)
22. count[i] += count[i - 1];
23.
24. // Build the output array
G H PATEL COLLEGE OF ENGINEERING & TECHNOLOGY
GCET, V. V. Nagar – 388 120 4 | P a g e
25. for (i = n - 1; i >= 0; i--) {
26. output[count[(arr[i] / exp) % 10] - 1] = arr[i];
27. count[(arr[i] / exp) % 10]--;
28. }
29.
30. for (i = 0; i < n; i++)
31. arr[i] = output[i];
32. }
33.
34. // The main function to that sorts arr[] of size n using Radix Sort
35. void radixsort(int arr[], int n) {
36. int m = getMax(arr, n);
37.
38. int exp;
39. for (exp = 1; m / exp > 0; exp *= 10)
40. countSort(arr, n, exp);
41. }
42.
43. void print(int arr[], int n) {
44. int i;
45. for (i = 0; i < n; i++)
46. printf("%d ", arr[i]);
47. }
48.
49. int main() {
50. int arr[] = { 170, 45, 75, 90, 802, 24, 2, 66 };
51. int n = sizeof(arr) / sizeof(arr[0]);
G H PATEL COLLEGE OF ENGINEERING & TECHNOLOGY
GCET, V. V. Nagar – 388 120 5 | P a g e
52. radixsort(arr, n);
53. Print(arr, n);
54. return 0;
55. }
Output:
2 24 45 66 75 90 170 802

Contenu connexe

Tendances

Bubble sort
Bubble sortBubble sort
Bubble sortManek Ar
 
3.9 external sorting
3.9 external sorting3.9 external sorting
3.9 external sortingKrish_ver2
 
Insertion sort
Insertion sortInsertion sort
Insertion sortMYER301
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data StructureDharita Chokshi
 
Linked list in Data Structure and Algorithm
Linked list in Data Structure and Algorithm Linked list in Data Structure and Algorithm
Linked list in Data Structure and Algorithm KristinaBorooah
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Balwant Gorad
 
3.3 shell sort
3.3 shell sort3.3 shell sort
3.3 shell sortKrish_ver2
 
Dining philosopher problem operating system
Dining philosopher problem operating system Dining philosopher problem operating system
Dining philosopher problem operating system anushkashastri
 
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...Umesh Kumar
 
Insertion sort
Insertion sortInsertion sort
Insertion sortalmaqboli
 
Bubble sort | Data structure |
Bubble sort | Data structure |Bubble sort | Data structure |
Bubble sort | Data structure |MdSaiful14
 
Radix sort presentation
Radix sort presentationRadix sort presentation
Radix sort presentationRatul Hasan
 
NAND and NOR implementation and Other two level implementation
NAND and NOR implementation and  Other two level implementationNAND and NOR implementation and  Other two level implementation
NAND and NOR implementation and Other two level implementationMuhammad Akhtar
 
Java Linked List Tutorial | Edureka
Java Linked List Tutorial |  EdurekaJava Linked List Tutorial |  Edureka
Java Linked List Tutorial | EdurekaEdureka!
 
Presentation on queue
Presentation on queuePresentation on queue
Presentation on queueRojan Pariyar
 

Tendances (20)

Insertion Sorting
Insertion SortingInsertion Sorting
Insertion Sorting
 
Bubble sort
Bubble sortBubble sort
Bubble sort
 
3.9 external sorting
3.9 external sorting3.9 external sorting
3.9 external sorting
 
single linked list
single linked listsingle linked list
single linked list
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
Merge sort
Merge sortMerge sort
Merge sort
 
Linked list in Data Structure and Algorithm
Linked list in Data Structure and Algorithm Linked list in Data Structure and Algorithm
Linked list in Data Structure and Algorithm
 
Insertion sort algorithm power point presentation
Insertion  sort algorithm power point presentation Insertion  sort algorithm power point presentation
Insertion sort algorithm power point presentation
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
 
3.3 shell sort
3.3 shell sort3.3 shell sort
3.3 shell sort
 
Dining philosopher problem operating system
Dining philosopher problem operating system Dining philosopher problem operating system
Dining philosopher problem operating system
 
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Bubble sort | Data structure |
Bubble sort | Data structure |Bubble sort | Data structure |
Bubble sort | Data structure |
 
Radix sort presentation
Radix sort presentationRadix sort presentation
Radix sort presentation
 
NAND and NOR implementation and Other two level implementation
NAND and NOR implementation and  Other two level implementationNAND and NOR implementation and  Other two level implementation
NAND and NOR implementation and Other two level implementation
 
Java Linked List Tutorial | Edureka
Java Linked List Tutorial |  EdurekaJava Linked List Tutorial |  Edureka
Java Linked List Tutorial | Edureka
 
Presentation on queue
Presentation on queuePresentation on queue
Presentation on queue
 
Link list
Link listLink list
Link list
 

Similaire à Data Structure Radix Sort

Basic_analysis.ppt
Basic_analysis.pptBasic_analysis.ppt
Basic_analysis.pptSoumyaJ3
 
Isc computer project final upload last
Isc computer project final upload lastIsc computer project final upload last
Isc computer project final upload lastArunav Ray
 
Net practicals lab mannual
Net practicals lab mannualNet practicals lab mannual
Net practicals lab mannualAbhishek Pathak
 
chapter1.ppt
chapter1.pptchapter1.ppt
chapter1.pptebinazer1
 
Design of QSD Number System Addition using Delayed Addition Technique
Design of QSD Number System Addition using Delayed Addition TechniqueDesign of QSD Number System Addition using Delayed Addition Technique
Design of QSD Number System Addition using Delayed Addition TechniqueKumar Goud
 
Design of QSD Number System Addition using Delayed Addition Technique
Design of QSD Number System Addition using Delayed Addition TechniqueDesign of QSD Number System Addition using Delayed Addition Technique
Design of QSD Number System Addition using Delayed Addition TechniqueKumar Goud
 
Data Structure & Algorithms - Matrix Multiplication
Data Structure & Algorithms - Matrix MultiplicationData Structure & Algorithms - Matrix Multiplication
Data Structure & Algorithms - Matrix Multiplicationbabuk110
 
FDS- Basic Concepts.ppt
FDS- Basic Concepts.pptFDS- Basic Concepts.ppt
FDS- Basic Concepts.pptshanthishyam
 
Java parallel programming made simple
Java parallel programming made simpleJava parallel programming made simple
Java parallel programming made simpleAteji Px
 
Computer Science CS Project Matrix CBSE Class 12th XII .pdf
Computer Science CS Project Matrix CBSE Class 12th XII .pdfComputer Science CS Project Matrix CBSE Class 12th XII .pdf
Computer Science CS Project Matrix CBSE Class 12th XII .pdfPranavAnil9
 
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programsAbhishek Jena
 
MITCOE 2011-12 conm-submission
MITCOE 2011-12 conm-submissionMITCOE 2011-12 conm-submission
MITCOE 2011-12 conm-submissionAshutosh Katti
 

Similaire à Data Structure Radix Sort (20)

Basic_analysis.ppt
Basic_analysis.pptBasic_analysis.ppt
Basic_analysis.ppt
 
chapter1.ppt
chapter1.pptchapter1.ppt
chapter1.ppt
 
chapter1.ppt
chapter1.pptchapter1.ppt
chapter1.ppt
 
Isc computer project final upload last
Isc computer project final upload lastIsc computer project final upload last
Isc computer project final upload last
 
Net practicals lab mannual
Net practicals lab mannualNet practicals lab mannual
Net practicals lab mannual
 
chapter1.ppt
chapter1.pptchapter1.ppt
chapter1.ppt
 
Design of QSD Number System Addition using Delayed Addition Technique
Design of QSD Number System Addition using Delayed Addition TechniqueDesign of QSD Number System Addition using Delayed Addition Technique
Design of QSD Number System Addition using Delayed Addition Technique
 
Design of QSD Number System Addition using Delayed Addition Technique
Design of QSD Number System Addition using Delayed Addition TechniqueDesign of QSD Number System Addition using Delayed Addition Technique
Design of QSD Number System Addition using Delayed Addition Technique
 
Data Structure & Algorithms - Matrix Multiplication
Data Structure & Algorithms - Matrix MultiplicationData Structure & Algorithms - Matrix Multiplication
Data Structure & Algorithms - Matrix Multiplication
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
LMmanual.pdf
LMmanual.pdfLMmanual.pdf
LMmanual.pdf
 
Doc 20180130-wa0006
Doc 20180130-wa0006Doc 20180130-wa0006
Doc 20180130-wa0006
 
FDS- Basic Concepts.ppt
FDS- Basic Concepts.pptFDS- Basic Concepts.ppt
FDS- Basic Concepts.ppt
 
Sorting_project_2.pdf
Sorting_project_2.pdfSorting_project_2.pdf
Sorting_project_2.pdf
 
Java parallel programming made simple
Java parallel programming made simpleJava parallel programming made simple
Java parallel programming made simple
 
Computer Science CS Project Matrix CBSE Class 12th XII .pdf
Computer Science CS Project Matrix CBSE Class 12th XII .pdfComputer Science CS Project Matrix CBSE Class 12th XII .pdf
Computer Science CS Project Matrix CBSE Class 12th XII .pdf
 
C++ TUTORIAL 5
C++ TUTORIAL 5C++ TUTORIAL 5
C++ TUTORIAL 5
 
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs
 
Cis435 week01
Cis435 week01Cis435 week01
Cis435 week01
 
MITCOE 2011-12 conm-submission
MITCOE 2011-12 conm-submissionMITCOE 2011-12 conm-submission
MITCOE 2011-12 conm-submission
 

Plus de Bhavik Vashi

Runge Kutta Method
Runge Kutta Method Runge Kutta Method
Runge Kutta Method Bhavik Vashi
 
Rate monotonic scheduling- Operating System
Rate monotonic scheduling- Operating SystemRate monotonic scheduling- Operating System
Rate monotonic scheduling- Operating SystemBhavik Vashi
 
File management in OS
File management in OSFile management in OS
File management in OSBhavik Vashi
 
Types of Constructor in C++
Types of Constructor in C++Types of Constructor in C++
Types of Constructor in C++Bhavik Vashi
 
Parallel processing (simd and mimd)
Parallel processing (simd and mimd)Parallel processing (simd and mimd)
Parallel processing (simd and mimd)Bhavik Vashi
 
Ethernet and switches
Ethernet and switchesEthernet and switches
Ethernet and switchesBhavik Vashi
 
Fiscal Policy & Monetary Policy
Fiscal Policy & Monetary PolicyFiscal Policy & Monetary Policy
Fiscal Policy & Monetary PolicyBhavik Vashi
 
Projection of lines
Projection of linesProjection of lines
Projection of linesBhavik Vashi
 
Most Successful People & Personality
Most Successful People & Personality Most Successful People & Personality
Most Successful People & Personality Bhavik Vashi
 
Global Need of the World
Global Need of the WorldGlobal Need of the World
Global Need of the WorldBhavik Vashi
 
Functions of stdio conio
Functions of stdio   conio Functions of stdio   conio
Functions of stdio conio Bhavik Vashi
 
Impact of social media
Impact of social mediaImpact of social media
Impact of social mediaBhavik Vashi
 

Plus de Bhavik Vashi (20)

Aws ec2
Aws ec2Aws ec2
Aws ec2
 
MACRO PROCESSOR
MACRO PROCESSORMACRO PROCESSOR
MACRO PROCESSOR
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Linear Sorting
Linear SortingLinear Sorting
Linear Sorting
 
Colormodels
ColormodelsColormodels
Colormodels
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
 
Runge Kutta Method
Runge Kutta Method Runge Kutta Method
Runge Kutta Method
 
Rate monotonic scheduling- Operating System
Rate monotonic scheduling- Operating SystemRate monotonic scheduling- Operating System
Rate monotonic scheduling- Operating System
 
File management in OS
File management in OSFile management in OS
File management in OS
 
Types of Constructor in C++
Types of Constructor in C++Types of Constructor in C++
Types of Constructor in C++
 
Parallel processing (simd and mimd)
Parallel processing (simd and mimd)Parallel processing (simd and mimd)
Parallel processing (simd and mimd)
 
Ethernet and switches
Ethernet and switchesEthernet and switches
Ethernet and switches
 
Fiscal Policy & Monetary Policy
Fiscal Policy & Monetary PolicyFiscal Policy & Monetary Policy
Fiscal Policy & Monetary Policy
 
Diwali Light
Diwali LightDiwali Light
Diwali Light
 
Heat transfer
Heat transferHeat transfer
Heat transfer
 
Projection of lines
Projection of linesProjection of lines
Projection of lines
 
Most Successful People & Personality
Most Successful People & Personality Most Successful People & Personality
Most Successful People & Personality
 
Global Need of the World
Global Need of the WorldGlobal Need of the World
Global Need of the World
 
Functions of stdio conio
Functions of stdio   conio Functions of stdio   conio
Functions of stdio conio
 
Impact of social media
Impact of social mediaImpact of social media
Impact of social media
 

Dernier

VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 

Dernier (20)

VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 

Data Structure Radix Sort

  • 1. G H PATEL COLLEGE OF ENGINEERING & TECHNOLOGY GCET, V. V. Nagar – 388 120 1 | P a g e DATA STRUCTURE OPEN ENDED PROBLEM Topic: Radix Sort. Prepared by: - Tejoy Vachhrajani (160110116057) Khyati Valera (160110116059) Bhavik Vashi (160110116061) Submitted to: - Prof. Dipti Mathpal Class: B.E. (IT) 2nd Year Batch: - 1C16 1. INTRODUCTION In computer science, radix sort is a non-comparative integer sorting algorithm that sorts data with integer keys by grouping keys by the individual digits which share the same significant position and value. A positional notation is required, but because integers can represent strings of characters (e.g., names or dates) and specially formatted floating point numbers, radix sort is not limited to integers. Radix sort dates back as far as 1887 to the work of Herman Hollerith on tabulating machines. Most digital computers internally represent all of their data as electronic representations of binary numbers, so processing the digits of integer representations by groups of binary digit representations is most convenient. Two classifications of radix sorts are least significant digit (LSD) radix sorts and most significant digit (MSD) radix sorts. LSD radix sorts process the integer representations starting from the least digit and move towards the most significant digit. MSD radix sorts work the other way around. This is a C Program to implement Radix Sort. The idea of Radix Sort is to do digit by digit sort starting from least significant digit to most significant digit. Radix sort uses counting sort as a subroutine to sort. Here is source code of the C Program to Implement Radix Sort. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
  • 2. G H PATEL COLLEGE OF ENGINEERING & TECHNOLOGY GCET, V. V. Nagar – 388 120 2 | P a g e THE ALGORITHM The program implementation is done by using the below algorithm. Step 1: Find the largest number in array as LARGE Step 2: [INITIALIZE] Set NOP = Number of digits in LARGE. Step 3: Set PASS=0 Step 4: Repeat Step 5 while PASS<=NOP-1. Step 5: Set i=0 and initialize the bucket Step 6: Repeat steps 7 to 9 while i<n-1 Step 7: Set digit=digit at PASSth place in A[i] Step 8: Add A[i] to bucket numbered digit Step 9: Increment bucket count for bucket number digit (End of Loop) Step 10: Collect the numbers in the bucket (End of Loop) Step 11: End
  • 3. G H PATEL COLLEGE OF ENGINEERING & TECHNOLOGY GCET, V. V. Nagar – 388 120 3 | P a g e Program :- 1. #include<stdio.h> 2. #include<conio.h> 3. 4. int getMax(int arr[], int n) { 5. int mx = arr[0]; 6. int i; 7. for (i = 1; i < n; i++) 8. if (arr[i] > mx) 9. mx = arr[i]; 10. return mx; 11. } 12. 13. void countSort(int arr[], int n, int exp) { 14. int output[n]; // output array 15. int i, count[10] = { 0 }; 16. 17. // Store count of occurrences in count[] 18. for (i = 0; i < n; i++) 19. count[(arr[i] / exp) % 10]++; 20. 21. for (i = 1; i < 10; i++) 22. count[i] += count[i - 1]; 23. 24. // Build the output array
  • 4. G H PATEL COLLEGE OF ENGINEERING & TECHNOLOGY GCET, V. V. Nagar – 388 120 4 | P a g e 25. for (i = n - 1; i >= 0; i--) { 26. output[count[(arr[i] / exp) % 10] - 1] = arr[i]; 27. count[(arr[i] / exp) % 10]--; 28. } 29. 30. for (i = 0; i < n; i++) 31. arr[i] = output[i]; 32. } 33. 34. // The main function to that sorts arr[] of size n using Radix Sort 35. void radixsort(int arr[], int n) { 36. int m = getMax(arr, n); 37. 38. int exp; 39. for (exp = 1; m / exp > 0; exp *= 10) 40. countSort(arr, n, exp); 41. } 42. 43. void print(int arr[], int n) { 44. int i; 45. for (i = 0; i < n; i++) 46. printf("%d ", arr[i]); 47. } 48. 49. int main() { 50. int arr[] = { 170, 45, 75, 90, 802, 24, 2, 66 }; 51. int n = sizeof(arr) / sizeof(arr[0]);
  • 5. G H PATEL COLLEGE OF ENGINEERING & TECHNOLOGY GCET, V. V. Nagar – 388 120 5 | P a g e 52. radixsort(arr, n); 53. Print(arr, n); 54. return 0; 55. } Output: 2 24 45 66 75 90 170 802