SlideShare a Scribd company logo
10
Most read
13
Most read
16
Most read
DATA STRUCTURE
ARRAY
Type of Data Structure
2
Data Type
thanks to www.tutorialspoint.com
3
 Data type determines the values that can be used with the
corresponding type of data, the type of operations that can be
performed on the corresponding type of data. There are two
data types:
 Built-In Data Type
 Derived Data Type
 Built-In Data Type
 Those data types for which a language has built-in support are
known as built-in data types. Most of the languages provide the
following built-in data types.
 Examples: Integer, Float, Boolean, Character and String
Data Type (Continued…)
thanks to www.tutorialspoint.com
4
 Derived Data Type
 Those data types which are implementation independent, as
they can be implemented in one or the other way are known
as derived data types. There are normally built by the
combination of built-in data types and associated operations
on them.
 Examples: List, Array, Stack, Queue
 Basic Operations
 The data in the data structures are processed by certain
operations. These operations include the following:
 Traversing, Searching, Insertion, Deletion, Sorting, Merging etc
Array
thanks to www.tutorialspoint.com
5
 Array is a container which can hold a fix number of items
and these items should be of same type. Following are the
important terms of array:
 Element & Index
 Array Representation
Total Number of Elements in array
6
Basic Operations of an Array
thanks to www.tutorialspoint.com
7
 Following are the basic operations supported by an array:
 Traverse – Print all the array elements one by one
 Insertion – Adds an element at the given index
 Deletion – Deletes an element at the given index
 Search – Searches an element using the given index or by
the value
 Update – Updates an element at the given index
Traversing with Array (Examples)
8
 Total
 Finding even and odd
 Checking fail and pass
 More ?
Insertion with Array
9
 Insertion at end
 Insertion at start
 Insertion at the specified location
Insertion Operation
10
 Insert operation is to insert one or more data elements
into an array. Based on the requirement, a new element
can be added at the beginning, end, or any given index of
array.
 Let LA be a Linear Array (unordered) with N elements
and K is a positive integer such that K<=N. Following is
the algorithm where ITEM is inserted into the Kth position
of LA.
Insertion Operation (Algorithm)
11
1. Start
2. Set J = N
3. Repeat Step 4 and 5 while J >= K
4. Set LA[ J + 1 ] = LA[ J ]
5. Set J = J – 1
6. Set LA[ K ] = ITEM
7. Stop
Insertion Example
12
 int arr[5] = {4, 1, 8, 2};
 int val,loc;
 cout<<"enter value to insert"<<endl;
 cin>>val;
 cout<<"enter location"<<endl;
 cin>>loc;
 for(int i=4; i>loc; i--){
 // arr[i+1]=arr[i];
 arr[i]=arr[i-1];
 }
 arr[loc]=val;
 for(int i=0; i<=4; i++)
 cout<<"Values are "<<i<< " = "<<arr[i]<<endl;
Deletion Operation
thanks to www.tutorialspoint.com
13
 Deletion refers to removing an existing element from the
array and re-organizing all elements of an array.
 Consider LA is a linear array with N elements and K is a
positive integer such that K<=N. Following is the algorithm
to delete an element available at the Kthposition of LA.
 Complexity…?
Deletion Operation (Algorithm)
thanks to www.tutorialspoint.com
14
1. Start
2. Set J = K
3. Repeat Step 4 and 5 while J < N
4. Set LA[ J ] = LA[ J+1 ]
5. Set J = J + 1
6. Set N = N – 1
7. Stop
Search Operation
thanks to www.tutorialspoint.com
15
 You can perform a search for an array element based on
its value or its index.
 Consider LA is a linear array with N elements and K is a
positive integer such that K<=N. Following is the algorithm
to find an element with a value of ITEM using sequential
search.
 Complexity…?
Search Operation (Algorithm)
thanks to www.tutorialspoint.com
16
1. Start
2. Set J = 0
3. Repeat Step 4 and 5 while J < N
4. IF LA [ J ] is equal ITEM THEN GOTO Step 6
5. Set J = J + 1
6. Print J, ITEM
7. Stop
Update Operation
thanks to www.tutorialspoint.com
17
 Update operation refers to updating an existing element from
