Questions and Answers
- Which of the following does not support any insertion or deletion?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Because array is not dynamic in nature, So they can’t be manipulated.
- How the list containers are implemented?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
List containers are implemented as doubly-linked lists. Doubly linked lists can store each of the elements they contain in different and unrelated storage locations.
- What is the output of this program?
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
vector<int> Data;
Data.assign (5,50);
vector<int>::iterator iter;
iter=Data.begin()+1;
int Array[] = {1200,20,40};
cout << int (Data.size()) << '\n';
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
In this program, We are finding the size of the vector elements and resizing it.
- What is the output of this program?
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
vector<int> VectorData;
int * ptr;
unsigned int k;
ptr = VectorData.get_allocator().allocate(6);
for (k = 0; k < 6; k++)
VectorData.get_allocator().construct(&ptr[k], k);
for (k = 0; k < 6; k++)
cout << ' ' << ptr[k];
for (k = 0; k < 6; k++)
VectorData.get_allocator().destroy(&ptr[k]);
VectorData.get_allocator().deallocate(ptr, 6);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
In this program, We allocated the values to the vector by using get allocater and then we are destroying it.
- What is the output of this program?
#include <iostream>
#include <deque>
using namespace std;
int main ()
{
unsigned int k;
deque<int> DequeData;
DequeData.push_back (50);
DequeData.push_back (75);
DequeData.push_back (90);
for(deque<int> :: iterator iter = DequeData.begin(); iter != DequeData.end(); ++iter)
{
}
DequeData.clear();
DequeData.push_back (150);
DequeData.push_back (175);
for(deque<int> :: iterator iter = DequeData.begin(); iter != DequeData.end(); ++iter)
cout << ' ' << *iter;
cout << '\n';
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
In this program, We cleared the old values presented in the dequeue with the new values.