Technical Interview Questions and Answers :: C++
Sequence container stores elements in a linear sequence like a line .Each elements are related to other by its position along the line. They all expand themselves to allow insertion to the elements and all of them support a number of operations on them.
Element0 -> Element1 -> Element2 -> â€¦â€¦.. -> Last elementâ€¦
Associative containers are designed to support direct access to elements using keys. They are not sequential. There are 4 types of container:
All these containers stores data in a structure called tree which facilities fast searching, deletion and insertion.
The STL provides three derived containers namely:
Stack, queue and priority queue. These are known as Container adaptors.
These can be created for different sequence container and it does not support the Iterators and therefore we cannot use them for data manipulation.
However, they support two member functions pop() and push() fro implementing deleting and inserting operation.,
Algorithms are a function that can be used generally across a variety of containers for processing their contents.
STL algorithm reinforce the philosophy of reusability. By using these algorithms, programmers can save a lot of time and effort.
To access STL Algorithm we must be included
STL algorithm based on the nature of operations it may be categorized s follows:
â€¢ retrieve or non-mutating algorithm
â€¢ Mutating algorithm
â€¢ Sorting algorithm
â€¢ Set algorithm
â€¢ Relational algorithm
The list is another container that is popularly used. It supports bidirectional, linear list and provides an efficient implementation for deletion and insertion operation. Unlike a vector, which supports random access, a list can be accessed sequentially only.
Write some important member functions of the list class?
Back() Gives a reference to the last element
Begin() Gives a reference to the first element
Clear() Deletes all the elements
Empty() Decides if the list is empty or not
End() Gives refernce to the end of the list
Erase() Deletes elements as specified
merge() Merge two ordered list
Insert() Insert elemements as specified
Pop_back() Deletes the last element
Pop_front() Deletes the first element
Push_back() Adds an element at the end
Push_front() Adds an element at the front
A map is a sequence of key value pairs that provides for fast retrieval based on the flag. Almost one value is held for each key; in other words, each key in a map is unique.
A multimap is a map, except that it allows duplicate keys. Naturally several values can exist for a single key. A multimap is preferred over a map. In some ways, a multimap is even cleaner and more elegant than a map.
Iteration over a map is simply iteration over a sequence of pair < const key, mapped_type >. For e.g. We might print out the entries of a phone book like this
Typedef map(string, number)::const_iteration CI;
For(CI =phone_book.begin( ); p!=phone_book.end( );++p)
A map iterator presents the elements in ascending order of its keys.
You can check latest and updated Honeywell C++ Interview Questions and Answers on this page. You can filter the question set by the company's name. Looking for the right answer? Don't worry! You can click on view answer section and check the answer with the explanation. You can discuss the answer in the forum with other users easily. Login with Facebook and save the answer To Reading List right now!
Our site contains top IT companies placement paper and mock test to help the freshers and experienced candidate to get hands on experience on the pattern and type of questions. We have curated all the C++ technical interview questions and answers from previous candidates.