the array at a given index.
 Consider LA is a linear array with N elements and K is a
positive integer such that K<=N. Following is the algorithm to
update an element available at the Kth position of LA.
1. Start
2. Set LA [ K – 1 ] = ITEM
3. Stop
 Complexity…?
18
int main(){
int input[100], count, i, num;
cout << "Enter Number of Elements in Arrayn";
cin >> count;
cout << "Enter " << count << " numbers n";
// Read array elements
for(i = 0; i < count; i++){
cin >> input[i];
}
cout << "Enter a number to serach in Arrayn";
cin >> num;
// search num in inputArray from index 0 to elementCount-1
for(i = 0; i < count; i++){
if(input[i] == num){
cout << "Element found at index " << i;
break;
}
}
if(i == count){
cout << "Element Not Present in Input Arrayn";
}
return 0;
}
Ad

Recommended

DSA - Array.pptx
DSA - Array.pptx
11STEM2PGROUP1
 
Array data structure
Array data structure
maamir farooq
 
Array data structure
Array data structure
harsh112327
 
DS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and Engineering
RAJASEKHARV8
 
DATA STRUCTURES USING C -ENGGDIGEST
DATA STRUCTURES USING C -ENGGDIGEST
Swapnil Mishra
 
8.DATA STRUCTURES UNIT 1 AND 2 CS3301PPT.pptx
8.DATA STRUCTURES UNIT 1 AND 2 CS3301PPT.pptx
venigkrish89
 
TSAT Presentation1.pptx
TSAT Presentation1.pptx
Rajitha Reddy Alugati
 
9 Arrays
9 Arrays
Praveen M Jigajinni
 
arrays
arrays
Enakshi Chanda
 
Array linear data_structure_2 (1)
Array linear data_structure_2 (1)
eShikshak
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
blessyboban92
 
Data structures
Data structures
naveeth babu
 
1.1 ADS data-structure.pdf
1.1 ADS data-structure.pdf
RameshBabuKellamapal
 
chapter-4-data-structure.pdf
chapter-4-data-structure.pdf
study material
 
Chap10
Chap10
Terry Yoast
 
Data structures in c#
Data structures in c#
SivaSankar Gorantla
 
Data structure ppt
Data structure ppt
Prof. Dr. K. Adisesha
 
Updated Lab3.docx
Updated Lab3.docx
AleezaAnjum
 
Data structure using c module 1
Data structure using c module 1
smruti sarangi
 
An Introduction to Stack Data Structures
An Introduction to Stack Data Structures
berggold2024
 
introduction stacks in data structures and algorithms
introduction stacks in data structures and algorithms
sneham64878
 
Chapter 14
Chapter 14
Terry Yoast
 
arrays1.ppt python programme arrays insertion
arrays1.ppt python programme arrays insertion
bushraashraf639
 
01-intro_stacks.ppt
01-intro_stacks.ppt
soniya555961
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Malikireddy Bramhananda Reddy
 
9781439035665 ppt ch09
9781439035665 ppt ch09
Terry Yoast
 
data structures with algorithms vtu 2023 notes.pptx
data structures with algorithms vtu 2023 notes.pptx
hemanthkumar40680
 
Unit ii data structure-converted
Unit ii data structure-converted
Shri Shankaracharya College, Bhilai,Junwani
 
Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 

More Related Content

Similar to Array Operations.pptxdata structure array indsa (20)

arrays
arrays
Enakshi Chanda
 
Array linear data_structure_2 (1)
Array linear data_structure_2 (1)
eShikshak
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
blessyboban92
 
Data structures
Data structures
naveeth babu
 
1.1 ADS data-structure.pdf
1.1 ADS data-structure.pdf
RameshBabuKellamapal
 
chapter-4-data-structure.pdf
chapter-4-data-structure.pdf
study material
 
Chap10
Chap10
Terry Yoast
 
Data structures in c#
Data structures in c#
SivaSankar Gorantla
 
Data structure ppt
Data structure ppt
Prof. Dr. K. Adisesha
 
Updated Lab3.docx
Updated Lab3.docx
AleezaAnjum
 
Data structure using c module 1
Data structure using c module 1
smruti sarangi
 
