SlideShare a Scribd company logo
1 of 11
Download to read offline
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

Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Treesagar yadav
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure Janki Shah
 
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - NotesOmprakash Chauhan
 
Searching in c language
Searching in c languageSearching in c language
Searching in c languageCHANDAN KUMAR
 
Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applicationsJsaddam Hussain
 
Data Structures- Part7 linked lists
Data Structures- Part7 linked listsData Structures- Part7 linked lists
Data Structures- Part7 linked listsAbdullah Al-hazmy
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListManishPrajapati78
 
Arrays Data Structure
Arrays Data StructureArrays Data Structure
Arrays Data Structurestudent
 
Array operations
Array operationsArray operations
Array operationsZAFAR444
 
Queue data structure
Queue data structureQueue data structure
Queue data structureanooppjoseph
 
Searching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And AlgorithmSearching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And Algorithm03446940736
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESSowmya Jyothi
 
Data structure & its types
Data structure & its typesData structure & its types
Data structure & its typesRameesha Sadaqat
 
Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structureSajid Marwat
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structureMAHALAKSHMI P
 

What's hot (20)

Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
 
Stack
StackStack
Stack
 
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - Notes
 
Searching in c language
Searching in c languageSearching in c language
Searching in c language
 
Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applications
 
Data Structures- Part7 linked lists
Data Structures- Part7 linked listsData Structures- Part7 linked lists
Data Structures- Part7 linked lists
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked List
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
Arrays Data Structure
Arrays Data StructureArrays Data Structure
Arrays Data Structure
 
Quick Sort
Quick SortQuick Sort
Quick Sort
 
Array operations
Array operationsArray operations
Array operations
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
Searching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And AlgorithmSearching techniques in Data Structure And Algorithm
Searching techniques in Data Structure And Algorithm
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
 
Data structure & its types
Data structure & its typesData structure & its types
Data structure & its types
 
Queue ppt
Queue pptQueue ppt
Queue ppt
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
 

Viewers also liked

DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURESbca2010
 
Data structure lecture 3
Data structure lecture 3Data structure lecture 3
Data structure lecture 3Kumar
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithmsHarry Potter
 
Infix-Postfix expression conversion
Infix-Postfix expression conversionInfix-Postfix expression conversion
Infix-Postfix expression conversionRashmiranja625
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and PolynomialAroosa Rajput
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingEduardo Bergavera
 
11 abstract data types
11 abstract data types11 abstract data types
11 abstract data typesjigeno
 

Viewers also liked (13)

Algo>Abstract data type
Algo>Abstract data typeAlgo>Abstract data type
Algo>Abstract data type
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
Data structure lecture 3
Data structure lecture 3Data structure lecture 3
Data structure lecture 3
 
Arrays
ArraysArrays
Arrays
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Infix-Postfix expression conversion
Infix-Postfix expression conversionInfix-Postfix expression conversion
Infix-Postfix expression conversion
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
 
Arrays
ArraysArrays
Arrays
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and Searching
 
11 abstract data types
11 abstract data types11 abstract data types
11 abstract data types
 

Similar to Array linear data_structure_2 (1)

ARRAY in python and c with examples .pptx
ARRAY  in python and c with examples .pptxARRAY  in python and c with examples .pptx
ARRAY in python and c with examples .pptxabhishekmaurya102515
 
Array data structure
Array data structureArray data structure
Array data structureharsh112327
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHIBCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHISowmya Jyothi
 
Array data structure
Array data structureArray data structure
Array data structuremaamir farooq
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1blessyboban92
 
Data structures arrays
Data structures   arraysData structures   arrays
Data structures arraysmaamir farooq
 
search_sort Search sortSearch sortSearch sortSearch sort
search_sort Search sortSearch sortSearch sortSearch sortsearch_sort Search sortSearch sortSearch sortSearch sort
search_sort Search sortSearch sortSearch sortSearch sortShanmuganathan C
 
A sorted linear array
A sorted linear array A sorted linear array
A sorted linear array Suneel Dogra
 
3.8 quick sort
3.8 quick sort3.8 quick sort
3.8 quick sortKrish_ver2
 
Data Structures - Searching & sorting
Data Structures - Searching & sortingData Structures - Searching & sorting
Data Structures - Searching & sortingKaushal Shah
 
searching in data structure.pptx
searching in data structure.pptxsearching in data structure.pptx
searching in data structure.pptxchouguleamruta24
 
Updated Lab3.docx
Updated Lab3.docxUpdated Lab3.docx
Updated Lab3.docxAleezaAnjum
 
358 33 powerpoint-slides_14-sorting_chapter-14
358 33 powerpoint-slides_14-sorting_chapter-14358 33 powerpoint-slides_14-sorting_chapter-14
358 33 powerpoint-slides_14-sorting_chapter-14sumitbardhan
 

