SlideShare a Scribd company logo
Array(ADT)
Linear Data Structure




               www.eshikshak.co.in
What are Arrays ?
 ● An Aay is collection of elements stored in adjacent memory
   locations.
 ● By ‘finite’ – specific number of elements in an Aay
 ● By ‘similar’ – all the elements in an Aay are of the same data type




                        www.eshikshak.co.in
What are Arrays ? (cont.)
 ● An Aay containing number of element is reference
   using an index values 0, 1, …n-1
    ○ Lower bound–Lowest index value
    ○ Upper bound–Highest index value
 ● An Aay is set of pairs of an index and a value, for
   each index there is value associated with it.
 ● Various categories of Aay
    ○ 1D, 2D and Multi-D




                   www.eshikshak.co.in
What are Arrays ? (Cont.)
 ● The number of elements in the Aay is called its
   range.
 ● No matter how big an Aay is, its elements are
   always stored in contiguous memory locations.




                  www.eshikshak.co.in
Array Operations
Operation   Description
Traversal   Processing each element in the Aay
Search      Finding the location of an element with a given
            value
Insertion   Adding new element to an Aay
Deletion    Removing an element from an Aay
Sorting     Organizing the elements in some order
Merging     Combining two Aays into a single Aay
Reversing   Reversing the elements of an Aay




                     www.eshikshak.co.in
Row-Major and Column-Major
Arrangement
 ● All the elements of Aay are stored in adjacent memory.
 ● This leads to two possible Aangements of elements in memory
     ○ Row Major
     ○ ColumnMajor
 ● Base address , no. of rows ,& no. of columns helps to know any
   element in an Aay




                       www.eshikshak.co.in
Algorithm for Array Traversal
   ● Let A be a linear Aay with Lower Bound LB and Upper Bound UB. The
     following algorithm traverses A applying an operations PROCESS to each
     element of A
Step 1. Initialize Counter
       Set Counter = LB
Step 2. Repeat steps 3 and 4 while counter <= UB
       Else GoTo Step 5
Step 3. Visit element
       Apply PROCESS to A[counter]
Step 4. Increase Counter
       Set counter = counter + 1
       GoTo 2
Step 5. Exit

                             www.eshikshak.co.in
Algorithm for Insertion
Let A be a Linear Array, N is number of elements, k is the positive integer such
that k<=N, VAL to insert element at kth Position in an Array A
Step 1. Start
Step 2. Initialize Counter
          Set J = N
Step 3. Repeat Steps 3 and 4 while J>=k otherwise GoTo Step
Step 4. Move Jth element downward
          Set A[J+1] = A[J]
Step 5. Decrease Counter
          Set J = J + 1
       End of step 2 loop
Step 6. Insert element
          Set A[k] = ITEM
Step 7. Reset N
          Set N = N + 1
Step 8. Exit

                               www.eshikshak.co.in
Algorithm for Deletion
DELETE(A, N, K, VAL)
Let A be an linear Aay. N is the number of elements, k is the positive
integer such that k<=N. The algorithm deletes kth element from the
Aay.
Step 1. Start
Step 2. Set VAL = A[k]
Step 3. Repeat for J = k to N-1
[Move J+1 element Upward]
Set A[J] = A[J+1)
End of Loop
Step 4. Reset the number N of elements in A

Set N = N–     1
Step 5. Exit

                          www.eshikshak.co.in
Algorithm for Linear Search
Suppose A is linear Array with N elements, and VAL is the given item of
information. This algorithm finds the location LOC of item in A or sets LOC=0 if
search is unsuccessful
Step 1. Start
Step 2. [Insert VAL at the end of A]
        Set A[N+1] = VAL
Step 3. [Initialize counter]
        SET LOC = 1
Step 4. [Search for VAL]
        Repeat while A[LOC] != VAL
           Set LOC = LOC + 1
        [End of loop]
