SlideShare une entreprise Scribd logo
ARRAYS
Arrays
An array is collection of elements of similar data type.
Why Arrays????
Arrays are used when there is a need to use many variables of
the same type. Say you want to store marks scored by 60 students of
our class in C programming subject, so how many variables you need
to declare to hold 60 values? 60 variables? Will it be feasible? So use
an array for the same task instead. The programmer has to just specify
the data type of elements and the number of elements that are
required as the size of the array.
60 variable’s declaration???
int s1,s2,s3,……..s60;
Or
int s[60] ;
Which is easy???
int a[5]; int a[5][5]; int a[5][5][5];
One Dimensional Array (1D Array)
Syntax for Declaring 1D Array
Example for Declaring 1D Array
int a[5];
Data_Type Array_Name[Size];
1004
1000 1008 1012 1016
a[1]
a[0] a[2] a[3] a[4]
a
Subscript or index, used to access the specific value from an array, a[3]
gives 40
Name of
the
array
Address of the array, in a
contiguous manner
Initializing 1D Array
1. Compile Time Initialization
Types of compile time array initialization:
 Complete array Initialization
 Partial array Initialization
 Initialization without size
 Initialization with Zero
2. Runtime Initialization
Compile Time Array Initializations
4. Initialization with Zero
3. Initialization without size
2. Partial Array Initialization
1. Complete array Initialization
1 2 3 4 5 1 2 3 0 0
1 2 3 4 5 0 0 0 0 0
a[1]
a[0] a[2] a[3] a[4]
a[1]
a[0] a[2] a[3] a[4]
a[1]
a[0] a[2] a[3] a[4]
a[1]
a[0] a[2] a[3] a[4]
Write a C Program to scan and print n array elements.
Write a C Program to scan n elements in an array and find the sum
and average of all the elements of the array & print the same
Write a C program to read marks scored by each student in C
programming subject in first internal exam, and calculate the average.
Write a C program to find the largest element in an array of n elements
Write a C program to find the largest and smallest element in an array of
n elements
1 2 3 4 5
a[1]
a[0] a[2] a[3] a[4]
b[1]
b[0] b[2] b[3] b[4]
b[0] = a[0]
b[1] = a[1]
b[2] = a[2]
b[3] = a[3]
b[4] = a[4]
In general,
Write a C Program to copy the elements of one array to another array.
2
1 3 4 5
b[i] = a[i]
where i=0 to n-1
a
b
Write a C Program to copy the elements of one array to another array.
Write a C Program to perform element wise addition of two arrays a
and b in c.
1 2 3 4 5
a[1]
a[0] a[2] a[3] a[4]
6 7 8 9 10
b[1]
b[0] b[2] b[3] b[4]
7 9 11 13 15
c[1]
c[0] c[2] c[3] c[4]
c[0] = a[0]+b[0]
c[1] = a[1]+b[1]
c[2] = a[2]+b[2]
c[3] = a[3]+b[3]
c[4] = a[4]+b[4]
In general,
a
b
c
c[i] = a[i] + b[i]
where i=0 to n-1
Write a C Program to reverse the elements of an array of n elements.
Searching Techniques
Searching is an operation or a technique that helps to find a given element
or a value in the list of values. Any search is said to be successful or
unsuccessful depending upon whether the element that is being searched is
found or not.
Types of Searching Techniques
1. Linear Search
2. Binary Search
Write a C program to scan n array elements and perform linear search
for a given key element
Binary Search
Write a C program to scan n array elements and perform Binary search
for a given key element
Comparing Binary Search and Linear Search
Sorting Techniques
Sorting is the process of arranging the elements either in
ascending (or) descending order.
Types of Searching Techniques
1. Bubble Sort
2. Selection Sort
Bubble Sort
In Bubble sort, each element is compared with its adjacent element. If
the first element is bigger than the second one, then the positions of the
elements are interchanged. Otherwise it is not changed.
Then the next element is compared with its adjacent element and the
same process is repeated for all the elements in the array until we get a
sorted array.
Write a C Program to read n
arrays elements and sort the
elements of the array using
Bubble sort technique
Selection Sort
The selection sort algorithm sorts an
array by repeatedly finding the minimum
element (considering ascending order)
from unsorted part and putting it at the
beginning. The algorithm maintains two
sub arrays in a given array.
1) The sub array which is already sorted.
2) Remaining sub array which is unsorted.
In every iteration of selection sort, the
minimum element from the unsorted sub array
is picked and moved to the sorted sub array.
Write a C Program to read n arrays
elements and sort the elements of
the array using Selection sort
technique

