SlideShare a Scribd company logo
Array operations
It Is An Ordered List, Which Consist Of 
A Fixed Number Of Homogeneous Data 
Items (Elements).An Array Is A Primitive 
Data Structure. These Elements Are 
Stored In Successive Memory Locations 
According To Size Of Data Type. Array Is 
Also Referred As Set Of (Index , Value).
(index) 
A[0] A[1] A[2] A[3] A[4] A[5] A[MAX -1] 
10 5 46 2 100 97 ... 
Data element value
The Insert Operation Is Performed By 
Shifting All The Elements One Position 
Ahead From Index iTo N-1 Where i Is The 
Specified Index For New Element Is To Be 
Inserted. And Adding The New Element To 
The Array At The Specified Index Position.
For example, 
index for insertion is i=2 and new element is 17 with N=6. the 
MAX is the size of the array A. 
A[0] A[1] A[2] … A[N-1] A[MAX-1] 
10 5 46 2 100 97 … 
Insert index position 
Move All Elements From Insert Index Position I N-1 Towards Right By One Position 
A[0] 1 2 3 4 5 A[6] A[MAX-1] 
10 5 46 2 100 97 … 
Insert Index Position
A[0] 1 2 3 4 5 A[6] A[MAX-1] 
10 5 46 46 2 100 97 … 
Insert index position 
Shifted elements
Now, insert (store) new data element 17 at given index position 2: 
A[0] 1 2 3 4 5 A[6] A[MAX-1] 
10 5 17 46 2 100 97 … 
Inserted element 
For Every New Element Inserted The Number Of Elements 
I.E N Should Be Incremented By 1. If N= Max-1 Then Array 
Is Full And Insertion Operation Cannot Be Performed As 
There Is No Space For New Element In The Array.
The delete operation will delete the element at 
specified element index from one-dimensional array. 
The deletion operation performed by shifting all the 
elements one position before from index i=1 to N-1 
where i is the index of element to be deleted. A[i] = 
A[i+1], for all i to N-1 . This shifting causes 
overwriting of the said element with element at next 
index position.
For example, 
For an array N=7 and index position for deletion is 
i=3 and maximum array size as MAX. 
A[0] 1 2 3 4 5 A[6] A[MAX-1] 
10 5 17 46 2 100 97 … 
Delete Index Position 
Now , Shift All Element From Index 4 To 6 One Position Before As Below: 
A[0] 1 2 3 4 5 A[6] A[MAX-1] 
10 5 17 46 2 100 97 … 
Element At Index 3 
The Array After The Shifting Backward Is:
A[0] 1 2 3 4 A[5] A[MAX-1] 
10 5 17 2 100 97 97 … 
Last element of array 
The element 46 is deleted from the array. After every 
delete operation the number of elements N should be 
decrement by 1. if array is empty , the deletion operation 
cannot be performed .
Array operations
Ad

More Related Content

What's hot (20)

Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
KristinaBorooah
 
Linked List - Insertion & Deletion
Linked List - Insertion & DeletionLinked List - Insertion & Deletion
Linked List - Insertion & Deletion
Afaq Mansoor Khan
 
sorting and its types
sorting and its typessorting and its types
sorting and its types
SIVASHANKARIRAJAN
 
Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive
Raj Naik
 
Linked list
Linked listLinked list
Linked list
KalaivaniKS1
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
Binary Search
Binary SearchBinary Search
Binary Search
kunj desai
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structure
Vardhil Patel
 
Stack
StackStack
Stack
Zaid Shabbir
 
Hashing in datastructure
Hashing in datastructureHashing in datastructure
Hashing in datastructure
rajshreemuthiah
 
Linked list
Linked listLinked list
Linked list
Trupti Agrawal
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
SHAKOOR AB
 
Binary search
Binary searchBinary search
Binary search
AparnaKumari31
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
Kevin Jadiya
 
Hash table
Hash tableHash table
Hash table
Rajendran
 
2D Array
2D Array 2D Array
2D Array
Ehatsham Riaz
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
V.V.Vanniaperumal College for Women
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
MAHALAKSHMI P
 
AVL Tree in Data Structure
AVL Tree in Data Structure AVL Tree in Data Structure
AVL Tree in Data Structure
Vrushali Dhanokar
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
Ninad Mankar
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
KristinaBorooah
 
Linked List - Insertion & Deletion
Linked List - Insertion & DeletionLinked List - Insertion & Deletion
Linked List - Insertion & Deletion
Afaq Mansoor Khan
 
Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive
Raj Naik
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structure
Vardhil Patel
 