Step 5. [Successful ?]
        if LOC = N+1 then set LOC = 0
Step 6. Exit


                               www.eshikshak.co.in
Algorithm for sorting
Let A be an Aay of N elements. The following algorithm sorts
the elements of A.
Step 1. Start
Step 2. Repeat Steps 2 and 3 for k=1 to N-1
Step 3. Set PTR = 1 [Initialize pass pointer PTR]
Step 4. Repeat while PTR<=N-K [Execute Pass]
a. If A[PTR] > A[PTR+1], then
Interchange A[PTR] and A[PTR+1]
  [End of if structure]
b. Set PTR = PTR + 1
[End of inner loop]
[End of step1 outer loop]
Step 5. Exit

                          www.eshikshak.co.in

More Related Content

PPT
Arrays Data Structure
PPTX
Queue in Data Structure
PPTX
stack & queue
PPTX
Insertion sort
PPTX
PPT
Algorithmic Notations
PPSX
Data Structure (Queue)
PPTX
Arrays in Data Structure and Algorithm
Arrays Data Structure
Queue in Data Structure
stack & queue
Insertion sort
Algorithmic Notations
Data Structure (Queue)
Arrays in Data Structure and Algorithm

What's hot (20)

PPTX
linked list in data structure
PPTX
Binary search in data structure
PPTX
Doubly Linked List
PPTX
sorting and its types
PDF
Set methods in python
PPTX
Merge sort algorithm
PPTX
daa-unit-3-greedy method
PPTX
Protocols of noiseless
PPTX
Stacks in c++
PDF
Time and Space Complexity
PDF
Array data structure
PPTX
Passing an Array to a Function (ICT Programming)
PPTX
List in Python
PDF
Arrays in python
PPTX
Method overloading
PPT
Dinive conquer algorithm
PDF
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
PPTX
Quick sort-Data Structure
PDF
Quick sort algorithn
PDF
linked list in data structure
Binary search in data structure
Doubly Linked List
sorting and its types
Set methods in python
Merge sort algorithm
daa-unit-3-greedy method
Protocols of noiseless
Stacks in c++
Time and Space Complexity
Array data structure
Passing an Array to a Function (ICT Programming)
List in Python
Arrays in python
Method overloading
Dinive conquer algorithm
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
Quick sort-Data Structure
Quick sort algorithn
Ad

Viewers also liked (13)

PPT
Algo>Abstract data type
PPT
DATA STRUCTURES
PPT
Data structure lecture 3
PPT
Arrays
PPTX
Data structures and algorithms
PPTX
Infix-Postfix expression conversion
PPT
Abstract data types
PPT
Abstract data types
PDF
Abstract Data Types
PPT
Sparse Matrix and Polynomial
PPT
PPT
Chapter 11 - Sorting and Searching
PDF
11 abstract data types
Algo>Abstract data type
DATA STRUCTURES
Data structure lecture 3
Arrays
Data structures and algorithms
Infix-Postfix expression conversion
Abstract data types
Abstract data types
Abstract Data Types
Sparse Matrix and Polynomial
Chapter 11 - Sorting and Searching
11 abstract data types
Ad

Similar to Array linear data_structure_2 (1) (20)