Contenu connexe

Similaire à Arrays.pdf

arrays-120712074248-phpapp01
arrays-120712074248-phpapp01arrays-120712074248-phpapp01
arrays-120712074248-phpapp01
Abdul Samee
 
Prelim Project OOP
Prelim Project OOPPrelim Project OOP
Prelim Project OOP
Dwight Sabio
 
Mmt 001
Mmt 001Mmt 001
Mmt 001
sujatam8
 
Lab exp declaring arrays)
Lab exp declaring arrays)Lab exp declaring arrays)
Lab exp declaring arrays)
Daman Toor
 
Arrays in C.pptx
Arrays in C.pptxArrays in C.pptx
Arrays in C.pptx
HarsimranKaur362773
 
Comp 122 lab 6 lab report and source code
Comp 122 lab 6 lab report and source codeComp 122 lab 6 lab report and source code
Comp 122 lab 6 lab report and source code
pradesigali1
 
ARRAY in python and c with examples .pptx
ARRAY  in python and c with examples .pptxARRAY  in python and c with examples .pptx
ARRAY in python and c with examples .pptx
abhishekmaurya102515
 
Functions, Strings ,Storage classes in C
 Functions, Strings ,Storage classes in C Functions, Strings ,Storage classes in C
Functions, Strings ,Storage classes in C
arshpreetkaur07
 
Arrays
ArraysArrays
ppt on arrays in c programming language.pptx
ppt on arrays in c programming language.pptxppt on arrays in c programming language.pptx
ppt on arrays in c programming language.pptx
AmanRai352102
 
21CS32 DS Module 1 PPT.pptx
21CS32 DS Module 1 PPT.pptx21CS32 DS Module 1 PPT.pptx
21CS32 DS Module 1 PPT.pptx
reddy19841
 
PYTHON ALGORITHMS, DATA STRUCTURE, SORTING TECHNIQUES
PYTHON ALGORITHMS, DATA STRUCTURE, SORTING TECHNIQUESPYTHON ALGORITHMS, DATA STRUCTURE, SORTING TECHNIQUES
PYTHON ALGORITHMS, DATA STRUCTURE, SORTING TECHNIQUES
vanithasivdc
 
C programming session 05
C programming session 05C programming session 05
C programming session 05
Vivek Singh
 
Data structures arrays
Data structures   arraysData structures   arrays
Data structures arrays
maamir farooq
 
Lesson 18-20.pptx
Lesson 18-20.pptxLesson 18-20.pptx
Lesson 18-20.pptx
MIZANURRAHMANTUSHAR1
 
Unit-4 (Scope Rules and Arrays).pptx for
Unit-4 (Scope Rules and Arrays).pptx forUnit-4 (Scope Rules and Arrays).pptx for
Unit-4 (Scope Rules and Arrays).pptx for
pattinsonhenry524
 
C# Array.pptx
C# Array.pptxC# Array.pptx
C# Array.pptx
ZanyarRzgar
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
Dushmanta Nath
 
9781111530532 ppt ch09
9781111530532 ppt ch099781111530532 ppt ch09
9781111530532 ppt ch09
Terry Yoast
 
Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning material
ArthyR3
 

