SlideShare une entreprise Scribd logo
1  sur  54
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

Contenu connexe

Similaire à Data structure.pptx

Sorting and Searching in Array.pptx
Sorting and Searching in Array.pptxSorting and Searching in Array.pptx
Sorting and Searching in Array.pptxMERIAMMADERA2
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdfrushabhshah600
 
Heap sort &amp; bubble sort
Heap sort &amp; bubble sortHeap sort &amp; bubble sort
Heap sort &amp; bubble sortShanmuga Raju
 
Write a program that obtains the execution time of selection sort, bu.pdf
Write a program that obtains the execution time of selection sort, bu.pdfWrite a program that obtains the execution time of selection sort, bu.pdf
Write a program that obtains the execution time of selection sort, bu.pdfarri2009av
 
Java căn bản - Chapter10
Java căn bản - Chapter10Java căn bản - Chapter10
Java căn bản - Chapter10Vince Vo
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab filesNitesh Dubey
 
Write a program to implement and test the following sorting algorithm.docx
 Write a program to implement and test the following sorting algorithm.docx Write a program to implement and test the following sorting algorithm.docx
Write a program to implement and test the following sorting algorithm.docxajoy21
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File Rahul Chugh
 
ch07-arrays.ppt
ch07-arrays.pptch07-arrays.ppt
ch07-arrays.pptMahyuddin8
 

Similaire à Data structure.pptx (20)

6_Array.pptx
6_Array.pptx6_Array.pptx
6_Array.pptx
 
C programs
C programsC programs
C programs
 
Arrays 06.ppt
Arrays 06.pptArrays 06.ppt
Arrays 06.ppt
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
 
2DArrays.ppt
2DArrays.ppt2DArrays.ppt
2DArrays.ppt
 
DAA Lab Work.docx
DAA Lab Work.docxDAA Lab Work.docx
DAA Lab Work.docx
 
Sorting and Searching in Array.pptx
Sorting and Searching in Array.pptxSorting and Searching in Array.pptx
Sorting and Searching in Array.pptx
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
 
Chapter 6 arrays part-1
Chapter 6   arrays part-1Chapter 6   arrays part-1
Chapter 6 arrays part-1
 
Heap sort &amp; bubble sort
Heap sort &amp; bubble sortHeap sort &amp; bubble sort
Heap sort &amp; bubble sort
 
DSA - Array.pptx
DSA - Array.pptxDSA - Array.pptx
DSA - Array.pptx
 
Write a program that obtains the execution time of selection sort, bu.pdf
Write a program that obtains the execution time of selection sort, bu.pdfWrite a program that obtains the execution time of selection sort, bu.pdf
Write a program that obtains the execution time of selection sort, bu.pdf
 
Java căn bản - Chapter10
Java căn bản - Chapter10Java căn bản - Chapter10
Java căn bản - Chapter10
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
 
Write a program to implement and test the following sorting algorithm.docx
 Write a program to implement and test the following sorting algorithm.docx Write a program to implement and test the following sorting algorithm.docx
Write a program to implement and test the following sorting algorithm.docx
 
Arrays
ArraysArrays
Arrays
 
week-20x
week-20xweek-20x
week-20x
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
ch07-arrays.ppt
ch07-arrays.pptch07-arrays.ppt
ch07-arrays.ppt
 
Ada file
Ada fileAda file
Ada file
 

Plus de SajalFayyaz

Data structure.ppt
Data structure.pptData structure.ppt
Data structure.pptSajalFayyaz
 
data structure 9.pptx
data structure 9.pptxdata structure 9.pptx
data structure 9.pptxSajalFayyaz
 
Data structure 8.pptx
Data structure 8.pptxData structure 8.pptx
Data structure 8.pptxSajalFayyaz
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptxSajalFayyaz
 
Data structure 6.pptx
Data structure 6.pptxData structure 6.pptx
Data structure 6.pptxSajalFayyaz
 
Data Structure.pptx
Data Structure.pptxData Structure.pptx
Data Structure.pptxSajalFayyaz
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptxSajalFayyaz
 
data structure3.pptx
data structure3.pptxdata structure3.pptx
data structure3.pptxSajalFayyaz
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptxSajalFayyaz
 
Data Structure.pptx
Data Structure.pptxData Structure.pptx
Data Structure.pptxSajalFayyaz
 

Plus de SajalFayyaz (10)

Data structure.ppt
Data structure.pptData structure.ppt
Data structure.ppt
 
data structure 9.pptx
data structure 9.pptxdata structure 9.pptx
data structure 9.pptx
 
Data structure 8.pptx
Data structure 8.pptxData structure 8.pptx
Data structure 8.pptx
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 
Data structure 6.pptx
Data structure 6.pptxData structure 6.pptx
Data structure 6.pptx
 
Data Structure.pptx
Data Structure.pptxData Structure.pptx
Data Structure.pptx
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 
data structure3.pptx
data structure3.pptxdata structure3.pptx
data structure3.pptx
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 
Data Structure.pptx
Data Structure.pptxData Structure.pptx
Data Structure.pptx
 

Dernier

How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
Real-Time AI Streaming - AI Max Princeton
Real-Time AI  Streaming - AI Max PrincetonReal-Time AI  Streaming - AI Max Princeton
Real-Time AI Streaming - AI Max PrincetonTimothy Spann
 
Heart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectHeart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectBoston Institute of Analytics
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
Thiophen Mechanism khhjjjjjjjhhhhhhhhhhh
Thiophen Mechanism khhjjjjjjjhhhhhhhhhhhThiophen Mechanism khhjjjjjjjhhhhhhhhhhh
Thiophen Mechanism khhjjjjjjjhhhhhhhhhhhYasamin16
 
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxmodul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxaleedritatuxx
 
Multiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfMultiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfchwongval
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfJohn Sterrett
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024thyngster
 
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...ttt fff
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDRafezzaman
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
Learn How Data Science Changes Our World
Learn How Data Science Changes Our WorldLearn How Data Science Changes Our World
Learn How Data Science Changes Our WorldEduminds Learning
 
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degreeyuu sss
 
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Boston Institute of Analytics
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Seán Kennedy
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一F La
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queensdataanalyticsqueen03
 
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024Susanna-Assunta Sansone
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理e4aez8ss
 

Dernier (20)

How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
Real-Time AI Streaming - AI Max Princeton
Real-Time AI  Streaming - AI Max PrincetonReal-Time AI  Streaming - AI Max Princeton
Real-Time AI Streaming - AI Max Princeton
 
Heart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectHeart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis Project
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
Thiophen Mechanism khhjjjjjjjhhhhhhhhhhh
Thiophen Mechanism khhjjjjjjjhhhhhhhhhhhThiophen Mechanism khhjjjjjjjhhhhhhhhhhh
Thiophen Mechanism khhjjjjjjjhhhhhhhhhhh
 
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxmodul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
 
Multiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfMultiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdf
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdf
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
 
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
Learn How Data Science Changes Our World
Learn How Data Science Changes Our WorldLearn How Data Science Changes Our World
Learn How Data Science Changes Our World
 
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
 
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queens
 
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
 

Data structure.pptx

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 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.}