C/C++ Understanding Arrays & Vectors: What They Do & Why They Matter

AI Thread Summary
Arrays are collections of data indexed by natural numbers, primarily used to store sequences of information that share a common property, such as a list of students or even numbers. They are commonly utilized in graphics and gaming, but their applications extend to various programming contexts, as most nontrivial programs incorporate arrays in some form. The size of an array is typically fixed upon declaration. Vectors, often confused with arrays, are dynamic arrays that allow for specialized operations like addition and scalar multiplication. The term "vector" can be misleading, as it refers to a type-safe dynamic array rather than a mathematical vector. This confusion is compounded by the existence of other data structures like std::list, which is implemented as a linked list. There is some debate about the practical use of arrays in coding, with suggestions that they may not be as prevalent in modern programming practices.
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.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top