The real beauty of the video starts around the 12 minute mark with the parentheses. I couldn't, for the life of me, find a way to work with parentheses, but when he did his excellent job explaining it I was finally able to work it out.
i just wonder , if you wouldn't have made this videos , then i would have been literally ended up just cramming the stack , que ,etc from any local author! but the flow of your explanation is indeed dulcet ! thanx a lot for employing your time to help students like us !
true, but people dont value free things, they will like half this quality if they have to pay a hefty fee for it, and regarding location of subtitles, one can just switch them off if they distract...
these are quite difficult but you made them easier for all of us !! Thanks for such kind effort but I'm still struggling with this algorithm since morning.Somehow my mind is muffed :(
here is the correct code in c++ : /* Infix to postfix conversion in C++ Input Postfix expression must be in a desired format. Operands and operator, both must be single character. Only '+' , '-' , '*', '/' and '$' (for exponentiation) operators are expected. */ #include #include #include using namespace std; // Function to convert Infix expression to postfix string InfixToPostfix(string expression); // Function to verify whether an operator has higher precedence over other bool HasHigherPrecedence(char op1, char op2); // Function to verify whether a character is operator symbol or not. bool IsOperator(char C); // Function to verify whether a character is alphanumeric chanaracter (letter or numeric digit) or not. bool IsOperand(char C); int main() { string expression; cout
Thanks a lo0Oo0Oo0Oo0Oo0Oo0Oo0Ot for your great videos :) Note: breaks are missed in switch case in GetOperatorWeight function which leads to ignoring arithmetic precedence - Because returned weight will be 3 in the all cases -
I was working on figuring out what I did wrong after following this. Make sure your hasHigherPrecidence returns true if they are equal. Took me a while to figure out
+GBpackerfan95 will only work with operators of left to right associativity but will produce incorrect results for operators that are right to left associativity: exponents. test it with x ^ y ^ z w/c should produce x y z ^ ^.
At 10:04 the code says .. If s.top() has higher precendence than exp[i], then it has to enter into while loop. So, why '+' is popped out from stack even though + and - have same priority?
***** I agree with you. The code in this vedio would get the postfix as '3 2 1 + -'. However, manually conversion result should be ' 3 2 - 1 +'. Please correct if there's any mistake of my understood.
that because the precedence(+,-) is same and when that happens, rightmost value would have the highest precedence as the code is executed from right to left. so precedence would return true.
Hello, are you sure the code is correct? Let's say the infix exp is A+B*C-D*E. When postfix is ABC and we have +* in stack and exp[i] = -, then I think the condition (!s.empty() && HasHigherPrec(s.top(), exp[i])) in the while loop will prevent + from being appended to the postfix expression. I think the reason is when you append *, then the condition is validated again and + in stack will not have higher precedence than exp[i] = -. Can somebody please confirm if I am correct or not. Thanks.
Exactly..... we can use a flag which checks if the current operator is of lower precedence than the top of the stack. If it is , then just keep popping till the stack is empty and push the current operator in the stack
Yes,i have the same question as you.You can see the Dipanshu Someshwar's comment above you.In the java code (about line 51)." (precedenceLevel(exp.charAt(i))
Since we are doing Postfix, operators(+,-,*,/) will come after operands(numbers) if it is valid. For example, If you have *+-456 you will start the for loop. Since exp[0] is an operator (* in this case) you enter the else statement. Currently the stack is empty so it will exit. If you had a valid scenario 45*, for exp[0] and exp[1] you will enter the numbers on the stack and when you hit the operator the stack won't be empty.
6 years after this video has been published , still it saves engineering students
@walkman 12/June/2020 computer science student saved!
True m alive
@walkman who was killing you in lockdown
@@CorporateGamer who was killing you in lockdown
31 Dec 2020 , another engineering student saved |
The real beauty of the video starts around the 12 minute mark with the parentheses. I couldn't, for the life of me, find a way to work with parentheses, but when he did his excellent job explaining it I was finally able to work it out.
i just wonder , if you wouldn't have made this videos , then i would have been literally ended up just cramming the stack , que ,etc from any local author! but the flow of your explanation is indeed dulcet ! thanx a lot for employing your time to help students like us !
I see o.O !
Congratulations on your videos. I'm studying in an university and your videos are much easier to understand. Thumbs up!
Its 10 years and it still save lives
For those who disliked, you can not get better then this.
Dipanshu Someshwar
Are you getting the solution... subtitle is distributing it is at wrong location
than*
.............
I agree with you
true, but people dont value free things, they will like half this quality if they have to pay a hefty fee for it, and regarding location of subtitles, one can just switch them off if they distract...
At 9:21
In the while loop why the !s.empty is used, the stack is initially empty and the condition fails in first iteration
Just to note, combining this lesson with the previous lesson you can make a working calculator.
what previous video
duude such a great clear explanation, still helpfull 9 years later, thanks a lot 👍
You just saved me from jumping off a building.
Thanks mate.
people jumping off cuz they didn't understood a topic,awesome
By far the best infix/prefix/postfix series on TH-cam
I am speechless by your understanding of data structures , so clean apt and to the point , a huge thank you really
@mycodeschool, please make more videos! I haven't seen a better explanation to this conversion. By far the best!
At 9:21
In the while loop why the !s.empty is used, the stack is initially empty and the condition fails in first iteration
@@saireddybonthu985 That case is handeled at the last else condition where we append all teh leftover operators to the string form the stack.
the USA hav Stanford
India has mycodeschool
But, thankfully, the whole world has mycodeschool!
omg,teacher,you are so much better than my professor,i become more confident after seeing your videos
intelligence of the guy teaching is very well visible through his lectures
You are doing the Lord's work, even in 2021
Thanks. This was a terrific explanation of the conversion.
This lesson is going to live forever helping future students! Thanks.
Thank u Sir, my school teacher just made me to cram this, nut now i really understand the concept.
MAY GOD BLESS YOU..
Well done! This is the clearest explanation of this topic that I have ever seen. Thanks so much for sharing.
these videos are GOAT on data structures
this video was uploaded on 2013 but still in 2020 this is the best explanation
Clear, crisp, precise and concise. You and your content are amazing! Thanks!
Thank you! This lesson was very clear and easy to understand.
RIP Sir, You are not with us but your legacy will live forever.
@@zuhail339 what happened how??
What??? Did he die????? how????
@@antojosu That's his friend (the co-founder of this channel) not him
@@MohamedHossam-in1yn Oh
even in 2019 your maths is still appreciated. THANK YOU !!
mycodeschool has the best videos on DS and Algo in the entire youtube (or even Internet as whole)
I remember watching this video when I was in 11th and now I am watching this again in my second year . DAMN
simple and outstanding ,cant have better videos on infix and postfix than this.
Best explanation ever STILL 🙏🙏🙏
Great Explanation man. Everything explained in one video concisely!
Such a quality content!!! ❤️... Undoubtedly it deserves more views and likes!
wow..! what an explanation it is! Really great.if this video doesn't exist i might have left stack topic for sure.
How someone can dislike these gem videos
perfect explanation...one more thing your voice is just awesome sir...
Great video, random indian guy always comes in clutch 😤😤😤😤
24/03/22 and it still saved me
I understand what to do with my project now. Thank you for explaining it well!
Excellent video, couldn’t ask for a better explanation!
I like yr accent... really very helpfull...
Thanku soo mch sir..for yr valuable time....
his friend died not he
I needed to brush on this stuff recently, thank you so much for posting this clear example.
@ 7:42 what it mean? there r 2 ways in which we can find the end of the right operand for an operator a)If we get an operatoer of lesser precedence
these are quite difficult but you made them easier for all of us !! Thanks for such kind effort but I'm still struggling with this algorithm since morning.Somehow my mind is muffed :(
Your videos are worth Watching. Thanks for uploading them.
This is the best video for infix to postfix
no one can teach better than this!!!
2024 - still the best tutorial for infix to postfix
Like if you agree ❤
R.I.P! Your videos will survive
Excellent explanation ----> 5 STARS
Stupendous explanation and great illustration
very nicely and smoothly explained.Thanks
thank u sir for making my exam more simplest
This is really helpful! Great explanation.
Thanks a lot.
thank you
pseudocode was very tough nd explained so quickly..however logical view was gud
you are simply the best at explaining!!!! thank you
here is the correct code in c++ :
/*
Infix to postfix conversion in C++
Input Postfix expression must be in a desired format.
Operands and operator, both must be single character.
Only '+' , '-' , '*', '/' and '$' (for exponentiation) operators are expected.
*/
#include
#include
#include
using namespace std;
// Function to convert Infix expression to postfix
string InfixToPostfix(string expression);
// Function to verify whether an operator has higher precedence over other
bool HasHigherPrecedence(char op1, char op2);
// Function to verify whether a character is operator symbol or not.
bool IsOperator(char C);
// Function to verify whether a character is alphanumeric chanaracter (letter or numeric digit) or not.
bool IsOperand(char C);
int main()
{
string expression;
cout
2014 Passed out, still remembered
working c code:
#include
#include
#include
struct stack
{
char data;
struct stack *link;
};
struct stack *top=NULL;
void push(char x)
{
struct stack *temp=(struct stack*)malloc(sizeof(struct stack));
temp->data=x;
temp->link=NULL;
temp->link=top;
top=temp;
}
void pop()
{
if(top==NULL) return;
struct stack *temp=top;
top=top->link;
free(temp);
}
char top1()
{
if(top==NULL) return 0;
return top->data;
}
int isoperand(char c)
{
if(c>=65 && c0)
{
if(topprior(top1(),A[i])>0)
{
while(top!=NULL)
{
arr[j++]=top1(); pop();
}
}
push(A[i]);
}
}
while(top!=NULL)
{
arr[j++]=top1(); pop();
}
printf("Postfix:%s",arr);
}
void main()
{
char arr[100];
printf("Infix:");
int n; scanf("%s",arr);
n=strlen(arr);
compute(arr,n);
}
Really nice work the best I've found I can now start with my project Thank you
Wow!! Really awesome explanation :) Lots of thanks!
Omg I now understand hurray! All credits to u sir 😊
thanks sir...i wish you were my professor
*32
@Edijing Edijer gosh.... please say u r joking
@@abdulrahmanyasser3897 sorry bro but this is the reality!!!!!... That's why they stop uploading videos
Thanks a lo0Oo0Oo0Oo0Oo0Oo0Oo0Ot for your great videos :)
Note: breaks are missed in switch case in GetOperatorWeight function which leads to ignoring arithmetic precedence - Because returned weight will be 3 in the all cases -
I was working on figuring out what I did wrong after following this. Make sure your hasHigherPrecidence returns true if they are equal. Took me a while to figure out
+GBpackerfan95 will only work with operators of left to right associativity but will produce incorrect results for operators that are right to left associativity: exponents. test it with x ^ y ^ z w/c should produce x y z ^ ^.
easy to understand nd hard to 4gt....awsmmm xplaintn :)
Most excellent teaching. Thank you.
Well explained, saved my due day! Thank you!
thanks my man!! This is super clear your a great teacher!
big thanks, this has helped me so much in short amount of time!
GREAT! now my code works! THANK YOU!
different from how i did it, but your explanation has clarified and helped me successfully debug!
Thank you for this awesome and straight forward video!
thank you bro your a real life saver
thnx for uploading such video. very helpful
Super understandable! Thanks, this video really helped me with my project :).
You're the best Dude!!! Keep up
Best video for explanation :)
I was stucked with DS and you are boon for me
great explanation as always .... Lots of thanks for your videos.
At 10:04 the code says ..
If s.top() has higher precendence than exp[i], then it has to enter into while loop. So, why '+' is popped out from stack even though + and - have same priority?
*****
I agree with you.
The code in this vedio would get the postfix as '3 2 1 + -'.
However, manually conversion result should be ' 3 2 - 1 +'.
Please correct if there's any mistake of my understood.
that because the precedence(+,-) is same and when that happens, rightmost value would have the highest precedence as the code is executed from right to left. so precedence would return true.
its very clear. its easy to understand. Thanks
Found it really helpful!! Thank you :)
Thank you so much from Vietnam
Thanks a lot for your great and helpfull vedios
Thank you! I really understand this now!
Excellent lecture, thanks so much
Who's still watching this masterpiece in 2020?
Hello, are you sure the code is correct? Let's say the infix exp is A+B*C-D*E. When postfix is ABC and we have +* in stack and exp[i] = -, then I think the condition (!s.empty() && HasHigherPrec(s.top(), exp[i])) in the while loop will prevent + from being appended to the postfix expression. I think the reason is when you append *, then the condition is validated again and + in stack will not have higher precedence than exp[i] = -. Can somebody please confirm if I am correct or not. Thanks.
it should be like if we have the same preference then also it will be popped as it is coming for associativity as from left to right.
Exactly..... we can use a flag which checks if the current operator is of lower precedence than the top of the stack. If it is , then just keep popping till the stack is empty and push the current operator in the stack
agree, the solution for that issue is to check whether the operator has !LOWER(negation) precedence or HIGHER_EQUAL.
Yes,i have the same question as you.You can see the Dipanshu Someshwar's comment above you.In the java code (about line 51)." (precedenceLevel(exp.charAt(i))
Sir I dont understand . plz explain - if(op == "$") . in your code ...
Subscribed. Great video.
Really clearly explained
amazing video !! good explanation..
Nice one, clearly stated everything
At 9:21
In the while loop why the !s.empty is used, the stack is initially empty and the condition fails in first iteration
Since we are doing Postfix, operators(+,-,*,/) will come after operands(numbers) if it is valid. For example, If you have *+-456 you will start the for loop. Since exp[0] is an operator (* in this case) you enter the else statement. Currently the stack is empty so it will exit. If you had a valid scenario 45*, for exp[0] and exp[1] you will enter the numbers on the stack and when you hit the operator the stack won't be empty.
really i have understood how to convert infix to postfix.
Really Awesome Video its helped a lot thanx :-)
Thanks for clearing my confusion
very good explanation.
Well Explained!
Thank you sir :)
Thank you so much! This is very useful.
very easy to understand,thank you