VMWare Inc Interview Question
Software Engineer / DevelopersArray: Its a fixed length contiguous memory.
Vector: Vector is a variable length contiguous memory. It is initialized with a fixed length 'n'. When it is full and you try to insert a new element in the vector, It will create a new fixed length contiguous memory of size 'current vector size'+'n' and copy the original data into the new memory, delete the original memory and then it will insert the new element to the newly created memory space. This process will occur as and when vector runs out of space. Here 'n' is configurable which is specified at the time of initializing the vector.
Array: Its a fixed length contiguous memory.
Vector: Vector is a variable length contiguous memory. It is initialized with a fixed length "n". When it is full and you try to insert a new element in the vector, It will create a new fixed length contiguous memory of size "current vector size"+"n" and copy the original data into the new memory, delete the original memory and then it will insert the new element to the newly created memory space. This process will occur as and when vector runs out of space. Here "n" is configurable which is specified at the time of initializing the vector.
A vector is a dynamic array.
- XYZ October 29, 2008