[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

Technical Interview Questions and Answers :: C++

    1 / 187

    Define sequence container?
    Answer:

    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…


    /\
    |

    Begin() end()

    Please Login First :

    2 / 187

    What is meant by associative container?
    Answer:

    Associative containers are designed to support direct access to elements using keys. They are not sequential. There are 4 types of container:
    • set
    • multiset
    • multimap
    • map

    All these containers stores data in a structure called tree which facilities fast searching, deletion and insertion.

    Please Login First :

    3 / 187

    Define derived container?
    Answer:

    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.,

    Please Login First :

    4 / 187

    What is meant by algorithm?
    Answer:

    Algorithms are a function that can be used generally across a variety of containers for processing their contents.

    Please Login First :

    5 / 187

    What is meant by STL algorithm?
    Answer:

    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 in our program.

    Please Login First :

    6 / 187

    What are the categories of STL algorithm?
    Answer:

    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

    Please Login First :

    7 / 187

    What is meant by list?
    Answer:

    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?

    Function Task
    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

    Please Login First :

    8 / 187

    What is meant by map?
    Answer:

    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.

    Please Login First :

    9 / 187

    What is a multimap?
    Answer:

    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.

    Please Login First :

    10 / 187

    How is an iteration over a map is carried out?
    Answer:

    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
    Void f(map& phone_book) {
    Typedef map(string, number)::const_iteration CI;
    For(CI =phone_book.begin( ); p!=phone_book.end( );++p)
    cout<first<<’\t’<second<<’\n’;
    }
    A map iterator presents the elements in ascending order of its keys.

    Please Login First :