SlideShare a Scribd company logo
Click to add Title
Comparison between vector
List & Sequence
e-Infochips Institute of Training Research and Academics Limited
Prepared By:
Savani Nirali
Sanghani Monika
Sequence: Collection of elements organized in a specified order. Allows random
access by rank or position.
Stack: Sequence that can be accessed in LIFO fashion.
Queue: Sequence that can be accessed in FIFO fashion.
Vector: Sequence with random access by rank. The term rank to refer to the index of
an element in a vector.
List: Sequence with random access by position. The abstract node objects positions
to refer to the elements of list ADT.
Introduction
• The rank of an element e in a sequence S is the number of elements that are
before e in S.
• A linear sequence that supports access to its elements by their ranks is called a
vector.
• The vector ADT extends the notion of array by storing a sequence of arbitrary
objects.
• An element can be accessed, inserted or removed by specifying its rank (number
of elements preceding it)
• An exception is thrown if an incorrect rank is specified (e.g., a negative rank)
Vector ADT
• Main vector ADT operations:
elemAtRank(int r): returns the element at rank r without removing it
replaceAtRank(int r, Object o): replace the element at rank r with o
insertAtRank(int r, Object o): insert a new element o to have rank r
removeAtRank(int r): removes the element at rank r
• Additional operations: size() and isEmpty().
A Simple Array-Based Implementation of Vector:
• Use an array V of size N
• A variable n keeps track of the size of the vector (number of elements stored).
• Operation elemAtRank(r) is implemented in O(1) time by returning V[r].
Insertion:
• In operation insertAtRank(r,o), we need to make room for the new element by
shifting forward the n − r elements V[r], . . ., V[n − 1].
• In the worst case (r = 0), this takes O(n) time.
Deletion:
• In operation removeAtRank(r), we need to fill the hole left by the removed
element by shifting backward the n − r − 1 elements V[r + 1], . . ., V[n − 1]
• In the worst case (r = 0), this takes O(n) time
Performance:
•In the array based implementation of a vector ADT
The space used by the data structure is O(n)
size, isEmpty, elemAtRank and replaceAtRank run in O(1) time
insertAtRank and removeAtRank run in O(n) time
•If we use the array in a circular fashion, insertAtRank(0) and removeAtRank(0) run
in O(1) time
•In an insertAtRank operation, when the array is full, instead of throwing an
exception, we can replace the array with a larger one
Node-Based Operations and Positions:
Position:
• We view a list ADT as a container of elements that stores each element at a position
and positions are arranged in a linear order
• The position ADT models the notion of place within a data structure where a single
object is store.
• A special nullposition refers to no object
• Positions provide a unified view of many ways of storing data, such as
a cell of an array
a node of a linked list
List ADT
• Member functions:
•Object& element(): returns the element stored at this position
•boolisNull(): returns true if this is a null position
• A position is always defined relatively, that is in term of its neighbors. p will
always be "after" some position q and "before" some position s (unless p is the
first or last position).
The List Abstract Data Type
• It establishes a before/after relation between positions
• Generic methods:
size(), isEmpty()
• Query methods:
isFirst(p), isLast(p)
• Accessor methods:
first(), last()
before(p), after(p)
• Update methods:
replaceElement(p, o), swapElements(p, q)
insertBefore(p, o) insertAfter(p, o)
insertFirst(o), insertLast(o)
remove(p)
Doubly Linked List Implementation:
•A doubly linked list provides a natural implementation of the list ADT
•Nodes implement positions and store:
element
link to the previous node
link to the next node
•Special trailer and header nodes
Insertion:
• We visualize operation insertAfter(p, X) which returns position q.
Deletion:
• We visualize remove(p), where p = last()
The Sequence Abstract Data Type
• The sequence ADT is the union of the vector and list ADTs
• Elements accessed by
Rank, or Position
• Generic methods:
size(), isEmpty()
• Vector-based methods:
elemAtRank(r), replaceAtRank(r, o),
insertAtRank(r, o), removeAtRank(r)
• List-based methods:
first(), last(),
before(p), after(p),
replaceElement(p, o), swapElements(p, q),
insertBefore(p, o), insertAfter(p, o),
insertFirst(o), insertLast(o),
remove(p)
Sequence ADT
Implementing a Sequence with an Array
• We use a circular array storing positions
• A position object stores:
Element
Rank
• Indices f and l keep track of first and last positions
Operation Array List
size, isEmpty 1 1
atRank, rankOf, elemAtRank 1 n
first, last, before, after 1 1
replaceElement, swapElements 1 1
replaceAtRank 1 n
insertAtRank, removeAtRank n n
insertFirst, insertLast 1 1
insertAfter, insertBefore n 1
remove n 1
Sequence Implementation:
Thank you

