DS1.pptx
Array Index
Insert an element at a particular index in an array
Insert a given element at a specific position in an array.
Input
int arr[5] = {10, 20, 30, 40, 50}
Element = 100 position = 2.
Output
{10, 20, 100, 30, 40, 50}
Algorithm
1. Get the element value which needs to
be inserted.
2. Get the position value.
3. Check whether the position value is valid
or not.
4. If it is valid,
Shift all the elements from the last index
to position index by 1 position to the right.
insert the new element in arr[position]
5. Otherwise,
Invalid Position
DS1.pptx
DS1.pptx
DS1.pptx
Remove a specific element from array
Let's write an algorithm to remove a specific element from the array.
Algorithm
1. Find the given element in the given array
and note the index.
2. If the element found,
Shift all the elements from index + 1 by
1 position to the left.
Reduce the array size by 1.
3. Otherwise, print "Element Not Found"
Visual Representation
Let's take an array of 5 elements.
1, 20, 5, 78, 30.
If we remove element 20 from the array, the execution will be,
Implementation Algorithm:
1. Set index value as -1 initially. i.e. index = -1
2. Get key value from the user which needs to be deleted.
3. Search and store the index of a given key
[index will be -1, if the given key is not present in the array]
4. if index not equal to -1
Shift all the elements from index + 1 by 1 position to the left.
5. else
print "Element Not Found"
DS1.pptx
DS1.pptx
Searching an element in an array
Search whether the given key is present or not in the array.
Algorithm
1. Iterate the array using the loop.
2. Check whether the given key present in
the array i.e. arr[i] == key.
3. If yes,
print "Search Found".
4. Else
print "Search Not Found".
Search Found:
Search Not Found:
Implementation of Searching an Element:
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
DS1.pptx
Array Index---https://www.log2base2.com/data-structures/array/array-data-
structure.html

More Related Content

PPTX
Program Practical to operations on Array
PDF
Array data structure
PPTX
DSA - Array.pptx
PPTX
Data structures (Array 1 dimensional).pptx
PDF
Array data structure
PPT
Array operations
PPT
DOC
Main ds manual
Program Practical to operations on Array
Array data structure
DSA - Array.pptx
Data structures (Array 1 dimensional).pptx
Array data structure
Array operations
Main ds manual

Similar to DS1.pptx (20)

PPTX
Array Operations.pptxdata structure array indsa
PDF
C++ Arrays different operations .pdf
PDF
03 Linear Arrays Memory Representations .pdf
PPTX
Data Structures - Array presentation .pptx
PPTX
ARRAY in python and c with examples .pptx
PPTX
Arrays in Data
PPTX
Various Operations Of Array(Data Structure Algorithm).pptx
PDF
DOCX
Updated Lab3.docx
PDF
computer notes - List implementation
PDF
DSA UNIT II ARRAY AND LIST - notes
PPTX
Deletion of an element at a given particular position
PPT
PPTX
Data structure and algorithm All in One
PDF
Data-Structure-using-C-Rajesh-Pandey.pdf
PPT
arrays1.ppt python programme arrays insertion
PPT
4.1 sequentioal search
PPT
358 33 powerpoint-slides_5-arrays_chapter-5
PDF
Data structures arrays
Array Operations.pptxdata structure array indsa
C++ Arrays different operations .pdf
03 Linear Arrays Memory Representations .pdf
Data Structures - Array presentation .pptx
ARRAY in python and c with examples .pptx
Arrays in Data
Various Operations Of Array(Data Structure Algorithm).pptx
Updated Lab3.docx
computer notes - List implementation
DSA UNIT II ARRAY AND LIST - notes
Deletion of an element at a given particular position
Data structure and algorithm All in One
Data-Structure-using-C-Rajesh-Pandey.pdf
arrays1.ppt python programme arrays insertion
4.1 sequentioal search
358 33 powerpoint-slides_5-arrays_chapter-5
Data structures arrays

More from ArifKamal36 (16)