Similaire à Arrays.pdf (20)

arrays-120712074248-phpapp01
arrays-120712074248-phpapp01arrays-120712074248-phpapp01
arrays-120712074248-phpapp01
 
Prelim Project OOP
Prelim Project OOPPrelim Project OOP
Prelim Project OOP
 
Mmt 001
Mmt 001Mmt 001
Mmt 001
 
Lab exp declaring arrays)
Lab exp declaring arrays)Lab exp declaring arrays)
Lab exp declaring arrays)
 
Arrays in C.pptx
Arrays in C.pptxArrays in C.pptx
Arrays in C.pptx
 
Comp 122 lab 6 lab report and source code
Comp 122 lab 6 lab report and source codeComp 122 lab 6 lab report and source code
Comp 122 lab 6 lab report and source code
 
ARRAY in python and c with examples .pptx
ARRAY  in python and c with examples .pptxARRAY  in python and c with examples .pptx
ARRAY in python and c with examples .pptx
 
Functions, Strings ,Storage classes in C
 Functions, Strings ,Storage classes in C Functions, Strings ,Storage classes in C
Functions, Strings ,Storage classes in C
 
Arrays
ArraysArrays
Arrays
 
ppt on arrays in c programming language.pptx
ppt on arrays in c programming language.pptxppt on arrays in c programming language.pptx
ppt on arrays in c programming language.pptx
 
21CS32 DS Module 1 PPT.pptx
21CS32 DS Module 1 PPT.pptx21CS32 DS Module 1 PPT.pptx
21CS32 DS Module 1 PPT.pptx
 
PYTHON ALGORITHMS, DATA STRUCTURE, SORTING TECHNIQUES
PYTHON ALGORITHMS, DATA STRUCTURE, SORTING TECHNIQUESPYTHON ALGORITHMS, DATA STRUCTURE, SORTING TECHNIQUES
PYTHON ALGORITHMS, DATA STRUCTURE, SORTING TECHNIQUES
 
C programming session 05
C programming session 05C programming session 05
C programming session 05
 
Data structures arrays
Data structures   arraysData structures   arrays
Data structures arrays
 
Lesson 18-20.pptx
Lesson 18-20.pptxLesson 18-20.pptx
Lesson 18-20.pptx
 
Unit-4 (Scope Rules and Arrays).pptx for
Unit-4 (Scope Rules and Arrays).pptx forUnit-4 (Scope Rules and Arrays).pptx for
Unit-4 (Scope Rules and Arrays).pptx for
 
C# Array.pptx
C# Array.pptxC# Array.pptx
C# Array.pptx
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
 
9781111530532 ppt ch09
9781111530532 ppt ch099781111530532 ppt ch09
9781111530532 ppt ch09
 
Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning material
 

Dernier

cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
SakkaravarthiShanmug
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
Madan Karki
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
ecqow
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
Introduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptxIntroduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptx
MiscAnnoy1
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
AjmalKhan50578
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
BRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdfBRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdf
LAXMAREDDY22
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
Hematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood CountHematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood Count
shahdabdulbaset
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
21UME003TUSHARDEB
 

Dernier (20)

cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
Introduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptxIntroduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptx
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
BRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdfBRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdf
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
Hematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood CountHematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood Count
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
 

