Vector: Vector is a type of dynamic array which has the ability to resize automatically after insertion or deletion of elements. The elements in vector are placed in contiguous storage so that they can be accessed and traversed using iterators. Element is inserted at the end of the vector.
vector v; v.insert(5); v.delete();
List: List is a double linked sequence that supports both forward and backward traversal. The time taken in the insertion and deletion in the beginning, end and middle is constant. It has the non-contiguous memory and there is no pre-allocated memory.
list l; l.insert_begin(5); l.delete_end();
Below is a table of differences between Vector and List:
|It has contiguous memory.||While it has non-contiguous memory.|
|It is synchronized.||While it is not synchronized.|
|Vector may have a default size.||List does not have default size.|
|In vector, each element only requires the space for itself only.||In list, each element requires extra space for the node which holds the element, including pointers to the next and previous elements in the list.|
|Insertion at the end requires constant time but insertion elsewhere is costly.||Insertion is cheap no matter where in the list it occurs.|
|Vector is thread safe.||List is not thread safe.|
|Deletion at the end of the vector needs constant time but for the rest it is O(n).||Deletion is cheap no matter where in the list it occurs.|
|Random access of elements is possible.||Random access of elements is not possible.|
|Iterators become invalid if elements are added to or removed from the vector.||Iterators are valid if elements are added to or removed from the list.|
- Classifying data using Support Vector Machines(SVMs) in Python
- Vector vs Raster Graphics
- Difference between FAT32, exFAT, and NTFS File System
- Difference between SSH and Telnet
- Difference between Machine learning and Artificial Intelligence
- What is the Difference between Website and Web Portal
- Difference between Structured, Semi-structured and Unstructured data
- Difference between Cyber Security and Information Security
- Difference between Web Browser and Web Server
- Difference between Internet and Intranet
- Difference Between Programming, Scripting, and Markup Languages
- What is the difference between Front-End and Back-End Web Development?
- Difference between a Data Analyst and a Data Scientist
- Difference between Organic Search and Paid Search
- Difference Between SEO and SEM
- Is There Any Difference Between Software Developer And Software Engineer?
- Difference between Tor and VPN
- Difference between Search Engine and Web Browser
- Difference Between Data Science and Data Engineering
- Difference Between Architectural Style, Architectural Patterns and Design Patterns
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.