Stack using Queue | C++ Placement Course | Lecture 24.4

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Purane concept hil gaye sare is video se

StoryGicRohit
Автор

jisko bhi is question mai dikkat aa rahi hai ek chiiz note karna
animation galat daal rakhi hai bhaiya ne
jab q1 mai se q2 mai push karenge to rear se inserrt hona chaiye jisse ki is example mai last me swap karne ke baad elements 4 3 2 1 aaenge
aur jab pop operation lahaenge to front se niklenge
hence stack is implemented
code sahi likha hai but animation mai mistake kari hai

yashagarwal
Автор

From queues, elements are removed from front not back. Pls correct it

emad
Автор

q. front(), this is where the problem began.. Front points to first element in queue, but here it points to last element..

mrinnervoice
Автор

//Talking about first method(push operation costly). When you pop elements from q1 then 4 is popped first whereas according to FIFO order, 1 should be popped first since you are adding first element as "1".

ojasahirrao
Автор

*SOURCE CODE* (As notes are not there)

#include <bits/stdc++.h>
using namespace std;
class Stack
{
public:
queue<int> q1;
queue<int> q2;
int N;
Stack()
{
N = 0;
}
void push(int value)
{
q2.push(value);
N++;
while (!q1.empty())
{
q2.push(q1.front());
q1.pop();

}
queue<int>temp=q1;
q1=q2;
q2=temp;
}
void pop()
{
q1.pop();
N--;
}
int top()
{
return q1.front();
}
int size()
{
return N;
}


};

int main()
{
Stack q;
q.push(1);
q.push(2);
q.push(3);
q.push(4);
cout<<q.top()<<endl;


return 0;
}

sleepypanda
Автор

Please increase the frequency. Or at-least start the competitive programming part parallel to this one 🙏🏻.

mananshah
Автор

How in queue (q1.front()) is removing last value from q1
As in queue we use FIFO so according to it front value will be pushed in q2, it must not be last value of q1.

harshitadurgapal
Автор

just think q1 and q2 have entrance at left side and end at right side
q2 will be the final stack (imagine rotating the q2 to 90 ' by right side)

ani
Автор

There's no condition applied on top.
What if the stack is empty.


// Code Snippet;
int top(){
if(!q1.empty()) return q1.front();
return -1;
};

aiknowledge-ns
Автор

Sir Please tell, which book to follow.... Along side these lectures to get the maximum benefit?

shubhamprajapati
Автор

kon kon pareshan hogya itne late videos se

PiroCoder
Автор

bro 7 ki jagha 14 min ki video kr lete, kam se kam achhe se to smjh aata..aap ek baari mein saara smjha dete ho

mohdhumaid
Автор

Code toh shi hai but explain galat kiya hai q1.front() ko q2 k back mai push krenge ek baar Queue ki introduction video dekh lo or ise dry run kro samajh aa jaega

Amaterasu_Itachi
Автор

In previous video you tell insertion from back and deletion from front

shriganeshgaming
Автор

this course is definitely not for a beginner . All part of STL is not taught and you are using it frequently.
You are very fast and and not explaining few important points properly .
Till the point which I have studied from somewhere else I could able to understand but as the new topics are coming there are lots of doubts .
please sir and maam please go through these videos and analyse it as it is creating doubts and consuming much more times to understand a topic from multiple places.

aswinikumar
Автор

Bhaiya please upload all notes of c++ course as many lectures has not notes in description🙏🙏

RahulKumar-xenj
Автор

Please upload the remaining notes of physics 🙏

ishangaurav
Автор

Please upload the remaining notes of physics part 2

keepgrowingup
Автор

1:15 Queue hai toh last mai se nhi 1st mai se elements niklega na

sachinbairi
join shbcf.ru