Hashing in datastructure
Hashing in datastructureHashing in datastructure
Hashing in datastructure
rajshreemuthiah
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
SHAKOOR AB
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
Kevin Jadiya
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
MAHALAKSHMI P
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
Ninad Mankar
 

Viewers also liked (8)

القوائم المترابطة Linked List باستخدام لغة جافا
القوائم المترابطة Linked List باستخدام لغة جافاالقوائم المترابطة Linked List باستخدام لغة جافا
القوائم المترابطة Linked List باستخدام لغة جافا
Mahmoud Alfarra
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
Sriram Raj
 
المحاضرة الثامنة: تراكيب البيانات الطابور
المحاضرة الثامنة: تراكيب البيانات الطابورالمحاضرة الثامنة: تراكيب البيانات الطابور
المحاضرة الثامنة: تراكيب البيانات الطابور
Mahmoud Alfarra
 
3 Array operations
3   Array operations3   Array operations
3 Array operations
Mahmoud Alfarra
 
1 intro of data structure course
1  intro of data structure course1  intro of data structure course
1 intro of data structure course
Mahmoud Alfarra
 
2 introduction to data structure
2  introduction to data structure2  introduction to data structure
2 introduction to data structure
Mahmoud Alfarra
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in C
Smit Parikh
 
Data structure and algorithm with java implementation by obaid kakar
Data structure and algorithm with java implementation by obaid kakarData structure and algorithm with java implementation by obaid kakar
Data structure and algorithm with java implementation by obaid kakar
Obaid Kakar
 
القوائم المترابطة Linked List باستخدام لغة جافا
القوائم المترابطة Linked List باستخدام لغة جافاالقوائم المترابطة Linked List باستخدام لغة جافا
القوائم المترابطة Linked List باستخدام لغة جافا
Mahmoud Alfarra
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
Sriram Raj
 
المحاضرة الثامنة: تراكيب البيانات الطابور
المحاضرة الثامنة: تراكيب البيانات الطابورالمحاضرة الثامنة: تراكيب البيانات الطابور
المحاضرة الثامنة: تراكيب البيانات الطابور
Mahmoud Alfarra
 
1 intro of data structure course
1  intro of data structure course1  intro of data structure course
1 intro of data structure course
Mahmoud Alfarra
 
2 introduction to data structure
2  introduction to data structure2  introduction to data structure
2 introduction to data structure
Mahmoud Alfarra
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in C
Smit Parikh
 
Data structure and algorithm with java implementation by obaid kakar
Data structure and algorithm with java implementation by obaid kakarData structure and algorithm with java implementation by obaid kakar
Data structure and algorithm with java implementation by obaid kakar
Obaid Kakar
 
Ad

Similar to Array operations (20)

array-140928101958-pyyyyyyyyyyyhpapp02.pptx
array-140928101958-pyyyyyyyyyyyhpapp02.pptxarray-140928101958-pyyyyyyyyyyyhpapp02.pptx
array-140928101958-pyyyyyyyyyyyhpapp02.pptx
shesnasuneer
 
A sorted linear array
A sorted linear array A sorted linear array
A sorted linear array
Suneel Dogra
 
AD3251-LINKED LIST,STACK ADT,QUEUE ADT.docx
AD3251-LINKED LIST,STACK ADT,QUEUE ADT.docxAD3251-LINKED LIST,STACK ADT,QUEUE ADT.docx
AD3251-LINKED LIST,STACK ADT,QUEUE ADT.docx
AmuthachenthiruK
 
Sorting techniques
Sorting techniquesSorting techniques
Sorting techniques
Sukhvinder Singh
 
Insertion and Redix Sort
Insertion and Redix SortInsertion and Redix Sort
Insertion and Redix Sort
Sukhvinder Singh
 
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptxUNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
kncetaruna
 
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptxUNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
VISWANATHAN R V
 
DSA Unit II array.pptx
DSA Unit II array.pptxDSA Unit II array.pptx
DSA Unit II array.pptx
sayalishivarkar1
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)
swajahatr
 
MODULE 5-Searching and-sorting
MODULE 5-Searching and-sortingMODULE 5-Searching and-sorting
MODULE 5-Searching and-sorting
nikshaikh786
 
Linked list
Linked listLinked list
Linked list
Young Alista
 
Linked list
Linked listLinked list
Linked list
James Wong
 
Linked list
Linked listLinked list
Linked list
Tony Nguyen
 
Linked list
Linked listLinked list
Linked list
Harry Potter
 
