SlideShare a Scribd company logo
DATA STRUCTURES
NAGARAJU M L
ASSISTANT PROFESSOR
DEPARTMENT OF MCA
ACHARYA INSTITUTE OF GRADUATE
STUDIES
SOLADEVANAHALLI, BANGALORE
DATA STRUCTURE
 Definition: Logical or Mathematical model of a particular
organisation of data is called Data Structure.
 Example: Character, Integer, Float, Pointer, Arrays, Liked
List, Stacks, Queues, Trees, Graphs.
 Need: Data Structures are necessary for designing efficient
algorithms.
CLASSIFICATION OF DATA
STRUCTURE
 Definition: Data Structure which can be manipulated
directly by machine instructions.
 Example: Character, Integer, Float, Pointer
 Operations:
1. Create: int x;
2. Select: cout<<x;
3. Update: x = x + 10;
4. Destroy: delete x;
PRIMITIVE DATA STRUCTURE
 Definition: Data Structure which can not be manipulated
directly by machine instructions.
 Example: Arrays, Linked List, Stacks, Queues, Trees, Graphs.
 Operations:
1. Traversing
2. Insertion
3. Deletion
4. Searching
5. Sorting
6. Merging
NON-PRIMITIVE DATA STRUCTURE
 Definition: Data Structure in which there is a sequential
relationship between the elements.
 Example: Arrays, Liked List, Stacks, Queues.
Array:
Liked List:
Stacks:
Queues:
LINEAR DATA STRUCTURE
 Definition: Data Structure in which there is no sequential
relationship between the elements. There will be an
adjacency or hierarchical relationships.
 Example: Trees, Graphs.
NON-LINEAR DATA STRUCTURE
ARRAYS
 Definition: Collection of homogeneous elements with
only one name is called Arrays.
 Characteristics:
 Types:
1. One-Dimensional Array or Linear Array
2. Two-Dimensional Array
3. Multi-Dimensional Array
TYPES OF ARRAYS
 One-Dimensional Array or Linear Array: The array in
which the elements are accessed by using only one index.
 Two-Dimensional Array: The array in which the elements
are accessed by using two indexes.
 Multi-Dimensional Array: The array in which the elements
are accessed by using more than two indexes.
OPERATIONS ON ONE-DIMENSIONALARRAY
 The following operations can be performed on linear array.
1. Traversing
2. Insertion
3. Deletion
4. Searching
5. Sorting
6. Merging
TRAVERSING
 Traversal in a Linear Array is the process of
visiting each element once.
 Traversal is done by starting with the first
element of the array and reaching to the last.
 ALGORITHM:
TRAVERSAL(A, N)
Step1: FOR I = 0 to N-1
PROCESS(A[I])
[ end of FOR ]
Step2: Stop
INSERTION
 Adding new element into the array
Initially
After movement of Elements
After Insertion
INSERTION
 ALGORITHM:
INSERTION(A, N, ELE, POS)
Step1: FOR I = N-1 DOWNTO POS
A[I+1] = A[I]
[end of FOR]
Step2: A[POS] = ELE
Step3: N = N + 1
Step4: Stop
DELETION
 Removing an element from the array
Initially
After Deletion
After Movement of elements
DELETION
 ALGORITHM:
DELETION(A, N, ELE, POS)
Step1: ELE = A[POS]
Step2 FOR I = POS TO N – 2
A[I] = A[I+1]
[end of FOR]
Step3: N = N – 1
Step4: Stop
SEARCHING
 Definition: Checking weather the given
element is there in an array or not is called
Searching.
 Methods:
1. Linear Search or Sequential Search
2. Binary Search
LINEAR SEARCH
 It is also called Sequential Search.
 It can be applied on unsorted array.
 Algorithm:
LINEARSEARCH(A, N, KEY)
Step1: LOC = -1
Step2: FOR I = 1 TO N
IF (KEY == A[I])
LOC = I
goto Step3
[end of IF]
[end of FOR]
Step3: IF (LOC == – 1)
Print “ Element not found”
ELSE
Print “Element found at “, LOC
Step4: Stop
BINARY SEARCH
 It can be applied only on sorted array.
 It is based on Divide and Conquer Technique.
 Algorithm:
BINARYSEARCH(A, N, KEY)
Step1: LOC = -1, BEG = 0, END = N–1
Step2: Repeat WHILE (BEG <= END)
MID = (BEG + END)/2
IF ( KEY == A[MID] )
LOC = MID
goto Step3
ELSE IF (KEY < A[MID])
END = MID – 1
ELSE
BEG = MID + 1
[ end of IF ]
[ end of WHILE ]
Step3: IF (LOC == – 1)
Print “ Element not found”
BINARY SEARCH
Step3: IF (LOC == – 1)
Print “ Element not found”
ELSE
Print “Element found at “, LOC
[ end of IF ]
Step4: Stop
SORTING
 Definition: Arranging the elements in a
particular order is called sorting.
 Methods:
1. Bubble Sort
2. Selection Sort
3. Insertion Sort
4. Merge Sort
5. Quick Sort
6. Radix Sort
7. Heap Sort
BUBBLE SORT
 Algorithm:
BUBBLESORT(A, N)
Sept1. FOR I = 1 to N – 1
FOR J = 1 to N–I–1
IF ( A[J] > A[J+1]
TEMP = A[J]
A[J] = A[J+1]
A[J+1] = TEMP
[ end of IF ]
[ end of FOR ]
[ end of FOR ]
THANK YOU
Ad

More Related Content

Similar to Data Structures Types, Arrays, stacks - MLN.ppt (20)

All Searching and Sorting Techniques in Data Structures
All Searching and Sorting Techniques in Data StructuresAll Searching and Sorting Techniques in Data Structures
All Searching and Sorting Techniques in Data Structures
sonalishinge2015
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queue
Rai University
 
Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queue
Rai University
 
searching in data structure.pptx
searching in data structure.pptxsearching in data structure.pptx
searching in data structure.pptx
chouguleamruta24
 
queue & its applications
queue & its applicationsqueue & its applications
queue & its applications
somendra kumar
 
Stack and queue
Stack and queueStack and queue
Stack and queue
CHANDAN KUMAR
 
DSA_Ques ewoifhjerofhefhehfreofheek.pptx
DSA_Ques ewoifhjerofhefhehfreofheek.pptxDSA_Ques ewoifhjerofhefhehfreofheek.pptx
DSA_Ques ewoifhjerofhefhehfreofheek.pptx
arnab13984
 
هياكلبيانات
هياكلبياناتهياكلبيانات
هياكلبيانات
Rafal Edward
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3
infanciaj
 
Unit 6 dsa SEARCHING AND SORTING
Unit 6 dsa SEARCHING AND SORTINGUnit 6 dsa SEARCHING AND SORTING
Unit 6 dsa SEARCHING AND SORTING
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queue
Rai University
 
Revisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queueRevisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queue
ssuser7319f8
 
Unit 2 dsa LINEAR DATA STRUCTURE
Unit 2 dsa LINEAR DATA STRUCTUREUnit 2 dsa LINEAR DATA STRUCTURE
Unit 2 dsa LINEAR DATA STRUCTURE
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
9 Arrays
9 Arrays9 Arrays
9 Arrays
Praveen M Jigajinni
 
Data structure
Data  structureData  structure
Data structure
Arvind Kumar
 
DS Unit 1.pptx
DS Unit 1.pptxDS Unit 1.pptx
DS Unit 1.pptx
chin463670
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptx
skilljiolms
 
Java presentation on insertion sort
Java presentation on insertion sortJava presentation on insertion sort
Java presentation on insertion sort
_fahad_shaikh
 
TSAT Presentation1.pptx
TSAT Presentation1.pptxTSAT Presentation1.pptx
TSAT Presentation1.pptx
Rajitha Reddy Alugati
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
blessyboban92
 
All Searching and Sorting Techniques in Data Structures
All Searching and Sorting Techniques in Data StructuresAll Searching and Sorting Techniques in Data Structures
All Searching and Sorting Techniques in Data Structures
sonalishinge2015
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queue
Rai University
 
Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queue
Rai University
 
searching in data structure.pptx
searching in data structure.pptxsearching in data structure.pptx
searching in data structure.pptx
chouguleamruta24
 
queue & its applications
queue & its applicationsqueue & its applications
queue & its applications
somendra kumar
 
DSA_Ques ewoifhjerofhefhehfreofheek.pptx
DSA_Ques ewoifhjerofhefhehfreofheek.pptxDSA_Ques ewoifhjerofhefhehfreofheek.pptx
DSA_Ques ewoifhjerofhefhehfreofheek.pptx
arnab13984
 
هياكلبيانات
هياكلبياناتهياكلبيانات
هياكلبيانات
Rafal Edward
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3
infanciaj
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queue
Rai University
 
Revisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queueRevisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queue
ssuser7319f8
 
DS Unit 1.pptx
DS Unit 1.pptxDS Unit 1.pptx
DS Unit 1.pptx
chin463670
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptx
skilljiolms
 
Java presentation on insertion sort
Java presentation on insertion sortJava presentation on insertion sort
Java presentation on insertion sort
_fahad_shaikh
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
blessyboban92
 

Recently uploaded (20)

Deloitte - A Framework for Process Mining Projects
Deloitte - A Framework for Process Mining ProjectsDeloitte - A Framework for Process Mining Projects
Deloitte - A Framework for Process Mining Projects
Process mining Evangelist
 
LLM finetuning for multiple choice google bert
LLM finetuning for multiple choice google bertLLM finetuning for multiple choice google bert
LLM finetuning for multiple choice google bert
ChadapornK
 
Process Mining and Data Science in the Financial Industry
Process Mining and Data Science in the Financial IndustryProcess Mining and Data Science in the Financial Industry
Process Mining and Data Science in the Financial Industry
Process mining Evangelist
 
Simple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptxSimple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptx
ssuser2aa19f
 
Modern_Distribution_Presentation.pptx Aa
Modern_Distribution_Presentation.pptx AaModern_Distribution_Presentation.pptx Aa
Modern_Distribution_Presentation.pptx Aa
MuhammadAwaisKamboh
 
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docxMASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
santosh162
 
Developing Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response ApplicationsDeveloping Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response Applications
VICTOR MAESTRE RAMIREZ
 
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
James Francis Paradigm Asset Management
 
Conic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptxConic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptx
taiwanesechetan
 
Data Science Courses in India iim skills
Data Science Courses in India iim skillsData Science Courses in India iim skills
Data Science Courses in India iim skills
dharnathakur29
 
Decision Trees in Artificial-Intelligence.pdf
Decision Trees in Artificial-Intelligence.pdfDecision Trees in Artificial-Intelligence.pdf
Decision Trees in Artificial-Intelligence.pdf
Saikat Basu
 
Principles of information security Chapter 5.ppt
Principles of information security Chapter 5.pptPrinciples of information security Chapter 5.ppt
Principles of information security Chapter 5.ppt
EstherBaguma
 
Flip flop presenation-Presented By Mubahir khan.pptx
Flip flop presenation-Presented By Mubahir khan.pptxFlip flop presenation-Presented By Mubahir khan.pptx
Flip flop presenation-Presented By Mubahir khan.pptx
mubashirkhan45461
 
03 Daniel 2-notes.ppt seminario escatologia
03 Daniel 2-notes.ppt seminario escatologia03 Daniel 2-notes.ppt seminario escatologia
03 Daniel 2-notes.ppt seminario escatologia
Alexander Romero Arosquipa
 
GenAI for Quant Analytics: survey-analytics.ai
GenAI for Quant Analytics: survey-analytics.aiGenAI for Quant Analytics: survey-analytics.ai
GenAI for Quant Analytics: survey-analytics.ai
Inspirient
 
ISO 9001_2015 FINALaaaaaaaaaaaaaaaa - MDX - Copy.pptx
ISO 9001_2015 FINALaaaaaaaaaaaaaaaa - MDX - Copy.pptxISO 9001_2015 FINALaaaaaaaaaaaaaaaa - MDX - Copy.pptx
ISO 9001_2015 FINALaaaaaaaaaaaaaaaa - MDX - Copy.pptx
pankaj6188303
 
Defense Against LLM Scheming 2025_04_28.pptx
Defense Against LLM Scheming 2025_04_28.pptxDefense Against LLM Scheming 2025_04_28.pptx
Defense Against LLM Scheming 2025_04_28.pptx
Greg Makowski
 
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnTemplate_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
cegiver630
 
Cleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdfCleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdf
alcinialbob1234
 
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
gmuir1066
 
Deloitte - A Framework for Process Mining Projects
Deloitte - A Framework for Process Mining ProjectsDeloitte - A Framework for Process Mining Projects
Deloitte - A Framework for Process Mining Projects
Process mining Evangelist
 
LLM finetuning for multiple choice google bert
LLM finetuning for multiple choice google bertLLM finetuning for multiple choice google bert
LLM finetuning for multiple choice google bert
ChadapornK
 
Process Mining and Data Science in the Financial Industry
Process Mining and Data Science in the Financial IndustryProcess Mining and Data Science in the Financial Industry
Process Mining and Data Science in the Financial Industry
Process mining Evangelist
 
Simple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptxSimple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptx
ssuser2aa19f
 
Modern_Distribution_Presentation.pptx Aa
Modern_Distribution_Presentation.pptx AaModern_Distribution_Presentation.pptx Aa
Modern_Distribution_Presentation.pptx Aa
MuhammadAwaisKamboh
 
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docxMASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
santosh162
 
Developing Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response ApplicationsDeveloping Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response Applications
VICTOR MAESTRE RAMIREZ
 
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
James Francis Paradigm Asset Management
 
Conic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptxConic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptx
taiwanesechetan
 
Data Science Courses in India iim skills
Data Science Courses in India iim skillsData Science Courses in India iim skills
Data Science Courses in India iim skills
dharnathakur29
 
Decision Trees in Artificial-Intelligence.pdf
Decision Trees in Artificial-Intelligence.pdfDecision Trees in Artificial-Intelligence.pdf
Decision Trees in Artificial-Intelligence.pdf
Saikat Basu
 
Principles of information security Chapter 5.ppt
Principles of information security Chapter 5.pptPrinciples of information security Chapter 5.ppt
Principles of information security Chapter 5.ppt
EstherBaguma
 
Flip flop presenation-Presented By Mubahir khan.pptx
Flip flop presenation-Presented By Mubahir khan.pptxFlip flop presenation-Presented By Mubahir khan.pptx
Flip flop presenation-Presented By Mubahir khan.pptx
mubashirkhan45461
 
GenAI for Quant Analytics: survey-analytics.ai
GenAI for Quant Analytics: survey-analytics.aiGenAI for Quant Analytics: survey-analytics.ai
GenAI for Quant Analytics: survey-analytics.ai
Inspirient
 
ISO 9001_2015 FINALaaaaaaaaaaaaaaaa - MDX - Copy.pptx
ISO 9001_2015 FINALaaaaaaaaaaaaaaaa - MDX - Copy.pptxISO 9001_2015 FINALaaaaaaaaaaaaaaaa - MDX - Copy.pptx
ISO 9001_2015 FINALaaaaaaaaaaaaaaaa - MDX - Copy.pptx
pankaj6188303
 
Defense Against LLM Scheming 2025_04_28.pptx
Defense Against LLM Scheming 2025_04_28.pptxDefense Against LLM Scheming 2025_04_28.pptx
Defense Against LLM Scheming 2025_04_28.pptx
Greg Makowski
 
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnTemplate_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
cegiver630
 
Cleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdfCleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdf
alcinialbob1234
 
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
gmuir1066
 
Ad

Data Structures Types, Arrays, stacks - MLN.ppt

  • 1. DATA STRUCTURES NAGARAJU M L ASSISTANT PROFESSOR DEPARTMENT OF MCA ACHARYA INSTITUTE OF GRADUATE STUDIES SOLADEVANAHALLI, BANGALORE
  • 2. DATA STRUCTURE  Definition: Logical or Mathematical model of a particular organisation of data is called Data Structure.  Example: Character, Integer, Float, Pointer, Arrays, Liked List, Stacks, Queues, Trees, Graphs.  Need: Data Structures are necessary for designing efficient algorithms.
  • 4.  Definition: Data Structure which can be manipulated directly by machine instructions.  Example: Character, Integer, Float, Pointer  Operations: 1. Create: int x; 2. Select: cout<<x; 3. Update: x = x + 10; 4. Destroy: delete x; PRIMITIVE DATA STRUCTURE
  • 5.  Definition: Data Structure which can not be manipulated directly by machine instructions.  Example: Arrays, Linked List, Stacks, Queues, Trees, Graphs.  Operations: 1. Traversing 2. Insertion 3. Deletion 4. Searching 5. Sorting 6. Merging NON-PRIMITIVE DATA STRUCTURE
  • 6.  Definition: Data Structure in which there is a sequential relationship between the elements.  Example: Arrays, Liked List, Stacks, Queues. Array: Liked List: Stacks: Queues: LINEAR DATA STRUCTURE
  • 7.  Definition: Data Structure in which there is no sequential relationship between the elements. There will be an adjacency or hierarchical relationships.  Example: Trees, Graphs. NON-LINEAR DATA STRUCTURE
  • 8. ARRAYS  Definition: Collection of homogeneous elements with only one name is called Arrays.  Characteristics:  Types: 1. One-Dimensional Array or Linear Array 2. Two-Dimensional Array 3. Multi-Dimensional Array
  • 9. TYPES OF ARRAYS  One-Dimensional Array or Linear Array: The array in which the elements are accessed by using only one index.  Two-Dimensional Array: The array in which the elements are accessed by using two indexes.  Multi-Dimensional Array: The array in which the elements are accessed by using more than two indexes.
  • 10. OPERATIONS ON ONE-DIMENSIONALARRAY  The following operations can be performed on linear array. 1. Traversing 2. Insertion 3. Deletion 4. Searching 5. Sorting 6. Merging
  • 11. TRAVERSING  Traversal in a Linear Array is the process of visiting each element once.  Traversal is done by starting with the first element of the array and reaching to the last.  ALGORITHM: TRAVERSAL(A, N) Step1: FOR I = 0 to N-1 PROCESS(A[I]) [ end of FOR ] Step2: Stop
  • 12. INSERTION  Adding new element into the array Initially After movement of Elements After Insertion
  • 13. INSERTION  ALGORITHM: INSERTION(A, N, ELE, POS) Step1: FOR I = N-1 DOWNTO POS A[I+1] = A[I] [end of FOR] Step2: A[POS] = ELE Step3: N = N + 1 Step4: Stop
  • 14. DELETION  Removing an element from the array Initially After Deletion After Movement of elements
  • 15. DELETION  ALGORITHM: DELETION(A, N, ELE, POS) Step1: ELE = A[POS] Step2 FOR I = POS TO N – 2 A[I] = A[I+1] [end of FOR] Step3: N = N – 1 Step4: Stop
  • 16. SEARCHING  Definition: Checking weather the given element is there in an array or not is called Searching.  Methods: 1. Linear Search or Sequential Search 2. Binary Search
  • 17. LINEAR SEARCH  It is also called Sequential Search.  It can be applied on unsorted array.  Algorithm: LINEARSEARCH(A, N, KEY) Step1: LOC = -1 Step2: FOR I = 1 TO N IF (KEY == A[I]) LOC = I goto Step3 [end of IF] [end of FOR] Step3: IF (LOC == – 1) Print “ Element not found” ELSE Print “Element found at “, LOC Step4: Stop
  • 18. BINARY SEARCH  It can be applied only on sorted array.  It is based on Divide and Conquer Technique.  Algorithm: BINARYSEARCH(A, N, KEY) Step1: LOC = -1, BEG = 0, END = N–1 Step2: Repeat WHILE (BEG <= END) MID = (BEG + END)/2 IF ( KEY == A[MID] ) LOC = MID goto Step3 ELSE IF (KEY < A[MID]) END = MID – 1 ELSE BEG = MID + 1 [ end of IF ] [ end of WHILE ] Step3: IF (LOC == – 1) Print “ Element not found”
  • 19. BINARY SEARCH Step3: IF (LOC == – 1) Print “ Element not found” ELSE Print “Element found at “, LOC [ end of IF ] Step4: Stop
  • 20. SORTING  Definition: Arranging the elements in a particular order is called sorting.  Methods: 1. Bubble Sort 2. Selection Sort 3. Insertion Sort 4. Merge Sort 5. Quick Sort 6. Radix Sort 7. Heap Sort
  • 21. BUBBLE SORT  Algorithm: BUBBLESORT(A, N) Sept1. FOR I = 1 to N – 1 FOR J = 1 to N–I–1 IF ( A[J] > A[J+1] TEMP = A[J] A[J] = A[J+1] A[J+1] = TEMP [ end of IF ] [ end of FOR ] [ end of FOR ]