More Related Content

What's hot

Queue
QueueQueue
Queue
Raj Sarode
 
Standard template library
Standard template libraryStandard template library
Standard template library
Jancypriya M
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
Adam Mukharil Bachtiar
 
Data Structures and Files
Data Structures and FilesData Structures and Files
Data Structures and Files
KanchanPatil34
 
How to choose best containers in STL (C++)
How to choose best containers in STL (C++)How to choose best containers in STL (C++)
How to choose best containers in STL (C++)
Sangharsh agarwal
 
Team 6
Team 6Team 6
Standard template library
Standard template libraryStandard template library
Standard template library
Sukriti Singh
 
2CPP16 - STL
2CPP16 - STL2CPP16 - STL
2CPP16 - STL
Michael Heron
 
Talk on Standard Template Library
Talk on Standard Template LibraryTalk on Standard Template Library
Talk on Standard Template Library
Anirudh Raja
 
2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS2.1 STACK & QUEUE ADTS
Lec3
Lec3Lec3
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueWhat is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
Balwant Gorad
 
L11 array list
L11 array listL11 array list
L11 array list
teach4uin
 
Detalied information of queue
Detalied information of queueDetalied information of queue
Detalied information of queue
Smit Parikh
 
Queue
QueueQueue
Lec2
Lec2Lec2
Insertion & Selection Sort - using Priority Queues
Insertion & Selection Sort - using Priority QueuesInsertion & Selection Sort - using Priority Queues
Insertion & Selection Sort - using Priority Queues
Priyanka Rana
 
Quick sorting
Quick sortingQuick sorting
02 Stack
02 Stack02 Stack
Data Structures 01
Data Structures 01Data Structures 01
Data Structures 01
Budditha Hettige
 

What's hot (20)

Queue
QueueQueue
Queue
 
Standard template library
Standard template libraryStandard template library
Standard template library
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
Data Structures and Files
Data Structures and FilesData Structures and Files
Data Structures and Files
 
How to choose best containers in STL (C++)
How to choose best containers in STL (C++)How to choose best containers in STL (C++)
How to choose best containers in STL (C++)
 
Team 6
Team 6Team 6
Team 6
 
Standard template library
Standard template libraryStandard template library
Standard template library
 
2CPP16 - STL
2CPP16 - STL2CPP16 - STL
2CPP16 - STL
 
Talk on Standard Template Library
Talk on Standard Template LibraryTalk on Standard Template Library
Talk on Standard Template Library
 
2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS
 
Lec3
Lec3Lec3
Lec3
 
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueWhat is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
 
L11 array list
L11 array listL11 array list
L11 array list
 
Detalied information of queue
Detalied information of queueDetalied information of queue
Detalied information of queue
 
Queue
QueueQueue
Queue
 
Lec2
Lec2Lec2
Lec2
 
Insertion & Selection Sort - using Priority Queues
Insertion & Selection Sort - using Priority QueuesInsertion & Selection Sort - using Priority Queues
Insertion & Selection Sort - using Priority Queues
 
Quick sorting
Quick sortingQuick sorting
Quick sorting
 
02 Stack
02 Stack02 Stack
02 Stack
 
Data Structures 01
Data Structures 01Data Structures 01
Data Structures 01
 

Viewers also liked

CV Nissa Mukharomah SE -
CV Nissa Mukharomah SE  - CV Nissa Mukharomah SE  -
CV Nissa Mukharomah SE -
Nissa Mukharomah
 
Hadoop at LinkedIn
Hadoop at LinkedInHadoop at LinkedIn
Hadoop at LinkedIn
Keith Dsouza
 
Agile ppt final
Agile ppt finalAgile ppt final
Agile ppt final
Monika Sanghani
 
Ensa tomo2
Ensa tomo2Ensa tomo2
Ensa tomo2
Sofia Ferrer
 
Employee_Retention_Neha
Employee_Retention_NehaEmployee_Retention_Neha
Employee_Retention_Neha
Neha More
 
Vivi l'estate con energia
Vivi l'estate con energiaVivi l'estate con energia
Vivi l'estate con energia
viviconenergia
 
Heuristic approch monika sanghani
Heuristic approch  monika sanghaniHeuristic approch  monika sanghani
Heuristic approch monika sanghani
Monika Sanghani
 
