SlideShare a Scribd company logo
1 of 30
Vidhi Mehta
Unit 3
Arrays
What is Array?
 when we want to store more data type of the
same value we need to declare more variable
which leads to more memory utilization. C
supports array that is a derived data type.
 An array is a fixed size sequential group of
elements of the same data types which are
referred by common name. In other words array
is a collective name given to a group of ‘similar
quantities’.
 An array is a series of elements of the same
data type placed consecutively in memory
that can be individually referenced by adding
an index to a unique name.
Types of arrays
 There are 3 types of array:
 1) One-Dimensional array.
 2) Two-Dimensional array.
 3) Multi-Dimensional array.
1- Dimensional array
 A list of items can be given one variable name
using only one subscript and such a variable
is called a single subscripted variable or a
one dimensional array. The subscript begins
with 0.
How to declare 1-D array
 Type <variablename> [size];
 Eg:
 int a[5];
 float b[4];
 char c[5];
Initialization of 1D array
 After an array is declared, its elements must be
initialized. Otherwise they will contain “garbage”.
An array can be initialized at 2 stages:
 1) At compile time
 2) At runtime
Compile time initialization
 We can initialize the elements of array in the same
way as the ordinary variable during the time of
declaration.
 Syntax:
 type <array name> [size]={values};
 Eg:
 int a[4]={1,1,1,2};
 float b[4]={1.2, 2.34, 31.2,-2};
 The values in the list are separated by commas. The
size may be omitted. In such cases the compiler
allocates enough space for all initialized elements.
 Eg: int a[]={1,1,1,1};
 Here the variable a will contain four elements with
initial value 1.
 Compile time initialization may be partial. That is
number of initialize may be less than the declared
size. In such case the remaining elements are
initialized to zero in case of int and float type and
null in case of character.
 Eg:
 int a[4]={1,1};
 float b[2]={1.2,1.3};
 char c[4]={‘h’,’I’};
Run time initialization
 An array can be explicitly initialized at run time. This is
generally done for initializing large array.
 for(i=0;i<=200;i++)
{
If(i<50) {
Sum[i]=5.0;
}
Else {
Sum[i]=1.0;
}
 }
2D Array
 There could be situations where a table of values
will have to be stored. We can think of this table
as a matrix consisting of rows and columns. C
allows us to define such tables of items by using
2D array. 2D arrays are declared as follows:
 Syntax :
 Type <array name> [rows size] [column size];
 Eg : int table [3][3];
 Here the name of the array is table having 3 rows
and 3 columns.
 Initializing 2D array
 Int table[2][2]={0,0,1,1};
Multi Dimensional Array
 C allows arrays of three or more dimensions. The
exact limit is determined by the compiler.
 Syntax:
 type <array name> [size1][size2][size3]….[sizen];
 Eg: int a[3][3][2][5][6];
 ANSI C does not specify any limit for array
dimension. However, most compilers permit 7 to
10 dimensions.
Dynamic Arrays
 An array created at compile time by specifying size in
the source code has a fixed size and cannot be
modified at run time.
 The process of allocating memory at compile time is
known a static memory allocation and the arrays that
receive static memory allocation are called static
arrays.
 But in C it is possible to allocate memory to arrays at
run time. This feature is known as dynamic memory
allocation and the arrays created at run time are
called dynamic arrays.
 Dynamic arrays are created using pointer variables
and memory management functions called malloc,
calloc and realloc. These functions are included in the
Searching
 Searching is a process of finding the location of
the specified element in a list. The specified
element is often called the search key. If the
process of searching finds a match of the search
key with a list element value, the search is said to
be successful otherwise unsuccessful. The two
search techniques are:
 1.) Sequential Search
 2.) Binary Search
LINEAR SEARCH
 This is simplest technique to find out an element
in an unsorted list. Suppose, we have an
unsorted list which contain n elements and want
to search the value of a particular elements for
that we have to check each elements one by one
and find at any passion.
 One of the most straightforward and elementary
searches is the sequential search, also known as
a linear search.
Applications of Linear Search->
 To find out particular string linear search is
efficient
 Linear search is usually very simple to implement
and is practical when the list has only few
elements or when performing a single search in
an unordered list
 Pseduocode game is the eg of linear search