An Introduction to Stack Data Structures
An Introduction to Stack Data Structures
berggold2024
 
introduction stacks in data structures and algorithms
introduction stacks in data structures and algorithms
sneham64878
 
Chapter 14
Chapter 14
Terry Yoast
 
arrays1.ppt python programme arrays insertion
arrays1.ppt python programme arrays insertion
bushraashraf639
 
01-intro_stacks.ppt
01-intro_stacks.ppt
soniya555961
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Malikireddy Bramhananda Reddy
 
9781439035665 ppt ch09
9781439035665 ppt ch09
Terry Yoast
 
data structures with algorithms vtu 2023 notes.pptx
data structures with algorithms vtu 2023 notes.pptx
hemanthkumar40680
 
Unit ii data structure-converted
Unit ii data structure-converted
Shri Shankaracharya College, Bhilai,Junwani
 
Array linear data_structure_2 (1)
Array linear data_structure_2 (1)
eShikshak
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
blessyboban92
 
chapter-4-data-structure.pdf
chapter-4-data-structure.pdf
study material
 
Updated Lab3.docx
Updated Lab3.docx
AleezaAnjum
 
Data structure using c module 1
Data structure using c module 1
smruti sarangi
 
An Introduction to Stack Data Structures
An Introduction to Stack Data Structures
berggold2024
 
introduction stacks in data structures and algorithms
introduction stacks in data structures and algorithms
sneham64878
 
arrays1.ppt python programme arrays insertion
arrays1.ppt python programme arrays insertion
bushraashraf639
 
01-intro_stacks.ppt
01-intro_stacks.ppt
soniya555961
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Malikireddy Bramhananda Reddy
 
9781439035665 ppt ch09
9781439035665 ppt ch09
Terry Yoast
 
data structures with algorithms vtu 2023 notes.pptx
data structures with algorithms vtu 2023 notes.pptx
hemanthkumar40680
 

Recently uploaded (20)

Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
SHERAZ AHMAD LONE
 
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
 
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
 
NSUMD_M1 Library Orientation_June 11, 2025.pptx
NSUMD_M1 Library Orientation_June 11, 2025.pptx
Julie Sarpy
 
How to Customize Quotation Layouts in Odoo 18
How to Customize Quotation Layouts in Odoo 18
Celine George
 
Tanja Vujicic - PISA for Schools contact Info
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
 
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
How to Manage Different Customer Addresses in Odoo 18 Accounting
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
Assisting Individuals and Families to Promote and Maintain Health – Unit 7 | ...
Assisting Individuals and Families to Promote and Maintain Health – Unit 7 | ...
RAKESH SAJJAN
 
How payment terms are configured in Odoo 18
How payment terms are configured in Odoo 18
Celine George
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
 
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
SHERAZ AHMAD LONE
 
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
 
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
 
NSUMD_M1 Library Orientation_June 11, 2025.pptx
NSUMD_M1 Library Orientation_June 11, 2025.pptx
Julie Sarpy
 
How to Customize Quotation Layouts in Odoo 18
How to Customize Quotation Layouts in Odoo 18
Celine George
 
Tanja Vujicic - PISA for Schools contact Info
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
 
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
How to Manage Different Customer Addresses in Odoo 18 Accounting
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
Assisting Individuals and Families to Promote and Maintain Health – Unit 7 | ...
Assisting Individuals and Families to Promote and Maintain Health – Unit 7 | ...
RAKESH SAJJAN
 
How payment terms are configured in Odoo 18
How payment terms are configured in Odoo 18
Celine George
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
Ad

