1.

Pick the incorrect statement.(a) Vectors have a dynamic size(b) Vectors are placed in contiguous storage(c) Insertion in vectors always takes constant time(d) Vectors insert the element at the endThe question was asked during an interview for a job.My enquiry is from seq_con Vector Class in chapter Class Hierarchies, Library & Containers of C++

Answer»

The correct option is (c) INSERTION in vectors always takes CONSTANT time

Explanation: Insertion in vectors are not always constant. When we are inserting an element at the end of the vector then if a vector is FULL then it needs to size itself which takes time to resize and time to insert element else just time for inserting that element at the end. Hence the insertion time is not constant always. Vectors have a dynamic size. They are placed in contiguous MEMORY for easy access.



Discussion

No Comment Found

Related InterviewSolutions