Merits of Linear Search->
 The primary advantage of linear search is its
simplicity.
 It is also very resource efficient and memory
efficient. It also operates equally well on both
unsorted and sorted data.
Demerits of Linear Search->
 It needs more space and time complexity
 In linear search if the key element is the last
element and the search is from first element that
is a worst case or if the key element is the first
element and the search is from last element then
also is the worst case.
BINARY SEARCH
 Binary search works for sorted list and it is very
efficient searching technique.
 It is used to find the location of given element or
record in the list. Other information associated
with the element can also be fetched if required.
 To find the location of a file in the computer
directory one can use this searching technique.
 If we are on the internet then it is not easy task
using linear search to find out the information
about some records or files.
 For this one prefers binary searching technique.
Applications of binary search
 Guessing game
 Word list
Merits of binary search
 Searching speed is fast
Demerits of binary search
 The disadvantage of binary search in any
language is that you must provide an ordered list.
Sorting
 Sorting means arranging a set of data in some
order. There are different methods that are used
to sort the data in ascending order or descending
order.
BUBBLE SORT
 It is very simple sorting technique thus this
technique is not efficient to other techniques.
Suppose we sort the element in descending
order. The bubble sort loops through the elements
in the list comparing the adjacent element and
moves the largest element to the top of the list.
 Application of Bubble Sort
 In a small group of data we can use bubble sort
like classroom
 Sorting data of friends group
 Sorting data of our books collection
 Merits of Bubble Sort
 Easy to implement
 Efficient for small data set
 A bubble sort is a sort where adjacent items in the
array or list are scanned repeatedly swapping as
necessary until one full scan performs no swaps.
 Demerits of Bubble Sort
 A bubble sort, sort N elements where N is the
size of array or list because of out of position item
is only moved one position per scan and sorting
continues until all the elements are not swapped.
 It is less efficient in large data set.
SELECTON SORT
 The selection sort starts from element and
searches the entire list until it find the minimum
value. The sort palace the minimum value in the
first place. select the second element and
searches for the smallest element. The process
continuous until the complete the list.
 The Selection Sort is a very basic sort. It works by
finding the smallest element in the array and
putting it at the beginning of the list and then
repeating that process on the unsorted remainder
of the data. Rather than making successive
swaps with adjacent elements like bubble sort,
selection sort makes only one, swapping the
smallest number with the number occupying its
correct position.
 Application of Selection Sort
 In a small group of data we can use selection sort
 Sorting of friends group
 Sorting of data of our books collection
 Merits of Selection Sort
 Easy to implement
 Efficient for small data set
 Demerits of Selection Sort
 The worst case occurs if the array is already
sorted in descending order.
 Selection sort spends most of its time trying to
find the minimum element in the unsorted part of
the array
 It clearly shows the similarity between selection
sort and bubble sort.

More Related Content

What's hot (20)

Array in c++
Array in c++Array in c++
Array in c++
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Array ppt
Array pptArray ppt
Array ppt
 
Array in c#
Array in c#Array in c#
Array in c#
 
Array in c
Array in cArray in c
Array in c
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
Strings in c
Strings in cStrings in c
Strings in c
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointers
 
Strings Functions in C Programming
Strings Functions in C ProgrammingStrings Functions in C Programming
Strings Functions in C Programming
 
Structure in C
Structure in CStructure in C
Structure in C
 
Array in C
Array in CArray in C
Array in C
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Arrays Basics
Arrays BasicsArrays Basics
Arrays Basics
 
Data types in C language
Data types in C languageData types in C language
Data types in C language
 
C++ string
C++ stringC++ string
C++ string
 
ARRAY
ARRAYARRAY
ARRAY
 
Dynamic memory allocation in c
Dynamic memory allocation in cDynamic memory allocation in c
Dynamic memory allocation in c
 
Enumerated data types in C
Enumerated data types in CEnumerated data types in C
Enumerated data types in C
 
Arrays C#
Arrays C#Arrays C#
Arrays C#
 

Similar to arrays in c

Similar to arrays in c (20)

DS - Unit 2 FINAL (2).pptx
DS - Unit 2 FINAL (2).pptxDS - Unit 2 FINAL (2).pptx
DS - Unit 2 FINAL (2).pptx
 