Arrays.pdf

  • 2. Arrays An array is collection of elements of similar data type. Why Arrays???? Arrays are used when there is a need to use many variables of the same type. Say you want to store marks scored by 60 students of our class in C programming subject, so how many variables you need to declare to hold 60 values? 60 variables? Will it be feasible? So use an array for the same task instead. The programmer has to just specify the data type of elements and the number of elements that are required as the size of the array. 60 variable’s declaration??? int s1,s2,s3,……..s60; Or int s[60] ; Which is easy???
  • 3. int a[5]; int a[5][5]; int a[5][5][5];
  • 4. One Dimensional Array (1D Array) Syntax for Declaring 1D Array Example for Declaring 1D Array int a[5]; Data_Type Array_Name[Size]; 1004 1000 1008 1012 1016 a[1] a[0] a[2] a[3] a[4] a Subscript or index, used to access the specific value from an array, a[3] gives 40 Name of the array Address of the array, in a contiguous manner
  • 5. Initializing 1D Array 1. Compile Time Initialization Types of compile time array initialization:  Complete array Initialization  Partial array Initialization  Initialization without size  Initialization with Zero 2. Runtime Initialization
  • 6. Compile Time Array Initializations 4. Initialization with Zero 3. Initialization without size 2. Partial Array Initialization 1. Complete array Initialization 1 2 3 4 5 1 2 3 0 0 1 2 3 4 5 0 0 0 0 0 a[1] a[0] a[2] a[3] a[4] a[1] a[0] a[2] a[3] a[4] a[1] a[0] a[2] a[3] a[4] a[1] a[0] a[2] a[3] a[4]
  • 7. Write a C Program to scan and print n array elements.
  • 8. Write a C Program to scan n elements in an array and find the sum and average of all the elements of the array & print the same
  • 9. Write a C program to read marks scored by each student in C programming subject in first internal exam, and calculate the average.
  • 10. Write a C program to find the largest element in an array of n elements
  • 11. Write a C program to find the largest and smallest element in an array of n elements
  • 12. 1 2 3 4 5 a[1] a[0] a[2] a[3] a[4] b[1] b[0] b[2] b[3] b[4] b[0] = a[0] b[1] = a[1] b[2] = a[2] b[3] = a[3] b[4] = a[4] In general, Write a C Program to copy the elements of one array to another array. 2 1 3 4 5 b[i] = a[i] where i=0 to n-1 a b
  • 13. Write a C Program to copy the elements of one array to another array.
  • 14. Write a C Program to perform element wise addition of two arrays a and b in c. 1 2 3 4 5 a[1] a[0] a[2] a[3] a[4] 6 7 8 9 10 b[1] b[0] b[2] b[3] b[4] 7 9 11 13 15 c[1] c[0] c[2] c[3] c[4] c[0] = a[0]+b[0] c[1] = a[1]+b[1] c[2] = a[2]+b[2] c[3] = a[3]+b[3] c[4] = a[4]+b[4] In general, a b c c[i] = a[i] + b[i] where i=0 to n-1
  • 15.
  • 16. Write a C Program to reverse the elements of an array of n elements.
  • 17. Searching Techniques Searching is an operation or a technique that helps to find a given element or a value in the list of values. Any search is said to be successful or unsuccessful depending upon whether the element that is being searched is found or not. Types of Searching Techniques 1. Linear Search 2. Binary Search
  • 18.
  • 19. Write a C program to scan n array elements and perform linear search for a given key element
  • 21. Write a C program to scan n array elements and perform Binary search for a given key element
  • 22. Comparing Binary Search and Linear Search
  • 23. Sorting Techniques Sorting is the process of arranging the elements either in ascending (or) descending order. Types of Searching Techniques 1. Bubble Sort 2. Selection Sort
  • 24. Bubble Sort In Bubble sort, each element is compared with its adjacent element. If the first element is bigger than the second one, then the positions of the elements are interchanged. Otherwise it is not changed. Then the next element is compared with its adjacent element and the same process is repeated for all the elements in the array until we get a sorted array.
  • 25. Write a C Program to read n arrays elements and sort the elements of the array using Bubble sort technique
  • 26. Selection Sort The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning. The algorithm maintains two sub arrays in a given array. 1) The sub array which is already sorted. 2) Remaining sub array which is unsorted. In every iteration of selection sort, the minimum element from the unsorted sub array is picked and moved to the sorted sub array.
  • 27. Write a C Program to read n arrays elements and sort the elements of the array using Selection sort technique