Understanding Arrays & Vectors: What They Do & Why They Matter

  • Context: C/C++ 
  • Thread starter Thread starter ineedhelpnow
  • Start date Start date
  • Tags Tags
    Arrays Matter Vectors
Click For Summary
SUMMARY

Arrays and vectors are fundamental data structures used to store collections of data. Arrays hold a fixed-size sequence of information indexed by natural numbers, while vectors, specifically referring to std::vector in C++, are dynamic arrays that allow for specialized operations such as addition and scalar multiplication. Arrays are predominantly utilized in graphics and gaming, but they also play a crucial role in various programming applications. Understanding the distinction between arrays and vectors is essential for effective coding and data management.

PREREQUISITES
  • Basic understanding of data structures
  • Familiarity with C++ programming language
  • Knowledge of mathematical operations related to vectors
  • Experience with fixed-size and dynamic arrays
NEXT STEPS
  • Explore the differences between std::vector and std::list in C++
  • Learn about memory management in dynamic arrays
  • Investigate common use cases for arrays in game development
  • Study mathematical operations on vectors in programming
USEFUL FOR

Software developers, computer science students, and anyone interested in understanding data structures and their applications in programming.

ineedhelpnow
Messages
649
Reaction score
0
whats an array for?...whats a vector for? what do they do? what purpose do they serve?
 
Last edited:
Technology news on Phys.org
ineedhelpnow said:
whats an array for?...whats a vector for? who do they do? what purpose do they serve?

Arrays are a collection of data. It holds a sequence of information indexed using natural numbers. Vectors are like those in mathematics. They have specialized operations like adding , scalar-multiplication and so on.

Usually we use arrays and vectors to store data that share a certain property. For example , the students in a class , a finite subset of even numbers , list of books on a library. Most of the time , the size of an array is fixed once declared. Arrays , are mostly used in graphics and gaming.
 
ZaidAlyafey said:
Arrays are a collection of data. It holds a sequence of information indexed using natural numbers. Vectors are like those in mathematics. They have specialized operations like adding , scalar-multiplication and so on.

Usually we use arrays and vectors to store data that share a certain property. For example , the students in a class , a finite subset of even numbers , list of books on a library. Most of the time , the size of an array is fixed once declared. Arrays , are mostly used in graphics and gaming.

I would say arrays have more uses than outside graphics and gaming. Most nontrivial programs feature arrays in some way. Arrays and key-value stores (dictionaries/maps) are the most basic data structures.

Also, I think NHN is talking about std::vector, not an actual 3D vector (std::vector is just a type-safe dynamic array). I seriously hate that it's called a "vector" and not an array or list, it's really confusing (even more confusingly, there is an std::list, but it's implemented as a linked list, and hence not usually worth using).
 
A vector is an ordered list of items of a given data type.
this is what i have as a definition but i still don't really get it.
 
i remember he said in class that we don't ACTUALLY use arrays when we code or something like that. and that got me very confused. he didn't explain it. he just mentioned something about not using them when coding and then he cut off.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 20 ·
Replies
20
Views
3K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 31 ·
2
Replies
31
Views
3K
Replies
6
Views
3K
  • · Replies 17 ·
Replies
17
Views
3K
Replies
20
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 13 ·
Replies
13
Views
5K