Data Structures_ Sorting & Searching
Data Structures_ Sorting & SearchingData Structures_ Sorting & Searching
Data Structures_ Sorting & Searching
 
Array.pdf
Array.pdfArray.pdf
Array.pdf
 
Arrays
ArraysArrays
Arrays
 
4.1 sequentioal search
4.1 sequentioal search4.1 sequentioal search
4.1 sequentioal search
 
advanced searching and sorting.pdf
advanced searching and sorting.pdfadvanced searching and sorting.pdf
advanced searching and sorting.pdf
 
Unit v data structure-converted
Unit  v data structure-convertedUnit  v data structure-converted
Unit v data structure-converted
 
Arrays
ArraysArrays
Arrays
 
Sorting
SortingSorting
Sorting
 
arrayppt.pptx
arrayppt.pptxarrayppt.pptx
arrayppt.pptx
 
Searching,sorting
Searching,sortingSearching,sorting
Searching,sorting
 
MODULE 5-Searching and-sorting
MODULE 5-Searching and-sortingMODULE 5-Searching and-sorting
MODULE 5-Searching and-sorting
 
ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
 
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHIBCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
 
arrays
arraysarrays
arrays
 
searching
searchingsearching
searching
 
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
 
SORTING techniques.pptx
SORTING techniques.pptxSORTING techniques.pptx
SORTING techniques.pptx
 
searching
searchingsearching
searching
 

Recently uploaded

chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
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
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spaintimesproduction05
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Christo Ananth
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLManishPatel169454
 
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
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 

Recently uploaded (20)

chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
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
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
(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 for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
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...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
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
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 

arrays in c

  • 2. What is Array?  when we want to store more data type of the same value we need to declare more variable which leads to more memory utilization. C supports array that is a derived data type.  An array is a fixed size sequential group of elements of the same data types which are referred by common name. In other words array is a collective name given to a group of ‘similar quantities’.  An array is a series of elements of the same data type placed consecutively in memory that can be individually referenced by adding an index to a unique name.
  • 3. Types of arrays  There are 3 types of array:  1) One-Dimensional array.  2) Two-Dimensional array.  3) Multi-Dimensional array.
  • 4. 1- Dimensional array  A list of items can be given one variable name using only one subscript and such a variable is called a single subscripted variable or a one dimensional array. The subscript begins with 0.
  • 5. How to declare 1-D array  Type <variablename> [size];  Eg:  int a[5];  float b[4];  char c[5];
  • 6.
  • 7. Initialization of 1D array  After an array is declared, its elements must be initialized. Otherwise they will contain “garbage”. An array can be initialized at 2 stages:  1) At compile time  2) At runtime
  • 8. Compile time initialization  We can initialize the elements of array in the same way as the ordinary variable during the time of declaration.  Syntax:  type <array name> [size]={values};  Eg:  int a[4]={1,1,1,2};  float b[4]={1.2, 2.34, 31.2,-2};  The values in the list are separated by commas. The size may be omitted. In such cases the compiler allocates enough space for all initialized elements.  Eg: int a[]={1,1,1,1};  Here the variable a will contain four elements with initial value 1.
  • 9.  Compile time initialization may be partial. That is number of initialize may be less than the declared size. In such case the remaining elements are initialized to zero in case of int and float type and null in case of character.  Eg:  int a[4]={1,1};  float b[2]={1.2,1.3};  char c[4]={‘h’,’I’};
  • 10. Run time initialization  An array can be explicitly initialized at run time. This is generally done for initializing large array.  for(i=0;i<=200;i++) { If(i<50) { Sum[i]=5.0; } Else { Sum[i]=1.0; }  }
  • 11. 2D Array  There could be situations where a table of values will have to be stored. We can think of this table as a matrix consisting of rows and columns. C allows us to define such tables of items by using 2D array. 2D arrays are declared as follows:  Syntax :  Type <array name> [rows size] [column size];  Eg : int table [3][3];  Here the name of the array is table having 3 rows and 3 columns.  Initializing 2D array  Int table[2][2]={0,0,1,1};
  • 12. Multi Dimensional Array  C allows arrays of three or more dimensions. The exact limit is determined by the compiler.  Syntax:  type <array name> [size1][size2][size3]….[sizen];  Eg: int a[3][3][2][5][6];  ANSI C does not specify any limit for array dimension. However, most compilers permit 7 to 10 dimensions.
  • 13. Dynamic Arrays  An array created at compile time by specifying size in the source code has a fixed size and cannot be modified at run time.  The process of allocating memory at compile time is known a static memory allocation and the arrays that receive static memory allocation are called static arrays.  But in C it is possible to allocate memory to arrays at run time. This feature is known as dynamic memory allocation and the arrays created at run time are called dynamic arrays.  Dynamic arrays are created using pointer variables and memory management functions called malloc, calloc and realloc. These functions are included in the
  • 14. Searching  Searching is a process of finding the location of the specified element in a list. The specified element is often called the search key. If the process of searching finds a match of the search key with a list element value, the search is said to be successful otherwise unsuccessful. The two search techniques are:  1.) Sequential Search  2.) Binary Search
  • 15. LINEAR SEARCH  This is simplest technique to find out an element in an unsorted list. Suppose, we have an unsorted list which contain n elements and want to search the value of a particular elements for that we have to check each elements one by one and find at any passion.  One of the most straightforward and elementary searches is the sequential search, also known as a linear search.
  • 16. Applications of Linear Search->  To find out particular string linear search is efficient  Linear search is usually very simple to implement and is practical when the list has only few elements or when performing a single search in an unordered list  Pseduocode game is the eg of linear search
  • 17. Merits of Linear Search->  The primary advantage of linear search is its simplicity.  It is also very resource efficient and memory efficient. It also operates equally well on both unsorted and sorted data.
  • 18. Demerits of Linear Search->  It needs more space and time complexity  In linear search if the key element is the last element and the search is from first element that is a worst case or if the key element is the first element and the search is from last element then also is the worst case.
  • 19. BINARY SEARCH  Binary search works for sorted list and it is very efficient searching technique.  It is used to find the location of given element or record in the list. Other information associated with the element can also be fetched if required.  To find the location of a file in the computer directory one can use this searching technique.  If we are on the internet then it is not easy task using linear search to find out the information about some records or files.  For this one prefers binary searching technique.
  • 20. Applications of binary search  Guessing game  Word list
  • 21. Merits of binary search  Searching speed is fast
  • 22. Demerits of binary search  The disadvantage of binary search in any language is that you must provide an ordered list.
  • 23. Sorting  Sorting means arranging a set of data in some order. There are different methods that are used to sort the data in ascending order or descending order.
  • 24. BUBBLE SORT  It is very simple sorting technique thus this technique is not efficient to other techniques. Suppose we sort the element in descending order. The bubble sort loops through the elements in the list comparing the adjacent element and moves the largest element to the top of the list.
  • 25.  Application of Bubble Sort  In a small group of data we can use bubble sort like classroom  Sorting data of friends group  Sorting data of our books collection
  • 26.  Merits of Bubble Sort  Easy to implement  Efficient for small data set  A bubble sort is a sort where adjacent items in the array or list are scanned repeatedly swapping as necessary until one full scan performs no swaps.
  • 27.  Demerits of Bubble Sort  A bubble sort, sort N elements where N is the size of array or list because of out of position item is only moved one position per scan and sorting continues until all the elements are not swapped.  It is less efficient in large data set.
  • 28. SELECTON SORT  The selection sort starts from element and searches the entire list until it find the minimum value. The sort palace the minimum value in the first place. select the second element and searches for the smallest element. The process continuous until the complete the list.  The Selection Sort is a very basic sort. It works by finding the smallest element in the array and putting it at the beginning of the list and then repeating that process on the unsorted remainder of the data. Rather than making successive swaps with adjacent elements like bubble sort, selection sort makes only one, swapping the smallest number with the number occupying its correct position.
  • 29.  Application of Selection Sort  In a small group of data we can use selection sort  Sorting of friends group  Sorting of data of our books collection
  • 30.  Merits of Selection Sort  Easy to implement  Efficient for small data set  Demerits of Selection Sort  The worst case occurs if the array is already sorted in descending order.  Selection sort spends most of its time trying to find the minimum element in the unsorted part of the array  It clearly shows the similarity between selection sort and bubble sort.