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

What's hot (20)

PPTX
Sorting Algorithms
Pranay Neema
 
PPTX
heap Sort Algorithm
Lemia Algmri
 
PPTX
Data structures and algorithms
Julie Iskander
 
PPTX
Searching & Sorting Algorithms
Rahul Jamwal
 
PPT
Arrays Data Structure
student
 
PPT
Queue AS an ADT (Abstract Data Type)
Self-Employed
 
PPTX
Deque and its applications
Jsaddam Hussain
 
PPT
Breadth first search
Sazzad Hossain
 
PPTX
Heap sort
Ayesha Tahir
 
PPTX
linked list in data structure
shameen khan
 
PPT
Searching algorithms
Trupti Agrawal
 
PDF
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
Sowmya Jyothi
 
PPTX
Complexity analysis in Algorithms
Daffodil International University
 
PDF
Intermediate code generation in Compiler Design
Kuppusamy P
 
PPTX
Data structures
Sneha Chopra
 
PDF
Double ended queue
jyoti_lakhani
 
PPTX
linked list
Mohaimin Rahat
 
PPT
Queue Data Structure
Zidny Nafan
 
PPTX
Queues
Ashim Lamichhane
 
Sorting Algorithms
Pranay Neema
 
heap Sort Algorithm
Lemia Algmri
 
Data structures and algorithms
Julie Iskander
 
Searching & Sorting Algorithms
Rahul Jamwal
 
Arrays Data Structure
student
 
Queue AS an ADT (Abstract Data Type)
Self-Employed
 
Deque and its applications
Jsaddam Hussain
 
Breadth first search
Sazzad Hossain
 
Heap sort
Ayesha Tahir
 
linked list in data structure
shameen khan
 
Searching algorithms
Trupti Agrawal
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
Sowmya Jyothi
 
Complexity analysis in Algorithms
Daffodil International University
 
Intermediate code generation in Compiler Design
Kuppusamy P
 
Data structures
Sneha Chopra
 
Double ended queue
jyoti_lakhani
 
linked list
Mohaimin Rahat
 
Queue Data Structure
Zidny Nafan
 

Viewers also liked (13)

PPT
Algo>Abstract data type
Ain-ul-Moiz Khawaja
 
PPT
DATA STRUCTURES
bca2010
 
PPT
Data structure lecture 3
Kumar
 
PPT
Arrays
Komal Singh
 
PPTX
Data structures and algorithms
Harry Potter
 
PPTX
Infix-Postfix expression conversion
Rashmiranja625
 
PPT
Abstract data types
Luis Goldster
 
PPT
Abstract data types
Poojith Chowdhary
 
PDF
Abstract Data Types
Reggie Niccolo Santos
 
PPT
Sparse Matrix and Polynomial
Aroosa Rajput
 
PPT
Arrays
archikabhatia
 
PPT
Chapter 11 - Sorting and Searching
Eduardo Bergavera
 
PDF
11 abstract data types
jigeno
 
Algo>Abstract data type
Ain-ul-Moiz Khawaja
 
DATA STRUCTURES
bca2010
 
Data structure lecture 3
Kumar
 
Arrays
Komal Singh
 
Data structures and algorithms
Harry Potter
 
Infix-Postfix expression conversion
Rashmiranja625
 
Abstract data types
Luis Goldster
 
Abstract data types
Poojith Chowdhary
 
Abstract Data Types
Reggie Niccolo Santos
 
Sparse Matrix and Polynomial
Aroosa Rajput
 
Chapter 11 - Sorting and Searching
Eduardo Bergavera
 
11 abstract data types
jigeno
 
Ad

Similar to Array linear data_structure_2 (1) (20)

PPT
arrays1.ppt python programme arrays insertion
bushraashraf639
 
PPTX
sorting1.pptx
AJAYVISHALRP
 
PPTX
ARRAY in python and c with examples .pptx
abhishekmaurya102515
 
PPTX
Array Operations.pptxdata structure array indsa
ar0454492
 
PPTX
DSA - Array.pptx
11STEM2PGROUP1
 
PPTX
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
kncetaruna
 
PPTX
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
VISWANATHAN R V
 
PPT
Unit 7 sorting
kalyanineve
 
PDF
Array data structure
harsh112327
 
PDF
Array data structure
maamir farooq
 
PPTX
Unit 2 - Quick Sort.pptx
CO1IShwetaKidile
 
PPTX
Ist year Msc,2nd sem module1
blessyboban92
 
PDF
Data structures arrays
maamir farooq
 
PDF
DSA.pdf
AkashSaha75835
 
PPT
search_sort search_sortsearch_sort search_sortsearch_sortsearch_sortsearch_sort
Kanupriya731200
 
PPT
search_sort Search sortSearch sortSearch sortSearch sort
Shanmuganathan C
 
DOC
A sorted linear array
Suneel Dogra
 
PPTX
All Searching and Sorting Techniques in Data Structures
sonalishinge2015
 
PPT
3.8 quick sort
Krish_ver2
 
PPT
Data Structures - Searching & sorting
Kaushal Shah
 
arrays1.ppt python programme arrays insertion
bushraashraf639
 
sorting1.pptx
AJAYVISHALRP
 
ARRAY in python and c with examples .pptx
abhishekmaurya102515
 
Array Operations.pptxdata structure array indsa
ar0454492
 
DSA - Array.pptx
11STEM2PGROUP1
 
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
kncetaruna
 
UNIT V Searching Sorting Hashing Techniques [Autosaved].pptx
VISWANATHAN R V
 
Unit 7 sorting
kalyanineve
 
Array data structure
harsh112327
 
Array data structure
maamir farooq
 
Unit 2 - Quick Sort.pptx
CO1IShwetaKidile
 
Ist year Msc,2nd sem module1
blessyboban92
 
Data structures arrays
maamir farooq
 
search_sort search_sortsearch_sort search_sortsearch_sortsearch_sortsearch_sort
Kanupriya731200
 
search_sort Search sortSearch sortSearch sortSearch sort
Shanmuganathan C
 
A sorted linear array
Suneel Dogra
 
All Searching and Sorting Techniques in Data Structures
sonalishinge2015
 
3.8 quick sort
Krish_ver2
 
Data Structures - Searching & sorting
Kaushal Shah
 
Ad

More from eShikshak (20)

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

Recently uploaded (20)

PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
Designing Production-Ready AI Agents
Kunal Rai
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
July Patch Tuesday
Ivanti
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Designing Production-Ready AI Agents
Kunal Rai
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 

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