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

More Related Content

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

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

Recently uploaded (20)

PDF
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays
 
PPTX
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
PDF
apidays Helsinki & North 2025 - REST in Peace? Hunting the Dominant Design fo...
apidays
 
PDF
Product Management in HealthTech (Case Studies from SnappDoctor)
Hamed Shams
 
PPT
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
PDF
apidays Helsinki & North 2025 - APIs in the healthcare sector: hospitals inte...
apidays
 
PDF
Simplifying Document Processing with Docling for AI Applications.pdf
Tamanna
 
PDF
Choosing the Right Database for Indexing.pdf
Tamanna
 
PDF
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
PDF
Data Chunking Strategies for RAG in 2025.pdf
Tamanna
 
PDF
apidays Helsinki & North 2025 - Monetizing AI APIs: The New API Economy, Alla...
apidays
 
PPT
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
PDF
Building Production-Ready AI Agents with LangGraph.pdf
Tamanna
 
PPTX
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
apidays
 
PPTX
Aict presentation on dpplppp sjdhfh.pptx
vabaso5932
 
PPTX
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
PPTX
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
PDF
Avatar for apidays apidays PRO June 07, 2025 0 5 apidays Helsinki & North 2...
apidays
 
PPTX
apidays Helsinki & North 2025 - Vero APIs - Experiences of API development in...
apidays
 
PPTX
ER_Model_Relationship_in_DBMS_Presentation.pptx
dharaadhvaryu1992
 
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays
 
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
apidays Helsinki & North 2025 - REST in Peace? Hunting the Dominant Design fo...
apidays
 
Product Management in HealthTech (Case Studies from SnappDoctor)
Hamed Shams
 
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
apidays Helsinki & North 2025 - APIs in the healthcare sector: hospitals inte...
apidays
 
Simplifying Document Processing with Docling for AI Applications.pdf
Tamanna
 
Choosing the Right Database for Indexing.pdf
Tamanna
 
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
Data Chunking Strategies for RAG in 2025.pdf
Tamanna
 
apidays Helsinki & North 2025 - Monetizing AI APIs: The New API Economy, Alla...
apidays
 
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
Building Production-Ready AI Agents with LangGraph.pdf
Tamanna
 
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
apidays
 
Aict presentation on dpplppp sjdhfh.pptx
vabaso5932
 
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
Avatar for apidays apidays PRO June 07, 2025 0 5 apidays Helsinki & North 2...
apidays
 
apidays Helsinki & North 2025 - Vero APIs - Experiences of API development in...
apidays
 
ER_Model_Relationship_in_DBMS_Presentation.pptx
dharaadhvaryu1992
 
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 ]