PPTX
data structure and algorithm Array.pptx btech 2nd year
DOCX
Updated Lab3.docx
PDF
03 Linear Arrays Memory Representations .pdf
PPTX
PPT Lecture 2.2.1 onn c++ data structures
PPT
PPTX
Data structures (Array 1 dimensional).pptx
PPT
arrays1.ppt python programme arrays insertion
PDF
Array data structure
PPTX
Data Structure Introduction- Arrays, Matrix, Linked List
PPTX
ARRAY in python and c with examples .pptx
PPTX
Data structure and algorithm All in One
PDF
PPTX
Data structure using c module 1
PDF
PPT
358 33 powerpoint-slides_5-arrays_chapter-5
PPTX
datastructureppt-190327174340 (1).pptx
PPTX
DSA - Array.pptx
PPT
PPTX
2.DS Array
PPTX
Array Operations.pptxdata structure array indsa
data structure and algorithm Array.pptx btech 2nd year
Updated Lab3.docx
03 Linear Arrays Memory Representations .pdf
PPT Lecture 2.2.1 onn c++ data structures
Data structures (Array 1 dimensional).pptx
arrays1.ppt python programme arrays insertion
Array data structure
Data Structure Introduction- Arrays, Matrix, Linked List
ARRAY in python and c with examples .pptx
Data structure and algorithm All in One
Data structure using c module 1
358 33 powerpoint-slides_5-arrays_chapter-5
datastructureppt-190327174340 (1).pptx
DSA - Array.pptx
2.DS Array
Array Operations.pptxdata structure array indsa

More from eShikshak (20)

PDF
Modelling and evaluation
PDF
Operators in python
PDF
Datatypes in python
PDF
Introduction to python
PPT
Introduction to e commerce
PDF
Chapeter 2 introduction to cloud computing
PDF
Unit 1.4 working of cloud computing
PDF
Unit 1.3 types of cloud
PDF
Unit 1.2 move to cloud computing
PDF
Unit 1.1 introduction to cloud computing
PPT
Mesics lecture files in 'c'
PPT
Mesics lecture 8 arrays in 'c'
PPT
Mesics lecture 7 iteration and repetitive executions
PPT
Mesics lecture 5 input – output in ‘c’
PPT
Mesics lecture 6 control statement = if -else if__else
PPT
Mesics lecture 4 c operators and experssions
PPT
Mesics lecture 5 input – output in ‘c’
PPT
Mesics lecture 3 c – constants and variables
PDF
Lecture 7 relational_and_logical_operators
PDF
Lecture21 categoriesof userdefinedfunctions.ppt
Modelling and evaluation
Operators in python
Datatypes in python
Introduction to python
Introduction to e commerce
Chapeter 2 introduction to cloud computing
Unit 1.4 working of cloud computing
Unit 1.3 types of cloud
Unit 1.2 move to cloud computing
Unit 1.1 introduction to cloud computing
Mesics lecture files in 'c'
Mesics lecture 8 arrays in 'c'
Mesics lecture 7 iteration and repetitive executions
Mesics lecture 5 input – output in ‘c’
Mesics lecture 6 control statement = if -else if__else
Mesics lecture 4 c operators and experssions
Mesics lecture 5 input – output in ‘c’
Mesics lecture 3 c – constants and variables
Lecture 7 relational_and_logical_operators
Lecture21 categoriesof userdefinedfunctions.ppt

Recently uploaded (20)

PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Cloud computing and distributed systems.
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Approach and Philosophy of On baking technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
sap open course for s4hana steps from ECC to s4
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Review of recent advances in non-invasive hemoglobin estimation
Digital-Transformation-Roadmap-for-Companies.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Big Data Technologies - Introduction.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Advanced methodologies resolving dimensionality complications for autism neur...
Cloud computing and distributed systems.
Dropbox Q2 2025 Financial Results & Investor Presentation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Building Integrated photovoltaic BIPV_UPV.pdf
Electronic commerce courselecture one. Pdf
20250228 LYD VKU AI Blended-Learning.pptx
MIND Revenue Release Quarter 2 2025 Press Release
MYSQL Presentation for SQL database connectivity
Mobile App Security Testing_ A Comprehensive Guide.pdf