Linked list
Linked listLinked list
Linked list
Hoang Nguyen
 
Linked list
Linked listLinked list
Linked list
Fraboni Ec
 
Linked list
Linked listLinked list
Linked list
Luis Goldster
 
Array Presentation
Array PresentationArray Presentation
Array Presentation
Deep Prajapati Microplacer
 
Arrays.pptx
Arrays.pptxArrays.pptx
Arrays.pptx
Koteswari Kasireddy
 
Arrays
ArraysArrays
Arrays
SARITHA REDDY
 
array-140928101958-pyyyyyyyyyyyhpapp02.pptx
array-140928101958-pyyyyyyyyyyyhpapp02.pptxarray-140928101958-pyyyyyyyyyyyhpapp02.pptx
array-140928101958-pyyyyyyyyyyyhpapp02.pptx
shesnasuneer
 
A sorted linear array
A sorted linear array A sorted linear array
A sorted linear array
Suneel Dogra
 
AD3251-LINKED LIST,STACK ADT,QUEUE ADT.docx
AD3251-LINKED LIST,STACK ADT,QUEUE ADT.docxAD3251-LINKED LIST,STACK ADT,QUEUE ADT.docx
AD3251-LINKED LIST,STACK ADT,QUEUE ADT.docx
AmuthachenthiruK
 
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptxUNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
kncetaruna
 
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptxUNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
VISWANATHAN R V
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)
swajahatr
 
MODULE 5-Searching and-sorting
MODULE 5-Searching and-sortingMODULE 5-Searching and-sorting
MODULE 5-Searching and-sorting
nikshaikh786
 
Ad

Recently uploaded (20)

International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Journal of Soft Computing in Civil Engineering
 
Reagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptxReagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptx
AlejandroOdio
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Reagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptxReagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptx
AlejandroOdio
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 

Array operations

  • 2. It Is An Ordered List, Which Consist Of A Fixed Number Of Homogeneous Data Items (Elements).An Array Is A Primitive Data Structure. These Elements Are Stored In Successive Memory Locations According To Size Of Data Type. Array Is Also Referred As Set Of (Index , Value).
  • 3. (index) A[0] A[1] A[2] A[3] A[4] A[5] A[MAX -1] 10 5 46 2 100 97 ... Data element value
  • 4. The Insert Operation Is Performed By Shifting All The Elements One Position Ahead From Index iTo N-1 Where i Is The Specified Index For New Element Is To Be Inserted. And Adding The New Element To The Array At The Specified Index Position.
  • 5. For example, index for insertion is i=2 and new element is 17 with N=6. the MAX is the size of the array A. A[0] A[1] A[2] … A[N-1] A[MAX-1] 10 5 46 2 100 97 … Insert index position Move All Elements From Insert Index Position I N-1 Towards Right By One Position A[0] 1 2 3 4 5 A[6] A[MAX-1] 10 5 46 2 100 97 … Insert Index Position
  • 6. A[0] 1 2 3 4 5 A[6] A[MAX-1] 10 5 46 46 2 100 97 … Insert index position Shifted elements
  • 7. Now, insert (store) new data element 17 at given index position 2: A[0] 1 2 3 4 5 A[6] A[MAX-1] 10 5 17 46 2 100 97 … Inserted element For Every New Element Inserted The Number Of Elements I.E N Should Be Incremented By 1. If N= Max-1 Then Array Is Full And Insertion Operation Cannot Be Performed As There Is No Space For New Element In The Array.
  • 8. The delete operation will delete the element at specified element index from one-dimensional array. The deletion operation performed by shifting all the elements one position before from index i=1 to N-1 where i is the index of element to be deleted. A[i] = A[i+1], for all i to N-1 . This shifting causes overwriting of the said element with element at next index position.
  • 9. For example, For an array N=7 and index position for deletion is i=3 and maximum array size as MAX. A[0] 1 2 3 4 5 A[6] A[MAX-1] 10 5 17 46 2 100 97 … Delete Index Position Now , Shift All Element From Index 4 To 6 One Position Before As Below: A[0] 1 2 3 4 5 A[6] A[MAX-1] 10 5 17 46 2 100 97 … Element At Index 3 The Array After The Shifting Backward Is:
  • 10. A[0] 1 2 3 4 A[5] A[MAX-1] 10 5 17 2 100 97 97 … Last element of array The element 46 is deleted from the array. After every delete operation the number of elements N should be decrement by 1. if array is empty , the deletion operation cannot be performed .