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
Ad

Recommended

Arrays Data Structure
Arrays Data Structure
student
 
daa-unit-3-greedy method
daa-unit-3-greedy method
hodcsencet
 
Array data structure
Array data structure
maamir farooq
 
Binary search
Binary search
AparnaKumari31
 
Asymptotic notations
Asymptotic notations
Nikhil Sharma
 
Analysis and Design of Algorithms
Analysis and Design of Algorithms
Bulbul Agrawal
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
imtiazalijoono
 
Deque and its applications
Deque and its applications
Jsaddam Hussain
 
Divide and conquer
Divide and conquer
Dr Shashikant Athawale
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First Search
Kevin Jadiya
 
stack presentation
stack presentation
Shivalik college of engineering
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
Array ppt
Array ppt
Kaushal Mehta
 
Binary Search Tree
Binary Search Tree
sagar yadav
 
Recursion - Algorithms and Data Structures
Recursion - Algorithms and Data Structures
Priyanka Rana
 
DAA AND DAS
DAA AND DAS
Basavaraj Shetty
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
cs19club
 
Complexity analysis in Algorithms
Complexity analysis in Algorithms
Daffodil International University
 
Matrix chain multiplication
Matrix chain multiplication
Respa Peter
 
Data structure
Data structure
viswanathV8
 
Python programming : Arrays
Python programming : Arrays
Emertxe Information Technologies Pvt Ltd
 
Algorithm analysis
Algorithm analysis
sumitbardhan
 
Input Output Organization
Input Output Organization
Kamal Acharya
 
Quick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And Analysis
SNJ Chaudhary
 
Python Modules
Python Modules
Nitin Reddy Katkam
 
Data Structures- Part5 recursion
Data Structures- Part5 recursion
Abdullah Al-hazmy
 
5.2 divide and conquer
5.2 divide and conquer
Krish_ver2
 
header, circular and two way linked lists
header, circular and two way linked lists
student
 
Algo>Abstract data type
Algo>Abstract data type
Ain-ul-Moiz Khawaja
 
DATA STRUCTURES
DATA STRUCTURES
bca2010
 

More Related Content

What's hot (20)

Divide and conquer
Divide and conquer
Dr Shashikant Athawale
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First Search
Kevin Jadiya
 
stack presentation
stack presentation
Shivalik college of engineering
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
Array ppt
Array ppt
Kaushal Mehta
 
Binary Search Tree
Binary Search Tree
sagar yadav
 
Recursion - Algorithms and Data Structures
Recursion - Algorithms and Data Structures
Priyanka Rana
 
DAA AND DAS
DAA AND DAS
Basavaraj Shetty
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
cs19club
 
Complexity analysis in Algorithms
Complexity analysis in Algorithms
Daffodil International University
 
Matrix chain multiplication
Matrix chain multiplication
Respa Peter
 
Data structure
Data structure
viswanathV8
 
Python programming : Arrays
Python programming : Arrays
Emertxe Information Technologies Pvt Ltd
 
Algorithm analysis
Algorithm analysis
sumitbardhan
 
Input Output Organization
Input Output Organization
Kamal Acharya
 
Quick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And Analysis
SNJ Chaudhary
 
Python Modules
Python Modules
Nitin Reddy Katkam
 
Data Structures- Part5 recursion
Data Structures- Part5 recursion
Abdullah Al-hazmy
 
5.2 divide and conquer
5.2 divide and conquer
Krish_ver2
 
header, circular and two way linked lists
header, circular and two way linked lists
student
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First Search
Kevin Jadiya
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
Binary Search Tree
Binary Search Tree
sagar yadav
 
Recursion - Algorithms and Data Structures
Recursion - Algorithms and Data Structures
Priyanka Rana
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
cs19club
 
Matrix chain multiplication
Matrix chain multiplication
Respa Peter
 
Algorithm analysis
Algorithm analysis
sumitbardhan
 