How to avoid being marked as spam christoph pass next lead generation (long v...
How to avoid being marked as spam christoph pass next lead generation (long v...How to avoid being marked as spam christoph pass next lead generation (long v...
How to avoid being marked as spam christoph pass next lead generation (long v...
Christoph Pass
 
Union Budget 2016-2017
Union Budget 2016-2017Union Budget 2016-2017
Union Budget 2016-2017
Dharania Abirami
 
IBM Connections Cloud
IBM Connections CloudIBM Connections Cloud
IBM Connections Cloud
유 김
 
Memory management of datatypes
Memory management of datatypesMemory management of datatypes
Memory management of datatypes
Monika Sanghani
 
Conceptos de linealización gráficas lineales
Conceptos de linealización gráficas linealesConceptos de linealización gráficas lineales
Conceptos de linealización gráficas lineales
Isaias Ponce
 
Ajaran buddha dan kematian
Ajaran buddha dan kematianAjaran buddha dan kematian
Ajaran buddha dan kematian
unitperpustakaan
 
methods and tools for directed creativity
methods and tools for directed creativitymethods and tools for directed creativity
methods and tools for directed creativity
Dharania Abirami
 
Model & method of managerial job
Model & method of managerial jobModel & method of managerial job
Model & method of managerial job
Dharania Abirami
 
Enhancing Teaching and Learning Process
Enhancing Teaching and Learning Process Enhancing Teaching and Learning Process
Enhancing Teaching and Learning Process
Pravin Nikumbh
 

Viewers also liked (17)

CV Nissa Mukharomah SE -
CV Nissa Mukharomah SE  - CV Nissa Mukharomah SE  -
CV Nissa Mukharomah SE -
 
Hadoop at LinkedIn
Hadoop at LinkedInHadoop at LinkedIn
Hadoop at LinkedIn
 
Agile ppt final
Agile ppt finalAgile ppt final
Agile ppt final
 
Ensa tomo2
Ensa tomo2Ensa tomo2
Ensa tomo2
 
Employee_Retention_Neha
Employee_Retention_NehaEmployee_Retention_Neha
Employee_Retention_Neha
 
Vivi l'estate con energia
Vivi l'estate con energiaVivi l'estate con energia
Vivi l'estate con energia
 
POLYCARO
POLYCAROPOLYCARO
POLYCARO
 
Heuristic approch monika sanghani
Heuristic approch  monika sanghaniHeuristic approch  monika sanghani
Heuristic approch monika sanghani
 
How to avoid being marked as spam christoph pass next lead generation (long v...
How to avoid being marked as spam christoph pass next lead generation (long v...How to avoid being marked as spam christoph pass next lead generation (long v...
How to avoid being marked as spam christoph pass next lead generation (long v...
 
Union Budget 2016-2017
Union Budget 2016-2017Union Budget 2016-2017
Union Budget 2016-2017
 
IBM Connections Cloud
IBM Connections CloudIBM Connections Cloud
IBM Connections Cloud
 
Memory management of datatypes
Memory management of datatypesMemory management of datatypes
Memory management of datatypes
 
Conceptos de linealización gráficas lineales
Conceptos de linealización gráficas linealesConceptos de linealización gráficas lineales
Conceptos de linealización gráficas lineales
 
Ajaran buddha dan kematian
Ajaran buddha dan kematianAjaran buddha dan kematian
Ajaran buddha dan kematian
 
methods and tools for directed creativity
methods and tools for directed creativitymethods and tools for directed creativity
methods and tools for directed creativity
 
Model & method of managerial job
Model & method of managerial jobModel & method of managerial job
Model & method of managerial job
 
Enhancing Teaching and Learning Process
Enhancing Teaching and Learning Process Enhancing Teaching and Learning Process
Enhancing Teaching and Learning Process
 

Similar to Vectors,squence & list

Lec3
Lec3Lec3
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
blessyboban92
 
Data structures
Data structuresData structures
Data structures
Sneha Chopra
 
JavaScript.pptx
JavaScript.pptxJavaScript.pptx
JavaScript.pptx
pramod599939
 
Queue
QueueQueue
Data Structures and Algorithms Fundamentals
Data Structures and Algorithms FundamentalsData Structures and Algorithms Fundamentals
Data Structures and Algorithms Fundamentals
Ashwin Kumar Ramasamy
 
standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++
•sreejith •sree
 
Array linear data_structure_2 (1)
Array linear data_structure_2 (1)Array linear data_structure_2 (1)
Array linear data_structure_2 (1)
eShikshak
 
ACP-arrays.pptx
ACP-arrays.pptxACP-arrays.pptx
ACP-arrays.pptx
MuhammadSubtain9
 
DS UNIT2QUEUES.pptx
DS UNIT2QUEUES.pptxDS UNIT2QUEUES.pptx
DS UNIT2QUEUES.pptx
VeerannaKotagi1
 
Arrays in C.pptx
Arrays in C.pptxArrays in C.pptx
Arrays in C.pptx
HarsimranKaur362773
 
Data structures and Algorithm analysis_Lecture 2.pptx
Data structures and Algorithm analysis_Lecture 2.pptxData structures and Algorithm analysis_Lecture 2.pptx
Data structures and Algorithm analysis_Lecture 2.pptx
AhmedEldesoky24
 
Complexity in array
Complexity in arrayComplexity in array
Complexity in array
Nahin Kumar Dey
 
DS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and EngineeringDS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and Engineering
RAJASEKHARV8
 
NEW AP Computer Science Exam GridWorld Quick Reference Booklet
NEW AP Computer Science Exam GridWorld Quick Reference BookletNEW AP Computer Science Exam GridWorld Quick Reference Booklet
NEW AP Computer Science Exam GridWorld Quick Reference Booklet
A Jorge Garcia
 
DATA STRUCTURES USING C -ENGGDIGEST
DATA STRUCTURES USING C -ENGGDIGESTDATA STRUCTURES USING C -ENGGDIGEST
DATA STRUCTURES USING C -ENGGDIGEST
Swapnil Mishra
 
STRINGS IN JAVA
STRINGS IN JAVASTRINGS IN JAVA
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queue
Rai University
 
Data structure using c module 1
Data structure using c module 1Data structure using c module 1
Data structure using c module 1
smruti sarangi
 
Review of basic data structures
Review of basic data structuresReview of basic data structures
Review of basic data structures
Deepa Rani
 

Similar to Vectors,squence & list (20)

Lec3
Lec3Lec3
Lec3
 
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
Data structuresData structures
Data structures
 
JavaScript.pptx
JavaScript.pptxJavaScript.pptx
JavaScript.pptx
 
Queue
QueueQueue
Queue
 
Data Structures and Algorithms Fundamentals
Data Structures and Algorithms FundamentalsData Structures and Algorithms Fundamentals
Data Structures and Algorithms Fundamentals
 
standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++
 
Array linear data_structure_2 (1)
Array linear data_structure_2 (1)Array linear data_structure_2 (1)
Array linear data_structure_2 (1)
 
ACP-arrays.pptx
ACP-arrays.pptxACP-arrays.pptx
ACP-arrays.pptx
 
DS UNIT2QUEUES.pptx
DS UNIT2QUEUES.pptxDS UNIT2QUEUES.pptx
DS UNIT2QUEUES.pptx
 
Arrays in C.pptx
Arrays in C.pptxArrays in C.pptx
Arrays in C.pptx
 
Data structures and Algorithm analysis_Lecture 2.pptx
Data structures and Algorithm analysis_Lecture 2.pptxData structures and Algorithm analysis_Lecture 2.pptx
Data structures and Algorithm analysis_Lecture 2.pptx
 
Complexity in array
Complexity in arrayComplexity in array
Complexity in array
 
DS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and EngineeringDS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and Engineering
 
NEW AP Computer Science Exam GridWorld Quick Reference Booklet
NEW AP Computer Science Exam GridWorld Quick Reference BookletNEW AP Computer Science Exam GridWorld Quick Reference Booklet
NEW AP Computer Science Exam GridWorld Quick Reference Booklet
 
DATA STRUCTURES USING C -ENGGDIGEST
DATA STRUCTURES USING C -ENGGDIGESTDATA STRUCTURES USING C -ENGGDIGEST
DATA STRUCTURES USING C -ENGGDIGEST
 
STRINGS IN JAVA
STRINGS IN JAVASTRINGS IN JAVA
STRINGS IN JAVA
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queue
 
Data structure using c module 1
Data structure using c module 1Data structure using c module 1
Data structure using c module 1
 
Review of basic data structures
Review of basic data structuresReview of basic data structures
Review of basic data structures
 

Recently uploaded

Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
mamunhossenbd75
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
ssuser36d3051
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
mahammadsalmanmech
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
awadeshbabu
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
rpskprasana
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 

Recently uploaded (20)

Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 

Vectors,squence & list

  • 1. Click to add Title Comparison between vector List & Sequence e-Infochips Institute of Training Research and Academics Limited Prepared By: Savani Nirali Sanghani Monika
  • 2. Sequence: Collection of elements organized in a specified order. Allows random access by rank or position. Stack: Sequence that can be accessed in LIFO fashion. Queue: Sequence that can be accessed in FIFO fashion. Vector: Sequence with random access by rank. The term rank to refer to the index of an element in a vector. List: Sequence with random access by position. The abstract node objects positions to refer to the elements of list ADT. Introduction
  • 3. • The rank of an element e in a sequence S is the number of elements that are before e in S. • A linear sequence that supports access to its elements by their ranks is called a vector. • The vector ADT extends the notion of array by storing a sequence of arbitrary objects. • An element can be accessed, inserted or removed by specifying its rank (number of elements preceding it) • An exception is thrown if an incorrect rank is specified (e.g., a negative rank) Vector ADT
  • 4. • Main vector ADT operations: elemAtRank(int r): returns the element at rank r without removing it replaceAtRank(int r, Object o): replace the element at rank r with o insertAtRank(int r, Object o): insert a new element o to have rank r removeAtRank(int r): removes the element at rank r • Additional operations: size() and isEmpty().
  • 5. A Simple Array-Based Implementation of Vector: • Use an array V of size N • A variable n keeps track of the size of the vector (number of elements stored). • Operation elemAtRank(r) is implemented in O(1) time by returning V[r]. Insertion: • In operation insertAtRank(r,o), we need to make room for the new element by shifting forward the n − r elements V[r], . . ., V[n − 1]. • In the worst case (r = 0), this takes O(n) time.
  • 6. Deletion: • In operation removeAtRank(r), we need to fill the hole left by the removed element by shifting backward the n − r − 1 elements V[r + 1], . . ., V[n − 1] • In the worst case (r = 0), this takes O(n) time
  • 7. Performance: •In the array based implementation of a vector ADT The space used by the data structure is O(n) size, isEmpty, elemAtRank and replaceAtRank run in O(1) time insertAtRank and removeAtRank run in O(n) time •If we use the array in a circular fashion, insertAtRank(0) and removeAtRank(0) run in O(1) time •In an insertAtRank operation, when the array is full, instead of throwing an exception, we can replace the array with a larger one
  • 8. Node-Based Operations and Positions: Position: • We view a list ADT as a container of elements that stores each element at a position and positions are arranged in a linear order • The position ADT models the notion of place within a data structure where a single object is store. • A special nullposition refers to no object • Positions provide a unified view of many ways of storing data, such as a cell of an array a node of a linked list List ADT
  • 9. • Member functions: •Object& element(): returns the element stored at this position •boolisNull(): returns true if this is a null position • A position is always defined relatively, that is in term of its neighbors. p will always be "after" some position q and "before" some position s (unless p is the first or last position).
  • 10. The List Abstract Data Type • It establishes a before/after relation between positions • Generic methods: size(), isEmpty() • Query methods: isFirst(p), isLast(p) • Accessor methods: first(), last() before(p), after(p) • Update methods: replaceElement(p, o), swapElements(p, q) insertBefore(p, o) insertAfter(p, o) insertFirst(o), insertLast(o) remove(p)
  • 11. Doubly Linked List Implementation: •A doubly linked list provides a natural implementation of the list ADT •Nodes implement positions and store: element link to the previous node link to the next node •Special trailer and header nodes
  • 12. Insertion: • We visualize operation insertAfter(p, X) which returns position q.
  • 13. Deletion: • We visualize remove(p), where p = last()
  • 14. The Sequence Abstract Data Type • The sequence ADT is the union of the vector and list ADTs • Elements accessed by Rank, or Position • Generic methods: size(), isEmpty() • Vector-based methods: elemAtRank(r), replaceAtRank(r, o), insertAtRank(r, o), removeAtRank(r) • List-based methods: first(), last(), before(p), after(p), replaceElement(p, o), swapElements(p, q), insertBefore(p, o), insertAfter(p, o), insertFirst(o), insertLast(o), remove(p) Sequence ADT
  • 15. Implementing a Sequence with an Array • We use a circular array storing positions • A position object stores: Element Rank • Indices f and l keep track of first and last positions
  • 16. Operation Array List size, isEmpty 1 1 atRank, rankOf, elemAtRank 1 n first, last, before, after 1 1 replaceElement, swapElements 1 1 replaceAtRank 1 n insertAtRank, removeAtRank n n insertFirst, insertLast 1 1 insertAfter, insertBefore n 1 remove n 1 Sequence Implementation:

Editor's Notes

  1. 1