41 Lecture
CS304
Midterm & Final Term Short Notes
STANDARD TEMPLATE LIBRARY
The Standard Template Library (STL) is a library of generic algorithms, data structures, and iterators that are part of the C++ standard library. It provides a set of reusable and interchangeable components that can be used to implement complex
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is the purpose of the Standard Template Library (STL) in C++? a) To provide a library of generic algorithms, data structures, and iterators b) To provide a library of graphics functions c) To provide a library of mathematical functions d) To provide a library of input/output functions Answer: a Which of the following is a container class in STL? a) Vector b) Set c) List d) All of the above Answer: d Which of the following is not a type of iterator in STL? a) Forward iterator b) Reverse iterator c) Bidirectional iterator d) Parallel iterator Answer: d What is the complexity of finding an element in a set in STL? a) O(1) b) O(log n) c) O(n) d) O(n^2) Answer: b Which algorithm in STL is used to sort a range of elements in ascending order? a) sort b) reverse c) merge d) unique Answer: a Which container class in STL stores unique elements in sorted order? a) Vector b) Map c) Set d) Queue Answer: c What is the difference between a stack and a queue in STL? a) A stack is a LIFO structure, while a queue is a FIFO structure. b) A stack is a FIFO structure, while a queue is a LIFO structure. c) Both are LIFO structures. d) Both are FIFO structures. Answer: a Which algorithm in STL is used to copy a range of elements from one container to another? a) find b) copy c) sort d) replace Answer: b Which of the following is not a header file in STL? a) <vector> b) <set> c) <list> d) <iostream> Answer: d Which container class in STL is used to implement a priority queue? a) Map b) Queue c) Stack d) Heap Answer: d
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is the Standard Template Library (STL) in C++? Answer: The Standard Template Library is a library of generic algorithms, data structures, and iterators that are part of the C++ standard library. What is an iterator in STL? Answer: An iterator is a type of object that points to an element in a container in STL and allows us to access and modify its value. What are the advantages of using STL in C++ programming? Answer: The advantages of using STL in C++ programming are that it provides a set of reusable and interchangeable components, reduces development time, improves code quality, and makes the code more maintainable. What is a container in STL? Answer: A container is a class that stores and manages a collection of objects in STL, such as vectors, lists, sets, and maps. What is the difference between a vector and a list in STL? Answer: A vector is a sequence container that stores objects in contiguous memory, while a list is a doubly linked list container that stores objects in non-contiguous memory. What is an algorithm in STL? Answer: An algorithm is a set of operations that can be performed on a range of elements in a container in STL, such as sorting, searching, and copying. What is a template in STL? Answer: A template is a C++ feature that allows us to write generic code that works with different data types, and it is used extensively in STL to provide a generic framework for algorithms and containers. What is the difference between a stack and a queue in STL? Answer: A stack is a container that provides LIFO (last-in-first-out) access to elements, while a queue is a container that provides FIFO (first-in-first-out) access to elements. What is the complexity of finding an element in a map in STL? Answer: The complexity of finding an element in a map in STL is O(log n), where n is the number of elements in the map. What is the difference between a set and a multiset in STL? Answer: A set is a container that stores unique elements in sorted order, while a multiset is a container that stores multiple copies of the same element in sorted order.