Similar to Array linear data_structure_2 (1) (20)

sorting1.pptx
sorting1.pptxsorting1.pptx
sorting1.pptx
 
ARRAY in python and c with examples .pptx
ARRAY  in python and c with examples .pptxARRAY  in python and c with examples .pptx
ARRAY in python and c with examples .pptx
 
DSA - Array.pptx
DSA - Array.pptxDSA - Array.pptx
DSA - Array.pptx
 
Unit 7 sorting
Unit 7   sortingUnit 7   sorting
Unit 7 sorting
 
Array data structure
Array data structureArray data structure
Array data structure
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHIBCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
 
Array data structure
Array data structureArray data structure
Array data structure
 
Unit 2 - Quick Sort.pptx
Unit 2 - Quick Sort.pptxUnit 2 - Quick Sort.pptx
Unit 2 - Quick Sort.pptx
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
 
Data structures arrays
Data structures   arraysData structures   arrays
Data structures arrays
 
DSA.pdf
DSA.pdfDSA.pdf
DSA.pdf
 
search_sort Search sortSearch sortSearch sortSearch sort
search_sort Search sortSearch sortSearch sortSearch sortsearch_sort Search sortSearch sortSearch sortSearch sort
search_sort Search sortSearch sortSearch sortSearch sort
 
A sorted linear array
A sorted linear array A sorted linear array
A sorted linear array
 
3.8 quick sort
3.8 quick sort3.8 quick sort
3.8 quick sort
 
Data Structures - Searching & sorting
Data Structures - Searching & sortingData Structures - Searching & sorting
Data Structures - Searching & sorting
 
searching in data structure.pptx
searching in data structure.pptxsearching in data structure.pptx
searching in data structure.pptx
 
Updated Lab3.docx
Updated Lab3.docxUpdated Lab3.docx
Updated Lab3.docx
 
Unit6 C
Unit6 C Unit6 C
Unit6 C
 
358 33 powerpoint-slides_14-sorting_chapter-14
358 33 powerpoint-slides_14-sorting_chapter-14358 33 powerpoint-slides_14-sorting_chapter-14
358 33 powerpoint-slides_14-sorting_chapter-14
 
Sorting
SortingSorting
Sorting
 

More from eShikshak

Modelling and evaluation
Modelling and evaluationModelling and evaluation
Modelling and evaluationeShikshak
 
Operators in python
Operators in pythonOperators in python
Operators in pythoneShikshak
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in pythoneShikshak
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythoneShikshak
 
Introduction to e commerce
Introduction to e commerceIntroduction to e commerce
Introduction to e commerceeShikshak
 
Chapeter 2 introduction to cloud computing
Chapeter 2   introduction to cloud computingChapeter 2   introduction to cloud computing
Chapeter 2 introduction to cloud computingeShikshak
 
Unit 1.4 working of cloud computing
Unit 1.4 working of cloud computingUnit 1.4 working of cloud computing
Unit 1.4 working of cloud computingeShikshak
 
Unit 1.3 types of cloud
Unit 1.3 types of cloudUnit 1.3 types of cloud
Unit 1.3 types of cloudeShikshak
 
Unit 1.2 move to cloud computing
Unit 1.2   move to cloud computingUnit 1.2   move to cloud computing
Unit 1.2 move to cloud computingeShikshak
 
Unit 1.1 introduction to cloud computing
Unit 1.1   introduction to cloud computingUnit 1.1   introduction to cloud computing
Unit 1.1 introduction to cloud computingeShikshak
 
Mesics lecture files in 'c'
Mesics lecture   files in 'c'Mesics lecture   files in 'c'
Mesics lecture files in 'c'eShikshak
 
Mesics lecture 8 arrays in 'c'
Mesics lecture 8   arrays in 'c'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 executionsMesics lecture 7   iteration and repetitive executions
Mesics lecture 7 iteration and repetitive executionseShikshak
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’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__elseMesics lecture 6   control statement = if -else if__else
Mesics lecture 6 control statement = if -else if__elseeShikshak
 
Mesics lecture 4 c operators and experssions
Mesics lecture  4   c operators and experssionsMesics lecture  4   c operators and experssions
Mesics lecture 4 c operators and experssionseShikshak
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’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 variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variableseShikshak
 
Lecture 7 relational_and_logical_operators
Lecture 7 relational_and_logical_operatorsLecture 7 relational_and_logical_operators
Lecture 7 relational_and_logical_operatorseShikshak
 
Lecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.pptLecture21 categoriesof userdefinedfunctions.ppt
Lecture21 categoriesof userdefinedfunctions.ppteShikshak
 

More from eShikshak (20)

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

Recently uploaded

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Recently uploaded (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

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