- #1
ineedhelpnow
- 651
- 0
whats an array for?...whats a vector for? what do they do? what purpose do they serve?
Last edited:
ineedhelpnow said:whats an array for?...whats a vector for? who do they do? what purpose do they serve?
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.
An array is a data structure that stores a collection of elements of the same data type in a sequential manner. Each element in the array is assigned a unique index number, allowing for efficient access and manipulation of the data.
A vector is a mathematical object that represents both magnitude and direction. In computer science, a vector is often used to store and manipulate a collection of values, similar to an array. However, unlike arrays, vectors can dynamically resize and can store elements of different data types.
Arrays and vectors are similar in that they both store collections of data. However, arrays have a fixed size and can only store elements of the same data type, while vectors can dynamically resize and can store elements of different data types.
Arrays and vectors are important in computer science because they allow for efficient storage, access, and manipulation of data. They are also essential in many algorithms and data structures, making them a fundamental concept in computer science.
Arrays and vectors are related in that they both store collections of data. Vectors can be viewed as a more flexible and dynamic version of arrays, as they can perform similar operations but with added features such as resizing and storing different data types.