Abhi bhi bahut logo ne playlist access kyu nahi kari hai DSA ki? - th-cam.com/play/PLu0W_9lII9ahIappRPN0MCAgtOu3lQjQi.html Instagram: instagram.com/codewithharry
Really you are a good teacher , i starrted the course just from the starting of the month of November and today I think that I am some suitable with the dsa problems and making others understand the concept of dsa topics, Thank you harry bhai, love you ...
To anyone getting confused with pop function, we can do the whole stuff without making it complex, just write the simple pop function and update top in main function. CODE given below: struct node* pop(struct node* top) { if(isempty(top)) { printf("Stack Underflow, Can't pop anthing out "); } else { struct node* helper = top; top = top->next; printf("Popped %d Successfully. ",helper->data); free(helper); return top; } } // in the main function to pop anything just update the top like below int main() { // Whatever prev code is written here // for popping an element just update top. top = pop(top); return 0; }
Harry is one guy who only wants his viewers to learn without expecting anything in return. Unlike these other TH-camrs who teach half the thing and force us into buying their paid courses. I wouldn't hesitate to give something to Harry once I start earning. I love you Harry bhai❤️
I was zero when I started watching c language in april 2023. Today, I feel confident in using c,c++ and data strucrures.Thanks harry bhai. Today is 26 June 2023.
24:00, pop() can be implemented in the following way too. struct Node* pop(struct Node *top) { if (!isEmpty(top)) { struct Node *ptr = top; top = top->next; int val = ptr->data; printf("Popped element is %d ", val); free(ptr); } else printf("Stack Underflow "); return top; }
struct node * pop (struct node * top){ struct node *n = top ; top = top->nextpointer; int data_of_popped = n->data; free(n); printf(" the data popped out : %d ", data_of_popped); return top; }; use this for pop . bhaiya kyu top ko global variable banana hai top ko change krke app return bhi kr skte ho
pop function can also be implemented like this /* struct Node * pop(struct Node * top) { struct Node *ptr; if (is_empty(top) ) { printf("stack underflow"); } else { ptr = top; top = top->next; int x = ptr->data; printf("deleted/popped element is %d ", x); free(ptr); return top; } } */ here the only diffference is data type of pop function that is [ struct Node * ] type almost similar like deletion of first node in linkedlist explained in video no. 18
25:00 jinko problem ho rahi hai isme. Ye sab complicated way use karne ko zaroorat nahi hai. Bass pop function me print karwado ki tumne ye value popped ki hai by using x. Aur int main me bass top = pop(top); Karo and pop function lo struct Node * type ka banao And return me top kardo pop function me Sab easy and simple ho jayega no tention 💯
In isFull() function, we need to free(p) when we are returning 0. Otherwise we will get an error when we do not have enough memory because we have already used that to assign p inside isFull() function.
Yeah or else we can make isFull() to return struct Node pointer ,and check in push if(isFull()==null ) then stack overflow Or else use that allocated memory as n in push, Right? This way memory will not be wasted
me to bol raha hoon isFull and isEmpty function alag se banake ka hi jarurat nehi h.... tum push and pop function k under hi wo sab cheez kar sakte ho bina koi function ko call kare
Bhai is video me harry ne jo isFull() function likha hai. samajh nai aya. can you explain me what's he doing? he is just creating a node using dynamic memory allocation and just checking if it's null or not. is this like indefinite stack which keeps on getting values till it runs out of memory?
@@uraniumgaming123 he wants his stack to grow on till he has memory in his stack(kinda inifinite - but has some max definite memory in pc)...so he implements a struct node pointer and allocated its memory and if the total space is filled , then he says stack overflow.....this is what i think
The code you wrote I also applied it in the program, but the issue with it is that it just returns you the value of the top for the first time, but doesn't update the top variable in the main function. Since, it doesn't traverse the data after that.
@@knowtechwithaman7254 no, it updates the top pointer in the main(), I have tried this code with multiple variations, and it works perfectly in each and every case
at 25 minutes video; while in pop function u can return top instead of element so we dont have to send address of top in the function and poped element can pe printed inside pop function only before element is poped; struct node* pop(struct node* top) { if(isempty(top)) { printf("stack underflow");
Hello, Harry bhaiya first of all thanks a lot for doing this much that too free of cost.Hope you doing well.I have a doubt here can you please sort it out------ What's the need of creating of is full() bcoz we are already checking it in our push function whether our stack is full or not.
We can also implement pop() like this: struct Node *pop(struct Node *top){ if (isEmpty(top)) { printf("Stack Underflow!! Can't pop "); } else { struct Node *p = top; int x = top->data; top = top->next; free(p); return top; } } In int main(): top = pop(top); traversal(top);
then, we can do like this : int pop(struct Node **top){ if (isEmpty(*top)) { printf("Stack Underflow!! Can't pop "); } else { struct Node *p = *top; int x = (*top)->data; *top = (*top)->next; free(p); return x; } } In int main(): printf("The poped element is %d ", pop(&top)); traversal(top);
because memory allocated tab karte hai jab hume node create karna hota hai..... struct node *n (yaha n ek normal variable hai). struct node *n =(struct node*)malloc(sizeof(struct node*)-----(yaha n ek node bann gya hai....ab "n" ke two components hoge n->data OR n->next.
I think this method is more easy and efficient...You dont have to return each node's address after pushing data .................. #include #include #include using namespace std; struct node { int data; node * ptr; }; bool isFull(){ node * s = new node; if (s == nullptr) { return true; } delete(s); return false; } bool isEmpty(node * top){ if (top == nullptr) { return true; } else{ return false; } } void push(node ** top , int data){ if (isFull()) { cout
passing top in the push ...and saying top = n ; then why we need to return top for updating . why it is not getting updated by top = n in push function although we are using the call by reference .
sir last me apne bola local variable top or global variable top aps me coincide kr rheh . to vo sirf pop wale function me hi use hoga ki push wale me bhi ho skta h .
Harry bhai m tkinter me button pe command me ek function de rha hu file ko write krane ke liye ye example aapne bhi diya tha par aapke program me side by side file write ho rhi thi par mere me m jab GUI window band kr deta hu uske baad file banti h aur write hoti h
bro stack using linked list mein address of pointer paas krne ki zarurat q pad rhi hai array implementation mein to direct pointer pass ho jaata tha output bhi correct aata tha.
void Push(struct Stack *head, int value) { if (isFull(head)) { printf("Stack overflow"); } else { struct Stack *ptr = (struct Stack *)malloc(sizeof(struct Stack)); ptr->next = head; head = ptr; } } why this not working?is that so i have return type void?but since i am changing head to ptr at last which should retain its change even after scope is destroyed as it is pointer ,so it should be fine if i don't return head?
Abhi bhi bahut logo ne playlist access kyu nahi kari hai DSA ki? - th-cam.com/play/PLu0W_9lII9ahIappRPN0MCAgtOu3lQjQi.html
Instagram: instagram.com/codewithharry
First
@sanghamitra dass I also want that bcz I want to become a ethical hacker
Thank you so much Harry Bhai... Please make a series on ANGULAR
Java Course launch kro please
@codewithharry Bhai 4:51 pr else block me n ko free krna hoga.
Quality Ka naam hai Harry Bhai❤️🔥
i m new your channel , and bs aate hi fan bn gya
Me ye video esliye like kar rha hu kyuki aapne pura afford lga diya samjane me, Thank you Bhai❤❤
Really you are a good teacher , i starrted the course just from the starting of the month of November and today I think that I am some suitable with the dsa problems and making others understand the concept of dsa topics, Thank you harry bhai, love you ...
To anyone getting confused with pop function,
we can do the whole stuff without making it complex,
just write the simple pop function and update top in main function.
CODE given below:
struct node* pop(struct node* top)
{
if(isempty(top))
{
printf("Stack Underflow, Can't pop anthing out
");
}
else
{
struct node* helper = top;
top = top->next;
printf("Popped %d Successfully.
",helper->data);
free(helper);
return top;
}
}
// in the main function to pop anything just update the top like below
int main()
{
// Whatever prev code is written here
// for popping an element just update top.
top = pop(top);
return 0;
}
this playlist is very helpful
Java Course launch kre... Harry
@@ViralXtreme one note notes where it is uploade anyone have idea regarding brother?
Harry is one guy who only wants his viewers to learn without expecting anything in return. Unlike these other TH-camrs who teach half the thing and force us into buying their paid courses. I wouldn't hesitate to give something to Harry once I start earning. I love you Harry bhai❤️
Harry Bhai me aapki python series sikh raha hu or apne mere bahut pqise bachaye hai.......thank you bhaiiiiii very much........
Kitna sikha ?
@@vikramjha7450 Bhai abhi mene 2nd exersice means faulty calculator tak sikha hai.......
bhai kaisa hai python ka course? abhi tak toh job bhi mil gyi hogi na
@@bhaumik250 💀
Best ds algo course ❤ one request plz continue this series and don't stop regular videos🙏🙏🙏
Harry Bhai Your The God For Coders🧑💻
So we coded a linked list and called it a stack .
Yeah bacislly😂😂
We alse made an array named it stack🙂
Hence,Stack is an ADT
2 years old course but this is the best explanation present anywhere else on yt
I was zero when I started watching c language in april 2023. Today, I feel confident in using c,c++ and data strucrures.Thanks harry bhai. Today is 26 June 2023.
int peek(stack* s,int idx){
Node* p = s->top;
int len =1;
while(p->next){
p = p->next;
len++;
}
p = s->top;
int i=1;
while(inext;
i++;
}
cout
24:00, pop() can be implemented in the following way too.
struct Node* pop(struct Node *top)
{
if (!isEmpty(top))
{
struct Node *ptr = top;
top = top->next;
int val = ptr->data;
printf("Popped element is %d
", val);
free(ptr);
}
else
printf("Stack Underflow
");
return top;
}
Absolutely, ptr ko free krlo bs
@@avinashdharme2234 haan ptr ko free Krna tha.
@@rickk3300 yes
Bro I think return top will be written in if part not in else part, please kindly check
@@Freshtech4428 return top is neither in the if part nor in the else part. If Stack Overflow happens, top will just get returned without any changes.
struct node * pop (struct node * top){
struct node *n = top ;
top = top->nextpointer;
int data_of_popped = n->data;
free(n);
printf(" the data popped out : %d
", data_of_popped);
return top;
};
use this for pop . bhaiya kyu top ko global variable banana hai top ko change krke app return bhi kr skte ho
@Relaxing hours bro.. in my computer, it is working perfectly. This code fragment is the perfect alternative to Harry bhai's code.
@Mayank :)
Use this in main function
int main()
{
top=push(top);
LinkedlistTraversal(top);
}
@Mayank :) Bro, use the above function as it is and,
In main(), write this:
top = pop(top);
printf("Updated stack is: ");
linkedListTraversal(top);
perfect alternative of using ampersnet and "*" everywhere
I did same
Waoh Harry bhai !! 1000 videos complete🔥🔥🔥
Easily samajh me aa raha hai stack using linked list jaisa topic bhi.... Very helpful videos Sir 👍
Hats off ,your way of teaching is amazing ,and implementing it in code is a good way of understanding really appreciate your hard work
isEmpty() aur isFull() method me return 1 kyu kiya hai??
You did not teach any concept of global and local variable in 15 hr video but i got this concept from this video thnx for your support 🥰
😄😄😁
that was what i was wondering too coz i didnt remember that part being taught in the 15 hr lecture.
pop function can also be implemented like this
/*
struct Node * pop(struct Node * top)
{
struct Node *ptr;
if (is_empty(top) )
{
printf("stack underflow");
}
else
{
ptr = top;
top = top->next;
int x = ptr->data;
printf("deleted/popped element is %d
", x);
free(ptr);
return top;
}
}
*/
here the only diffference is data type of pop function that is [ struct Node * ] type
almost similar like deletion of first node in linkedlist explained in video no. 18
Thankyou so much buddy
Great Help
That is the same thing I Implemented in my code..Same pinch!!
bhaiya aur jyaada jyaada videos daalo, bhot maza aa raha and cant wait to get into Compi coding
your teaching style is very crystal clear
muth pe le harry bhai ki sab kuchh aa jayega teko
@@dhruvarora5755 psycho hai kya? Kya baat Kara rahai hai?
apni ma se smajh le uske aata hoga
usen bhi harry ka muth peeya tha@@biswajitadhikary_0807
Bhai great teacher..maine aapki sabhi playlist lagbhag dekh li hai..bhut knowledge mila..thanku
great help bro to clear all concept that how to implement
hi harry sir mene apki python tutorial dekha and muje jod mili thank you sir
please continue the course harry bhai . app advanced data structure per bhi vedios laiye . or graph per bhi and i must say the video is awesome
25:00 jinko problem ho rahi hai isme. Ye sab complicated way use karne ko zaroorat nahi hai. Bass pop function me print karwado ki tumne ye value popped ki hai by using x.
Aur int main me bass top = pop(top);
Karo and pop function lo struct Node * type ka banao
And return me top kardo pop function me
Sab easy and simple ho jayega no tention 💯
28:29 koi doubt ni hai global and local variable mai apne c ke playlist mai bahut acche se samjha ya tha
In isFull() function, we need to free(p) when we are returning 0. Otherwise we will get an error when we do not have enough memory because we have already used that to assign p inside isFull() function.
Yeah or else we can make isFull() to return struct Node pointer ,and check in push if(isFull()==null ) then stack overflow Or else use that allocated memory as n in push, Right? This way memory will not be wasted
@@Im_RajSingh Yes
thanks . Learnt something new
me to bol raha hoon isFull and isEmpty function alag se banake ka hi jarurat nehi h.... tum push and pop function k under hi wo sab cheez kar sakte ho bina koi function ko call kare
Thanks I was thinking same
Thank you harry bhai for such awesome course 🙏🙏🙏
These playlist is best ❤️🤗.
My online classes are worst.
25:20 you can just simply change your function header to => int pop(Node* &top)
This works for C++. Not sure about C.
Bhai is video me harry ne jo isFull() function likha hai. samajh nai aya.
can you explain me what's he doing?
he is just creating a node using dynamic memory allocation and just checking if it's null or not.
is this like indefinite stack which keeps on getting values till it runs out of memory?
@@uraniumgaming123 he wants his stack to grow on till he has memory in his stack(kinda inifinite - but has some max definite memory in pc)...so he implements a struct node pointer and allocated its memory and if the total space is filled , then he says stack overflow.....this is what i think
@@Pranauv i understood it after giving it some time.
still..
Thanks a lot for Taking time and explaining me this.
🙂
It can be done only in C++
Thank You Sir ! Your Efforts Are Really Appreciated !!
harry bhai your tutorial is best.
Sir you are just GOAT
tere ko goat fetish haina?
thanks Harry
happy Guru pournima
Thanku so sir ❤ God bless you
another implementation of pop:-
struct node* pop(struct node *top){
struct node *n=top;
top=top->next;
free(n);
return top;
}
int main(){
top=pop(top);
}
The code you wrote I also applied it in the program, but the issue with it is that it just returns you the value of the top for the first time, but doesn't update the top variable in the main function. Since, it doesn't traverse the data after that.
That is we need to make it global variable any way to update the top for the whole.
@@knowtechwithaman7254 no, it updates the top pointer in the main(), I have tried this code with multiple variations, and it works perfectly in each and every case
i did same and works
Thank you Sir 😊
int pop(struct node * top){
if (isEmpty(top))
{
printf("Stack underflow");
}
else
{
struct node * n =top;
top=top->next;
int result=n->data;
free(n);
return result;
}
}
Thanku sir ..bhaut acche se aaya smjh....Thanks alot sir
I learnt soo much from you I subscriped from 3 different accounts
20:10
isFull( ) me argument "top" pass kyu kar rhe h ??
jabki wo function "top" ka use bhi nhi kar rha 🤔🤔
Agar Full() me top pass nhi bhi kiya to bhi koi problem nhi ayegi...
waise bhi isFull() negligible he smjho, kyuki linked list mai itna size matter nahi karta whereas in array pe karta hai.
Thanks brother for this quality contant
BHAI TUSSI GREAT HO........
Good video......bas last last me thoda confuse kar diya,😅😅👍
JIO RE BHAUBALLI.....OP RE HARRY BALLI😁😁
Maza aagaya Harry Bhai💖💖💖💖
❤ Thank you
Harry Bhai ❤❤❤
Really you are great I. I. Tian kharagpur.
at 25 minutes video;
while in pop function u can return top instead of element so we dont have to send address of top in the function and poped element can pe printed inside pop function only before element is poped;
struct node* pop(struct node* top)
{
if(isempty(top))
{
printf("stack underflow");
}
else
{
struct node* n=top;
printf("the popped elemnt %d ",n->data);
top=top->next;
free(n);
return top;
}
}
Loved this playlist 💘
thank you soooo much for your amazing content. Please keep this up.
to all those who r using next variable ig do not understand the concept of stack .....that's becoz it should be "prev" acc to ur concept sir
Harry bhaiya done with this thank you
11:05 what is need to make n ? Kya sidha top=top->next sidha nahi kar sakte?
Very nice explanation sir
You are osome teacher harry
Hello, Harry bhaiya first of all thanks a lot for doing this much that too free of cost.Hope you doing well.I have a doubt here can you please sort it out------ What's the need of creating of is full() bcoz we are already checking it in our push function whether our stack is full or not.
We can also implement pop() like this:
struct Node *pop(struct Node *top){
if (isEmpty(top))
{
printf("Stack Underflow!! Can't pop
");
}
else
{
struct Node *p = top;
int x = top->data;
top = top->next;
free(p);
return top;
}
}
In int main():
top = pop(top);
traversal(top);
I appreciate you bro... But the goal is to return the popped element .
After, free(p);
printf("Poped element is %d
", x);
But you can't use the popped element 😅
then, we can do like this :
int pop(struct Node **top){
if (isEmpty(*top))
{
printf("Stack Underflow!! Can't pop
");
}
else
{
struct Node *p = *top;
int x = (*top)->data;
*top = (*top)->next;
free(p);
return x;
}
}
In int main():
printf("The poped element is %d
", pop(&top));
traversal(top);
@@dollcyjain2452 OR create int x as global varible.
Amazing Harry bhai
Mine was 1000th like 👍 ❤️
great course
I bought GFG paid course for DSA and compared with this one, I found Harry Bhai rocks.......I regret y I wasted mh fathers money on that course🙂
which is GFG?
@@soumi6720 geeks4geeks
Thanks for the vedio and please make a video on carrer options like gate , other. thanks
quality content ekdum
I'm First This Time
BTW Harry Bhai Java Pe Full Playlist Banaona Plzz
Thankyou so much 🙏
good one, done on 15th may 2021
Why in pop function, we didn't dynamically allocated memory for n? Like
struct Node* n= (struct Node *)malloc (sizeof(struct Node))
because memory allocated tab karte hai jab hume node create karna hota hai.....
struct node *n (yaha n ek normal variable hai).
struct node *n =(struct node*)malloc(sizeof(struct node*)-----(yaha n ek node bann gya hai....ab "n" ke two components hoge n->data OR n->next.
Bro waha ham usko as pointer use kar rahe hai but in push function ham ek node create kar rahe hote hai iss liye.
Fantastic Explanation Harry Bhaiya!!!!
toh muh mein lele iska
simple use use & after * in parameter ====> int pop(nstack *&top)
wow sir you are great
Harry bhai awesome
Sir polynomial addition and multiplication wala program bhi bataiye
Perfect explanation 👍🏻
❣❣thankyou so much
Harry Bhai wbsite pe notes available nahi hai stack implementation se
Thanks Harry Bhaiya
Harry bhai Hashing pe video banao na please linear probing, quadratic probing and chaining.
harry paaji tussi great ho..........
Harry Bhai please make video on Java of 15 to 20 hours just like C language video of 15 hours with projects and notes
Why you passing top in isFull Function Because no any use of top in isFull 20:09
I think this method is more easy and efficient...You dont have to return each node's address after pushing data
..................
#include
#include
#include
using namespace std;
struct node
{
int data;
node * ptr;
};
bool isFull(){
node * s = new node;
if (s == nullptr)
{
return true;
}
delete(s);
return false;
}
bool isEmpty(node * top){
if (top == nullptr)
{
return true;
}
else{
return false;
}
}
void push(node ** top , int data){
if (isFull())
{
cout
Thank you bro for sharing........I am also doing code in c++....
Thank you Harry Bhai...
*Kisko kisko JAVA full course chahiye...*
👇
👇 We want JAVA
👇
Java
@@ViralXtreme yes... Java
@@ViralXtreme JAVA 💝💝
No java
passing top in the push ...and saying top = n ; then why we need to return top for updating . why it is not getting updated by top = n in push function although we are using the call by reference .
sir last me apne bola local variable top or global variable top aps me coincide kr rheh . to vo sirf pop wale function me hi use hoga ki push wale me bhi ho skta h .
better alternative is to return the updated head of type struct node*. Without using global variable.
GREAT JOB
Harry bhai m tkinter me button pe command me ek function de rha hu file ko write krane ke liye ye example aapne bhi diya tha par aapke program me side by side file write ho rhi thi par mere me m jab GUI window band kr deta hu uske baad file banti h aur write hoti h
bro stack using linked list mein address of pointer paas krne ki zarurat q pad rhi hai array implementation mein to direct pointer pass ho jaata tha output bhi correct aata tha.
i got the pointer harry bhi😅😅
23:10 double pointers will be required imo.
int Pop(struct Node **top){
struct Node* temp;
temp = *top;
*top = temp->next;
int val = temp->data;
free(temp);
return val;
}
Yea, can you please explain why we need to do so coz I can't really understand it. Thanks in advance:)
zyada tez ho rha hai bete
Thank you bhai!
Bhaiya I think, the image of the stack which u draw on the right top corner is incorrect, means 7 should be written at last of the stack
void Push(struct Stack *head, int value)
{
if (isFull(head))
{
printf("Stack overflow");
}
else
{
struct Stack *ptr = (struct Stack *)malloc(sizeof(struct Stack));
ptr->next = head;
head = ptr;
}
}
why this not working?is that so i have return type void?but since i am changing head to ptr at last which should retain its change even after scope is destroyed as it is pointer ,so it should be fine if i don't return head?
nice bro u explained well
Did not get why we are getting in error as when I am trying to print it is giving segmentation error.