Input Output Organization
Input Output Organization
Kamal Acharya
 
Quick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And Analysis
SNJ Chaudhary
 
Data Structures- Part5 recursion
Data Structures- Part5 recursion
Abdullah Al-hazmy
 
5.2 divide and conquer
5.2 divide and conquer
Krish_ver2
 
header, circular and two way linked lists
header, circular and two way linked lists
student
 

Viewers also liked (13)

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

Similar to Array linear data_structure_2 (1) (20)

data structure and algorithm Array.pptx btech 2nd year
data structure and algorithm Array.pptx btech 2nd year
palhimanshi999
 
Updated Lab3.docx
Updated Lab3.docx
AleezaAnjum
 
03 Linear Arrays Memory Representations .pdf
03 Linear Arrays Memory Representations .pdf
KkSingh64
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
Sowmya Jyothi
 
PPT Lecture 2.2.1 onn c++ data structures
PPT Lecture 2.2.1 onn c++ data structures
midtushar
 
arrays
arrays
Enakshi Chanda
 
Data structures (Array 1 dimensional).pptx
Data structures (Array 1 dimensional).pptx
itzsomeone50
 
arrays1.ppt python programme arrays insertion
arrays1.ppt python programme arrays insertion
bushraashraf639
 
Array data structure
Array data structure
harsh112327
 
ARRAY in python and c with examples .pptx
ARRAY in python and c with examples .pptx
abhishekmaurya102515
 
Data structure and algorithm All in One
Data structure and algorithm All in One
jehan1987
 
DSA.pdf
DSA.pdf
AkashSaha75835
 
Data structure using c module 1
Data structure using c module 1
smruti sarangi
 
Unit 2 dsa LINEAR DATA STRUCTURE
Unit 2 dsa LINEAR DATA STRUCTURE
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
358 33 powerpoint-slides_5-arrays_chapter-5
358 33 powerpoint-slides_5-arrays_chapter-5
sumitbardhan
 
datastructureppt-190327174340 (1).pptx
datastructureppt-190327174340 (1).pptx
DEEPAK948083
 
DSA - Array.pptx
DSA - Array.pptx
11STEM2PGROUP1
 
Arrays
Arrays
SARITHA REDDY
 
2.DS Array
2.DS Array
Chandan Singh
 
Array Operations.pptxdata structure array indsa
Array Operations.pptxdata structure array indsa
ar0454492
 
data structure and algorithm Array.pptx btech 2nd year
data structure and algorithm Array.pptx btech 2nd year
palhimanshi999
 
Updated Lab3.docx
Updated Lab3.docx
AleezaAnjum
 
03 Linear Arrays Memory Representations .pdf
03 Linear Arrays Memory Representations .pdf
KkSingh64
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
Sowmya Jyothi
 
PPT Lecture 2.2.1 onn c++ data structures
PPT Lecture 2.2.1 onn c++ data structures
midtushar
 
Data structures (Array 1 dimensional).pptx
Data structures (Array 1 dimensional).pptx
itzsomeone50
 
arrays1.ppt python programme arrays insertion
arrays1.ppt python programme arrays insertion
bushraashraf639
 
Array data structure
Array data structure
harsh112327
 
ARRAY in python and c with examples .pptx
ARRAY in python and c with examples .pptx
abhishekmaurya102515
 
Data structure and algorithm All in One
Data structure and algorithm All in One
jehan1987
 
Data structure using c module 1
Data structure using c module 1
smruti sarangi
 
358 33 powerpoint-slides_5-arrays_chapter-5
358 33 powerpoint-slides_5-arrays_chapter-5
sumitbardhan
 
datastructureppt-190327174340 (1).pptx
datastructureppt-190327174340 (1).pptx
DEEPAK948083
 
Array Operations.pptxdata structure array indsa
Array Operations.pptxdata structure array indsa
ar0454492
 
Ad

More from eShikshak (20)

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

Recently uploaded (20)

AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 

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