SlideShare a Scribd company logo
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
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"
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:
Array Index---https://www.log2base2.com/data-structures/array/array-data-
structure.html

More Related Content

Similar to DS1.pptx

Searching, Sorting and Complexity analysis in DS.pdf
Searching, Sorting and Complexity analysis in DS.pdfSearching, Sorting and Complexity analysis in DS.pdf
Searching, Sorting and Complexity analysis in DS.pdf
AkshatMehrotra14
 
IN PYTHONCreate your own list of random integers, do not use r.pdf
IN PYTHONCreate your own list of random integers, do not use r.pdfIN PYTHONCreate your own list of random integers, do not use r.pdf
IN PYTHONCreate your own list of random integers, do not use r.pdf
aggarwalenterprisesf
 

Similar to DS1.pptx (20)

Linear and Binary search .pptx
Linear and Binary search .pptxLinear and Binary search .pptx
Linear and Binary search .pptx
 
search_sort.ppt
search_sort.pptsearch_sort.ppt
search_sort.ppt
 
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
 
Linear and binary search
Linear and binary searchLinear and binary search
Linear and binary search
 
Searching in DSA that follow a dsa searching.pptx
Searching in DSA that follow a dsa searching.pptxSearching in DSA that follow a dsa searching.pptx
Searching in DSA that follow a dsa searching.pptx
 
Binary Search Algorithm.pptx
Binary Search Algorithm.pptxBinary Search Algorithm.pptx
Binary Search Algorithm.pptx
 
1 class linear and Binary search (3).ppt
1 class linear and Binary search (3).ppt1 class linear and Binary search (3).ppt
1 class linear and Binary search (3).ppt
 
Searching, Sorting and Complexity analysis in DS.pdf
Searching, Sorting and Complexity analysis in DS.pdfSearching, Sorting and Complexity analysis in DS.pdf
Searching, Sorting and Complexity analysis in DS.pdf
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3
 
1 D Arrays in C++
1 D Arrays in C++1 D Arrays in C++
1 D Arrays in C++
 
Searching techniques
Searching techniquesSearching techniques
Searching techniques
 
search_sort Search sortSearch sortSearch sortSearch sort
search_sort Search sortSearch sortSearch sortSearch sortsearch_sort Search sortSearch sortSearch sortSearch sort
search_sort Search sortSearch sortSearch sortSearch sort
 
Arrays in Data
Arrays in DataArrays in Data
Arrays in Data
 
seaching internal 2 ppt.pptx
seaching internal 2 ppt.pptxseaching internal 2 ppt.pptx
seaching internal 2 ppt.pptx
 
Dsa – data structure and algorithms searching
Dsa – data structure and algorithms   searchingDsa – data structure and algorithms   searching
Dsa – data structure and algorithms searching
 
Searching techniques
Searching techniquesSearching techniques
Searching techniques
 
PPT.pptx Searching and Sorting Techniques
PPT.pptx Searching and Sorting TechniquesPPT.pptx Searching and Sorting Techniques
PPT.pptx Searching and Sorting Techniques
 
Unit iv(dsc++)
Unit iv(dsc++)Unit iv(dsc++)
Unit iv(dsc++)
 
IN PYTHONCreate your own list of random integers, do not use r.pdf
IN PYTHONCreate your own list of random integers, do not use r.pdfIN PYTHONCreate your own list of random integers, do not use r.pdf
IN PYTHONCreate your own list of random integers, do not use r.pdf
 
C++ Arrays different operations .pdf
C++ Arrays different operations .pdfC++ Arrays different operations .pdf
C++ Arrays different operations .pdf
 

More from ArifKamal36 (15)

03-arrays-pointers.ppt
03-arrays-pointers.ppt03-arrays-pointers.ppt
03-arrays-pointers.ppt
 
html-lists-tables.ppt
html-lists-tables.ppthtml-lists-tables.ppt
html-lists-tables.ppt
 
HTMLTables.ppt
HTMLTables.pptHTMLTables.ppt
HTMLTables.ppt
 
Basic-HTML.9526794.powerpoint.pptx
Basic-HTML.9526794.powerpoint.pptxBasic-HTML.9526794.powerpoint.pptx
Basic-HTML.9526794.powerpoint.pptx
 
Lecture 1. Data Structure & Algorithm.pptx
Lecture 1. Data Structure & Algorithm.pptxLecture 1. Data Structure & Algorithm.pptx
Lecture 1. Data Structure & Algorithm.pptx
 
topic11LinkedLists.ppt
topic11LinkedLists.ppttopic11LinkedLists.ppt
topic11LinkedLists.ppt
 
3.ppt
3.ppt3.ppt
3.ppt
 
3.ppt
3.ppt3.ppt
3.ppt
 
2.ppt
2.ppt2.ppt
2.ppt
 
1.ppt
1.ppt1.ppt
1.ppt
 
CH5_Linked List.ppt
CH5_Linked List.pptCH5_Linked List.ppt
CH5_Linked List.ppt
 
Games.ppt
Games.pptGames.ppt
Games.ppt
 
IAT334-Lec01-Intro.pptx
IAT334-Lec01-Intro.pptxIAT334-Lec01-Intro.pptx
IAT334-Lec01-Intro.pptx
 
9916167.ppt
9916167.ppt9916167.ppt
9916167.ppt
 
e3-chap-01.ppt
e3-chap-01.ppte3-chap-01.ppt
e3-chap-01.ppt
 

Recently uploaded

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG Evaluation
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
The architecture of Generative AI for enterprises.pdf
The architecture of Generative AI for enterprises.pdfThe architecture of Generative AI for enterprises.pdf
The architecture of Generative AI for enterprises.pdf
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 

DS1.pptx

  • 1.
  • 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
  • 4.
  • 5.
  • 6.
  • 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"
  • 10.
  • 11.
  • 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".
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.