Please explain these questions.Except first ques,i m unable to solve them

Please explain these questions.Except first ques,i m unable to solve them

hi @KetanPandey please share the questions. If you are having trouble solving a lot of questions you should consider rewatching the relevant videos or reading the documentation for those topics.
Anyway, please share the questions you are having trouble with and I’ll try my best to explain them to you.

please explain 2,3,5,8,9,10.i have watched videos again but not getting perfect method to solve them

@KetanPandey please share the questions, not just the question numbers.

Q2. vector STL#2 Read the following code and predict the output of s4. .capacity() is a function that tells the current size of underlying array storage being used by the vector. s1. vector < int > v = {1, 3, 2, 5} s2. cout << v.capacity() << endl; // this prints 4. s3. v.push_back(12); s4. cout << v.capacity() << endl; // predict this

Predict the time complexity of the following recursive function, given the vector is of size N and the initial call is calSum(v, 0). int sum = 0; void calcSum(vector v, int i) { if(i == v.size()) return; sum += v[i]; calcSum(v, i+1); }

The statement vector< vector< int > > matrix(100, vector < int > (50, 100) ) declares :

Which of the following can be used to store a simple undirected graph with N nodes? vector < int > graph [ N + 1 ] bool graph [ N + 1 ][ N + 1 ] vector < vector < int > > graph(N+1) All of them. Prev

Let us build a stack data structure with the help of inbuilt vector class. class myStack { vector < int > stack; public: int top(); void pop(); void push(int x); } Imagine the vector as a stack. The element at last position of the vector will be treated as top of the stack and element at stack[0] will be treated as the bottom of the stack. Choose the correct option : top() and pop() can be implemented to work in O(1) time complexity. top() and push() can be implemented to work in O(1) time complexity. either pop() or push() will work in O(N) and the other will work in O(1). All functions can be implemented to work in O(1) time complexity.

I remember this being covered in a video. When you perform the push_back() operation, the size of the vector doubles to accomodate the extra element. SO evn though the size of vector is 5, after this, the capacity becomes 8.

@KetanPandey for the rest of the questions, you need to be familiar with the concepts of recursion, 2D vectors, graphs, stacks etc, please study those topics first and then come back to this.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.