Array Operations.pptxdata structure array indsa

  • 2. Type of Data Structure 2
  • 3. Data Type thanks to www.tutorialspoint.com 3  Data type determines the values that can be used with the corresponding type of data, the type of operations that can be performed on the corresponding type of data. There are two data types:  Built-In Data Type  Derived Data Type  Built-In Data Type  Those data types for which a language has built-in support are known as built-in data types. Most of the languages provide the following built-in data types.  Examples: Integer, Float, Boolean, Character and String
  • 4. Data Type (Continued…) thanks to www.tutorialspoint.com 4  Derived Data Type  Those data types which are implementation independent, as they can be implemented in one or the other way are known as derived data types. There are normally built by the combination of built-in data types and associated operations on them.  Examples: List, Array, Stack, Queue  Basic Operations  The data in the data structures are processed by certain operations. These operations include the following:  Traversing, Searching, Insertion, Deletion, Sorting, Merging etc
  • 5. Array thanks to www.tutorialspoint.com 5  Array is a container which can hold a fix number of items and these items should be of same type. Following are the important terms of array:  Element & Index  Array Representation
  • 6. Total Number of Elements in array 6
  • 7. Basic Operations of an Array thanks to www.tutorialspoint.com 7  Following are the basic operations supported by an array:  Traverse – Print all the array elements one by one  Insertion – Adds an element at the given index  Deletion – Deletes an element at the given index  Search – Searches an element using the given index or by the value  Update – Updates an element at the given index
  • 8. Traversing with Array (Examples) 8  Total  Finding even and odd  Checking fail and pass  More ?
  • 9. Insertion with Array 9  Insertion at end  Insertion at start  Insertion at the specified location
  • 10. Insertion Operation 10  Insert operation is to insert one or more data elements into an array. Based on the requirement, a new element can be added at the beginning, end, or any given index of array.  Let LA be a Linear Array (unordered) with N elements and K is a positive integer such that K<=N. Following is the algorithm where ITEM is inserted into the Kth position of LA.
  • 11. Insertion Operation (Algorithm) 11 1. Start 2. Set J = N 3. Repeat Step 4 and 5 while J >= K 4. Set LA[ J + 1 ] = LA[ J ] 5. Set J = J – 1 6. Set LA[ K ] = ITEM 7. Stop
  • 12. Insertion Example 12  int arr[5] = {4, 1, 8, 2};  int val,loc;  cout<<"enter value to insert"<<endl;  cin>>val;  cout<<"enter location"<<endl;  cin>>loc;  for(int i=4; i>loc; i--){  // arr[i+1]=arr[i];  arr[i]=arr[i-1];  }  arr[loc]=val;  for(int i=0; i<=4; i++)  cout<<"Values are "<<i<< " = "<<arr[i]<<endl;
  • 13. Deletion Operation thanks to www.tutorialspoint.com 13  Deletion refers to removing an existing element from the array and re-organizing all elements of an array.  Consider LA is a linear array with N elements and K is a positive integer such that K<=N. Following is the algorithm to delete an element available at the Kthposition of LA.  Complexity…?
  • 14. Deletion Operation (Algorithm) thanks to www.tutorialspoint.com 14 1. Start 2. Set J = K 3. Repeat Step 4 and 5 while J < N 4. Set LA[ J ] = LA[ J+1 ] 5. Set J = J + 1 6. Set N = N – 1 7. Stop
  • 15. Search Operation thanks to www.tutorialspoint.com 15  You can perform a search for an array element based on its value or its index.  Consider LA is a linear array with N elements and K is a positive integer such that K<=N. Following is the algorithm to find an element with a value of ITEM using sequential search.  Complexity…?
  • 16. Search Operation (Algorithm) thanks to www.tutorialspoint.com 16 1. Start 2. Set J = 0 3. Repeat Step 4 and 5 while J < N 4. IF LA [ J ] is equal ITEM THEN GOTO Step 6 5. Set J = J + 1 6. Print J, ITEM 7. Stop
  • 17. Update Operation thanks to www.tutorialspoint.com 17  Update operation refers to updating an existing element from the array at a given index.  Consider LA is a linear array with N elements and K is a positive integer such that K<=N. Following is the algorithm to update an element available at the Kth position of LA. 1. Start 2. Set LA [ K – 1 ] = ITEM 3. Stop  Complexity…?
  • 18. 18 int main(){ int input[100], count, i, num; cout << "Enter Number of Elements in Arrayn"; cin >> count; cout << "Enter " << count << " numbers n"; // Read array elements for(i = 0; i < count; i++){ cin >> input[i]; } cout << "Enter a number to serach in Arrayn"; cin >> num; // search num in inputArray from index 0 to elementCount-1 for(i = 0; i < count; i++){ if(input[i] == num){ cout << "Element found at index " << i; break; } } if(i == count){ cout << "Element Not Present in Input Arrayn"; } return 0; }