Lesson 1 (MIDTERM) Flashcards

(28 cards)

1
Q

Is a dynamic array provided by the Standard Template Library (STL).

A

Vector

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Unlike regular arrays, ______ can resize automatically as elements are added or removed.

A

Vectors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

They are stored in contiguous memory and support random access, just like arrays

A

Vectors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the use cases of vectors

A

Dynamic Arrays
Matrix Representation (2D Arrays)
Graph Representation
Dynamic Data Structures
Sorting and Searching Algorithms
Dynamic Input Handling
Database-like Application
Game Development (Handling Game Objects)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Vectors are often used as a replacement for fixed-size arrays. In cases where the number of elements is not known in advance, vectors allow dynamic resizing.

A

Dynamic Arrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Vectors represent matrices or multi-dimensional arrays efficiently. This is useful in applications like image processing, where you may need to store pixel data, or for mathematical computations like matrix multiplication.

A

Matrix Representation (2D Arrays)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Vectors are frequently used to store graphs, particularly using an adjacency list, Each node in the graph can be a vector containing the nodes it connects to.

A

Graph Representation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Vectors can act as a flexible stack, queue, or deque (Double-ended queue) in many algorithms

A

Dynamic Data Structures

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Vectors are a common data structure for sorting and searching algorithms due to their random-access capabilities

A

Sorting and Searching Algorithms

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In scenarios where the amount of input data is unknown (e.g., reading from a file, user input), vectors are perfect for storing data dynamically.

A

Dynamic Input Handling

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Vectors can act as in-memory storage for rows of data, where each row is a vector of values. This is useful in simple database-like applications for storing and querying data

A

Database-like Application

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Vectors can store dynamic collections of game objects (like characters, enemies, or projectiles) that are created or destroyed during the game.

A

Game Development (Handling Game Objects)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Store dynamic student records, scores, or IDs

A

Student Management System

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Store a growing list of selected products

A

Online Shopping Cart

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Maintain a list of enemies, items, or players.

A

Game Development

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Use vector of vectors and adjancency lists

A

Graph Algorithms

17
Q

Dynamic Storage for lines or words typed

18
Q

Maintain a list of recent files accessed

19
Q

What are the common operations

A

push_back(x)
pop_back()
size()
operator[]
at(index)
empty()
clear()
front and back()

20
Q

Add to end

21
Q

Remove last element

22
Q

Returns number of elements

23
Q

Accesses element by index without bounds checking

24
Q

Accesses element by index with bounds checking (throws exception if out of range).

25
Checks if vector is empty
empty()
26
Removes all elements
clear()
27
First and last elements
front() and back()
28
A language feature, not a method but important as it shows how vectors can be iterated over easily
Range based for loop