Array linear data_structure_2 (1)

  • 1. Array(ADT) Linear Data Structure www.eshikshak.co.in
  • 2. What are Arrays ? ● An Aay is collection of elements stored in adjacent memory locations. ● By ‘finite’ – specific number of elements in an Aay ● By ‘similar’ – all the elements in an Aay are of the same data type www.eshikshak.co.in
  • 3. What are Arrays ? (cont.) ● An Aay containing number of element is reference using an index values 0, 1, …n-1 ○ Lower bound–Lowest index value ○ Upper bound–Highest index value ● An Aay is set of pairs of an index and a value, for each index there is value associated with it. ● Various categories of Aay ○ 1D, 2D and Multi-D www.eshikshak.co.in
  • 4. What are Arrays ? (Cont.) ● The number of elements in the Aay is called its range. ● No matter how big an Aay is, its elements are always stored in contiguous memory locations. www.eshikshak.co.in
  • 5. Array Operations Operation Description Traversal Processing each element in the Aay Search Finding the location of an element with a given value Insertion Adding new element to an Aay Deletion Removing an element from an Aay Sorting Organizing the elements in some order Merging Combining two Aays into a single Aay Reversing Reversing the elements of an Aay www.eshikshak.co.in
  • 6. Row-Major and Column-Major Arrangement ● All the elements of Aay are stored in adjacent memory. ● This leads to two possible Aangements of elements in memory ○ Row Major ○ ColumnMajor ● Base address , no. of rows ,& no. of columns helps to know any element in an Aay www.eshikshak.co.in
  • 7. Algorithm for Array Traversal ● Let A be a linear Aay with Lower Bound LB and Upper Bound UB. The following algorithm traverses A applying an operations PROCESS to each element of A Step 1. Initialize Counter Set Counter = LB Step 2. Repeat steps 3 and 4 while counter <= UB Else GoTo Step 5 Step 3. Visit element Apply PROCESS to A[counter] Step 4. Increase Counter Set counter = counter + 1 GoTo 2 Step 5. Exit www.eshikshak.co.in
  • 8. Algorithm for Insertion Let A be a Linear Array, N is number of elements, k is the positive integer such that k<=N, VAL to insert element at kth Position in an Array A Step 1. Start Step 2. Initialize Counter Set J = N Step 3. Repeat Steps 3 and 4 while J>=k otherwise GoTo Step Step 4. Move Jth element downward Set A[J+1] = A[J] Step 5. Decrease Counter Set J = J + 1 End of step 2 loop Step 6. Insert element Set A[k] = ITEM Step 7. Reset N Set N = N + 1 Step 8. Exit www.eshikshak.co.in
  • 9. Algorithm for Deletion DELETE(A, N, K, VAL) Let A be an linear Aay. N is the number of elements, k is the positive integer such that k<=N. The algorithm deletes kth element from the Aay. Step 1. Start Step 2. Set VAL = A[k] Step 3. Repeat for J = k to N-1 [Move J+1 element Upward] Set A[J] = A[J+1) End of Loop Step 4. Reset the number N of elements in A Set N = N– 1 Step 5. Exit www.eshikshak.co.in
  • 10. Algorithm for Linear Search Suppose A is linear Array with N elements, and VAL is the given item of information. This algorithm finds the location LOC of item in A or sets LOC=0 if search is unsuccessful Step 1. Start Step 2. [Insert VAL at the end of A] Set A[N+1] = VAL Step 3. [Initialize counter] SET LOC = 1 Step 4. [Search for VAL] Repeat while A[LOC] != VAL Set LOC = LOC + 1 [End of loop] Step 5. [Successful ?] if LOC = N+1 then set LOC = 0 Step 6. Exit www.eshikshak.co.in
  • 11. Algorithm for sorting Let A be an Aay of N elements. The following algorithm sorts the elements of A. Step 1. Start Step 2. Repeat Steps 2 and 3 for k=1 to N-1 Step 3. Set PTR = 1 [Initialize pass pointer PTR] Step 4. Repeat while PTR<=N-K [Execute Pass] a. If A[PTR] > A[PTR+1], then Interchange A[PTR] and A[PTR+1] [End of if structure] b. Set PTR = PTR + 1 [End of inner loop] [End of step1 outer loop] Step 5. Exit www.eshikshak.co.in