0% found this document useful (0 votes)
13 views16 pages

Is Vector A Data Structure in C++

The document discusses data structures in C++, focusing on the Standard Template Library (STL) and specifically the vector data structure. It explains that vectors are dynamic arrays that can resize automatically, allowing for efficient data management and manipulation. The presentation concludes that vectors qualify as data structures as they organize and store data while providing operations for data manipulation.

Uploaded by

shreyansh YEOLE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views16 pages

Is Vector A Data Structure in C++

The document discusses data structures in C++, focusing on the Standard Template Library (STL) and specifically the vector data structure. It explains that vectors are dynamic arrays that can resize automatically, allowing for efficient data management and manipulation. The presentation concludes that vectors qualify as data structures as they organize and store data while providing operations for data manipulation.

Uploaded by

shreyansh YEOLE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

IS VECTOR A DATA

STRUCTURE IN C++?
2

AGENDA
Introduction to Data Structures
STL in C++
What is Vector ? Difference between vector
and arrays
Example problem to show vector in C++
Conclusion
INTRODUCTION TO
DATA STRUCTURES
DATA STRUCTURES
A data structure is a way of organizing,
storing, and managing data in a
computer so that it can be used
efficiently.

It defines the layout for data storage,


how the data is accessed, and how
operations like searching, adding, or
removing data are performed.

Common types of data structures


include:
Array, linked lists, stacks, queues, trees,
vectors, etc.
STL IN C++
Effortless way to implement
Data Structure in C++
STL 7

• The Standard Template Library (STL) in C++ is a powerful


collection of template-based classes and functions that
provide many commonly used data structures and
algorithms.
• It is a foundational part of the C++ Standard Library and
helps developers avoid writing common data structures and
algorithms from scratch by providing pre-built, efficient
implementations.
• Key Components of the STL
1. Containers: Containers are data structures that store collections of
objects.
2. Iterators
3. Algorithms: Functions that perform operations on data stored in
containers, such as searching, sorting, modifying, and more.
8

WHAT IS VECTOR?
DIFFERENCE BETWEEN
VECTOR AND ARRAYS
Static and dynamic arrays.
9

WHAT IS A VECTOR?
In C++, a vector is a part of the Standard
Template Library (STL) and is implemented
as a dynamic array

It allows you to store and manage


collections of elements, just like arrays, but
with the added capability of dynamically
resizing as elements are added or
removed.

Let’s dive deep into its features:


FEATURES OF VECTOR
1.Dynamic Sizing
10
• A vector allows elements to be added or removed, and it
adjusts its size automatically.
2. Contiguous Memory Allocation
• Like arrays, vectors store elements in contiguous memory
locations.
3. Template Class
• A vector in C++ is implemented as a template class,
meaning you can create a vector of any data type. For
example:
std::vector<int> intVector; // Vector of integers
std::vector<std::string> strVector; // Vector of
strings
11

COMMON OPERATIONS ON VECTORS


•Inserting elements: You can add elements using methods
like : push_back(), insert(), etc.
•Accessing elements: Elements can be accessed using the
[] operator or the at() method.
•Removing elements: Elements can be removed using
methods like pop_back(), erase(), etc.
•Size management: Methods like size(), resize(),
capacity(), and reserve() help manage the size and capacity
of the vector.
12

DIFFERENCE BETWEEN ARRAY AND VECTOR


13

EXAMPLE PROBLEM TO SHOW VECTOR IN C++


Problem: Dynamic Storage of User Input
Write a C++ program that takes an unknown number of
integers from the user and stores them in a vector until they
enter -1.

After that, print all the numbers they entered (except -1).
14
15

CONCLUSION
So the conclusion of this presentation or Answer
to the question with which we have started our
presentation is YES, Vector is a data structure as it
follows the definition of data structure which we
have learned earlier in this presentation i.e. a
container should organize and store data in a
particular layout and at the same time provide
additional operations to manipulate the stored
data in data structure to get the desired output of
THANK
YOU
While(!(succeed == try()));
//Keep trying until efforts meets the
success;

You might also like