Complexity
There are different measurements of the speed of any given algorithm. Given an input size of N, they can be described as follows:
Name Speed Description
exponential time slow takes an amount of time proportional to a constant raised to the Nth power (K^N)
polynomial time fast takes an amount of time proportional to N raised to some constant power (N^K)
linear time faster takes an amount of time directly proportional to N (K * N)
logarithmic time much faster takes an amount of time proportional to the logarithm of N (log(N))
constant time fastest takes a fixed amount of time, no matter how large the input is (K)
http://www.cppreference.com/complexity.html kombineret med
Vectors contain contiguous elements stored as an array. Accessing members of a vector or appending elements can be done in constant time, whereas locating a specific value or inserting elements into the vector takes linear time.
http://www.cppreference.com/cppvector.htmlLists are sequences of elements stored in a linked list. Compared to vectors, they allow fast insertions and deletions, but slower random access.
http://www.cppreference.com/cpplist.htmlDVS list er hurtigere til at indsætte og slette fra, men langsommere til random access. Hvilket ikke fremgår af Komplesiteten (O(n)). Det er begge dele jeg ønsker at udtale mig om.
Jeg kan godt se spørgsmålet nok ikke var super godt formuleret.