is video ko dekh kar meri aakhe bhar aayi 😢.... I was waiting for this lecture and also very excited.. Your Teaching style is very very good... Now, I am addicted to Your lecture.. Very very thank you sir,..❤❤❤ Sir, I downloaded your lecture then watch it.. because it save my internet..
54:36 time complexity in this case will be O(n + n + 1) = O(2n+1) ~ O(n) printing will be constant time as we are counting the iteration of the while loop ie. n times inside that printing the element will be constant time , overall complexity is correct but the explanation for printing the elements is incorrect so this is for the people who are confused but the rest explanation is so good : ) really enjoying every bit of it thanks for this amazing free course
best lecture learned a lot and thank you pw team for providing us with this excellent tutorials which are way better than the paid courses and best among all you tubers
respected sir , i came to your for the first time i thought i am clear with the topic recursion and doing stack with you here . bt sir you clerified my all little doubt very clearly so....thankyou so much sirr thanks alot
1:25:35 remove from bottom / any index solution Stack stack = new Stack(); Stack stack2 = new Stack(); stack.push(20); stack.push(40); stack.push(60); // index - 2 stack.push(80); stack.push(100); // total size = 5 (5-2 = 3) 3-> index 2 (element to be removed) int index = 2; while(stack.size()-1>index){ // for 0 based indexing stack2.push(stack.pop()); } stack.pop(); // removing the element at given index while(stack2.size()>0){ stack.push(stack2.pop()); } System.out.println("the size of the stack is :" + stack.size()); System.out.println(stack);
1:08:09 after getting the clue i have implemented the recursive algo , we can print in reverse order using this given code : ) static void printTheStack(Stack stack){ if(stack.isEmpty()) return; int topElement = stack.pop(); System.out.print(topElement + " "); printTheStack(stack); }
1:37:34 the clue really helped a lot to figure out the algo : ) static void pushAtBottom(Stack stack , int element){ if(stack.isEmpty()) { stack.push(element); return; } int topElement = stack.pop(); pushAtBottom(stack, element); stack.push(topElement); }
1:52:42 my array implementation using constructor to take the size of the array : ) class Stack { private int size; private int index = 0; private int[] arr; Stack(int size) { this.size = size; arr = new int[this.size]; } void push(int x) { if (isFull()) { System.out.println("Stack is full!"); return; } arr[index] = x; // adding element index++; // increasing the value of index } int pop() { if (isEmpty()) { System.out.println("Stack is empty!"); return -1; } int topElement = arr[index - 1]; // storing top element arr[index - 1] = 0; // setting the top element to 0 as we are removing (default value) index--; // decreasing index as one element is removed return topElement; } void display() { for (int i = 0; i
51:03 explanation why we do not get the error : Stack stack = new Stack(); Stack stack2 = new Stack(); // adding elements in stack - 1 stack.push(20); stack.push(40); stack.push(60); stack.push(80); stack.push(100); System.out.println(stack); // adding the given element at the given index in stack - 1 int index = 6; int add = 30; // when the index > size of the stack loop do not execute (here the size of stack 1 - is 4 (0 based indexing) // reason : condition becomes false & the element is added at the top in stack -1 while(stack.size()>index){ stack2.push(stack.pop()); } stack.push(add); // element is directly added in the stack -1 at the top while(stack2.size()>0){ // this will not execute in this case we do not need the stack -2 and also the size is 0 so condition is false stack.push(stack2.pop()); } System.out.println(stack);
PW Skills Instagram-: instagram.com/pw.skills/
PW CollegeWallah Instagram-: instagram.com/pwcollegewallah/
PW Skills Twitter - twitter.com/pw__skills
PW Facebook Page-: facebook.com/officialpwskills
PW Linkedin Page-: www.linkedin.com/company/ineuron-ai/
One of the finest videos on stack. It explains everything in detail.
I watched whole lecture in 2X and at no point I paused or rewind , great and crystal clear teaching!!!
Bhai ab is playlist ke tree wagera ke video kidhar hai
@@devanshpal944 eveyone is focusing on paid course... I think treee, dp wagera k lia paid course lena padega
other topics are on Pw website for free
@@vcIND18 bhai link share krna mujhe nhi mil rha free wla
is video ko dekh kar meri aakhe bhar aayi 😢....
I was waiting for this lecture and also very excited..
Your Teaching style is very very good...
Now, I am addicted to Your lecture..
Very very thank you sir,..❤❤❤
Sir, I downloaded your lecture then watch it.. because it save my internet..
I'm a student of scaler achadamy but this contents is better then my paid course
Yeah it's true brother, the videos were very helpful 🤠
why did you take the paid course on the first place ?
same brother bhai stack ka concept toh upar se gaya mera
But But I saw on TH-cam that scaler provide osm level of features for students
Yes bro❤❤
Sir, Your way of teaching is amazing 😍.
THANK YOU SIR for your efforts
Bhai main sach bol raha hu ....this course is 100% better then paid course......i compared it..❤❤❤
2:35:52
Linked List implementation of stack
size-- should be there in pop();
1:20:30
push at bottom question solution : )
static void pushAtBottom(Stack stack , int element){
if(stack.isEmpty()){
stack.push(element);
return;
}
int topElement = stack.pop();
pushAtBottom(stack, element);
stack.push(topElement);
}
2:40:43
Sir size-- in pop function,
After pop your out put came 3, before the size was 3
54:36
time complexity in this case will be O(n + n + 1) = O(2n+1) ~ O(n)
printing will be constant time as we are counting the iteration of the while loop ie. n times inside that printing the element will be constant time ,
overall complexity is correct but the explanation for printing the elements is incorrect
so this is for the people who are confused
but the rest explanation is so good : )
really enjoying every bit of it
thanks for this amazing free course
no one can teach better than raghav garg sir his teaching style always help me in learning thingss thankyou soo much raghav sir😇
best lecture learned a lot and thank you pw team for providing us with this excellent tutorials which are way better than the paid courses and best among all you tubers
MAZA AA GAYA ❤🔥
respected sir , i came to your for the first time i thought i am clear with the topic recursion and doing stack with you here . bt sir you clerified my all little doubt very clearly so....thankyou so much sirr thanks alot
Maza aaya sir.. kitna accha smjhte ho sir... Ek hi baar sb smjh gya.. thanku 😊
You made my super interest on DSA
From Btech till having 2.5 years of experince, I hate dsa
Mza aa gya...........
1:25:35
remove from bottom / any index solution
Stack stack = new Stack();
Stack stack2 = new Stack();
stack.push(20);
stack.push(40);
stack.push(60); // index - 2
stack.push(80);
stack.push(100); // total size = 5 (5-2 = 3) 3-> index 2 (element to be removed)
int index = 2;
while(stack.size()-1>index){ // for 0 based indexing
stack2.push(stack.pop());
}
stack.pop(); // removing the element at given index
while(stack2.size()>0){
stack.push(stack2.pop());
}
System.out.println("the size of the stack is :" + stack.size());
System.out.println(stack);
U teach with complete excellence 🎉❤
you are my favourite teacher
Maza aagya ❤
Thank you sir😊❤🎉
maja aagya raghav sir
Awesome explanation of stacks ❤❤
Best lecture on Stack on TH-cam+ paid courses combined!
mazza agayaa sir❤❤👌
Finally wait is over, hats off to you sir !!
Apse padkar Maza aa jata hai sir❤❤❤
Maza aa gya :)
Maza aa gaya sir🥳🥳🥳🥳🥳🥳
You Rock Sir
better than paid course
maazaa aa gya Sir..🤩😍😍😍
Maza ageya ❤🔥
MAZZAA AA GYA '😀😀🔥🔥🔥🔥🔥🔥🔥
Nice video sir Thank you😊😊
thnk you sir maja aagya
aapse pdhke kabhi bhi main bore nhi hota hu
bas please aap yha baki ka topic complete krwa digiye please
best video to watch for stack
kya bawal chiz bnaya re 🥰🥰🥰
wow. Amazing. Thank you so much sir !!
maja agay sirji ,it will help for placements
Mazza Aagaya
Nice lecture...completed it today
Thank you Sir
EXcellent Teaching skills
sir aap bhut accha padhate hein thanks
Maja aa gaya -- Thank you Sir 🙂
Sir your way of teaching ❤🥰
Have you watched all DSA lecture
Thank you so much sir for your support ❤❤
Such a great explanation sir hats off
1:08:09
after getting the clue i have implemented the recursive algo , we can print in reverse order using this given code : )
static void printTheStack(Stack stack){
if(stack.isEmpty()) return;
int topElement = stack.pop();
System.out.print(topElement + " ");
printTheStack(stack);
}
Bro I want to ask many questions can you please share your insta I'd or something else
As follows maja aagya
bole to jhakasss!
mza aa gya sir..
Recursion ki Duniya manvi mam ne clear kar diya hai ❤
Have you watched all DSA lecture
@@CTrickC Almost
Maza aa Gaya ❤❤
1:37:34
the clue really helped a lot to figure out the algo : )
static void pushAtBottom(Stack stack , int element){
if(stack.isEmpty()) {
stack.push(element);
return;
}
int topElement = stack.pop();
pushAtBottom(stack, element);
stack.push(topElement);
}
static void reverseTheStack(Stack stack){
if(stack.size()==1) return;
int topElement = stack.pop();
reverseTheStack(stack);
pushAtBottom(stack, topElement);
}
Sir aap great ho
great lecture and explanation
1:52:42
my array implementation using constructor to take the size of the array : )
class Stack {
private int size;
private int index = 0;
private int[] arr;
Stack(int size) {
this.size = size;
arr = new int[this.size];
}
void push(int x) {
if (isFull()) {
System.out.println("Stack is full!");
return;
}
arr[index] = x; // adding element
index++; // increasing the value of index
}
int pop() {
if (isEmpty()) {
System.out.println("Stack is empty!");
return -1;
}
int topElement = arr[index - 1]; // storing top element
arr[index - 1] = 0; // setting the top element to 0 as we are removing (default value)
index--; // decreasing index as one element is removed
return topElement;
}
void display() {
for (int i = 0; i
Good lecture for Beginners
maaza aa gaya
maja aa gya.....👍
02:08:00
ARRAY IMPLEMENTATION
Maza Aagaya sir!!
maja aagya thank you so much sir
Mazaa aa gaya sir
sir why we are using that pushAtbottom function does while we can use only one st.pus(x)? is there any reason or it is just an standard format?
Add the video in Java and dsa playlist
Maja aagya💓
Bohot maja aaya sir..
Best Explanation
51:03 explanation why we do not get the error :
Stack stack = new Stack();
Stack stack2 = new Stack();
// adding elements in stack - 1
stack.push(20);
stack.push(40);
stack.push(60);
stack.push(80);
stack.push(100);
System.out.println(stack);
// adding the given element at the given index in stack - 1
int index = 6;
int add = 30;
// when the index > size of the stack loop do not execute (here the size of stack 1 - is 4 (0 based indexing)
// reason : condition becomes false & the element is added at the top in stack -1
while(stack.size()>index){
stack2.push(stack.pop());
}
stack.push(add); // element is directly added in the stack -1 at the top
while(stack2.size()>0){ // this will not execute in this case we do not need the stack -2 and also the size is 0 so condition is false
stack.push(stack2.pop());
}
System.out.println(stack);
Nice video sir ji
Mzaa agya
maza agaya..🥰🤞
great explanation👍👍👍
// reverse stack recursively
import java.util.Stack;
public class reverseStack {
public static void revStack(Stack st){
if(!st.isEmpty()){
int top = st.pop();
revStack(st);
insertAtBottom(st,top);
}
}
public static void insertAtBottom(Stackst,int top){
if(st.isEmpty()){
st.push(top);
return;
}
int x = st.pop();
insertAtBottom(st,top);
st.push(x);
}
// main method
public static void main(String[] args) {
Stack st = new Stack();
st.push(1);
st.push(2);
st.push(3);
st.push(4);
st.push(5);
System.out.println(st);
revStack(st);
System.out.println(st);
}
}
Maza aa Gaya sir ji
mza aa gya..
Maza aa gaya ----->
Maza aa gaya!!!!!!
Mazza aa gya..
Also better than Coding Ninja which is costly
Maja Aa Gaya, Radha Radha 🌺
Maja Aa Gaya
Mjja a gya😊
Maza aa gaya
❤☺️sir u r amazing
Maza aa Gaya ........
Mzaaa aa gya sir
Maza aagaya
Awesome teacher
2:51:21 maza aa gya 🔥🔥🔥
Mja aa gya sir sach mey
mazaa aa gya
Maja aagaya sir 😊
Thankue sir ❤
Maza agya
Maza aagya
Maja aa gaya Sir
maja aa gaya bhaiya