PPTX
48583FrequencyDistributions_Week_1.2.3 (F).pptx
PPT
03-arrays-pointers.ppt
PPT
html-lists-tables.ppt
PPT
HTMLTables.ppt
PPTX
Basic-HTML.9526794.powerpoint.pptx
PPTX
Lecture 1. Data Structure & Algorithm.pptx
PPT
topic11LinkedLists.ppt
PPT
PPT
PPT
PPT
PPT
CH5_Linked List.ppt
PPT
Games.ppt
PPTX
IAT334-Lec01-Intro.pptx
PPT
9916167.ppt
PPT
e3-chap-01.ppt
48583FrequencyDistributions_Week_1.2.3 (F).pptx
03-arrays-pointers.ppt
html-lists-tables.ppt
HTMLTables.ppt
Basic-HTML.9526794.powerpoint.pptx
Lecture 1. Data Structure & Algorithm.pptx
topic11LinkedLists.ppt
CH5_Linked List.ppt
Games.ppt
IAT334-Lec01-Intro.pptx
9916167.ppt
e3-chap-01.ppt

Recently uploaded (20)

PPT
What is a Computer? Input Devices /output devices
PDF
STKI Israel Market Study 2025 version august
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PPTX
Configure Apache Mutual Authentication
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
Benefits of Physical activity for teenagers.pptx
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
Abstractive summarization using multilingual text-to-text transfer transforme...
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PDF
Architecture types and enterprise applications.pdf
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Two-dimensional Klein-Gordon and Sine-Gordon numerical solutions based on dee...
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
Five Habits of High-Impact Board Members
PDF
CloudStack 4.21: First Look Webinar slides
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
What is a Computer? Input Devices /output devices
STKI Israel Market Study 2025 version august
Module 1.ppt Iot fundamentals and Architecture
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
Configure Apache Mutual Authentication
Credit Without Borders: AI and Financial Inclusion in Bangladesh
Hindi spoken digit analysis for native and non-native speakers
Benefits of Physical activity for teenagers.pptx
Custom Battery Pack Design Considerations for Performance and Safety
Abstractive summarization using multilingual text-to-text transfer transforme...
Convolutional neural network based encoder-decoder for efficient real-time ob...
Architecture types and enterprise applications.pdf
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Two-dimensional Klein-Gordon and Sine-Gordon numerical solutions based on dee...
A review of recent deep learning applications in wood surface defect identifi...
Five Habits of High-Impact Board Members
CloudStack 4.21: First Look Webinar slides
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Getting started with AI Agents and Multi-Agent Systems
A contest of sentiment analysis: k-nearest neighbor versus neural network

DS1.pptx

  • 3. Insert an element at a particular index in an array Insert a given element at a specific position in an array. Input int arr[5] = {10, 20, 30, 40, 50} Element = 100 position = 2. Output {10, 20, 100, 30, 40, 50} Algorithm 1. Get the element value which needs to be inserted. 2. Get the position value. 3. Check whether the position value is valid or not. 4. If it is valid, Shift all the elements from the last index to position index by 1 position to the right. insert the new element in arr[position] 5. Otherwise, Invalid Position
  • 7. Remove a specific element from array Let's write an algorithm to remove a specific element from the array. Algorithm 1. Find the given element in the given array and note the index. 2. If the element found, Shift all the elements from index + 1 by 1 position to the left. Reduce the array size by 1. 3. Otherwise, print "Element Not Found"
  • 8. Visual Representation Let's take an array of 5 elements. 1, 20, 5, 78, 30. If we remove element 20 from the array, the execution will be,
  • 9. Implementation Algorithm: 1. Set index value as -1 initially. i.e. index = -1 2. Get key value from the user which needs to be deleted. 3. Search and store the index of a given key [index will be -1, if the given key is not present in the array] 4. if index not equal to -1 Shift all the elements from index + 1 by 1 position to the left. 5. else print "Element Not Found"
  • 12. Searching an element in an array Search whether the given key is present or not in the array. Algorithm 1. Iterate the array using the loop. 2. Check whether the given key present in the array i.e. arr[i] == key. 3. If yes, print "Search Found". 4. Else print "Search Not Found".