Evaluation of Prefix and Postfix expressions using stack

  Рет қаралды 636,034

mycodeschool

mycodeschool

Күн бұрын

Пікірлер: 269
@adityaojha2701
@adityaojha2701 4 жыл бұрын
You helped a lot of students achieving their goals. You deserve huge respect. Indeed.
@HandledToaster2
@HandledToaster2 4 жыл бұрын
Why can't we get teachers like this in college lol. I'm sure you're tired of hearing but thank you so much for all your videos, you explain everything so well.
@amanmishra-vt8hk
@amanmishra-vt8hk 3 жыл бұрын
Because Our Teachers doesn't belongs to Google. LOL
@HandledToaster2
@HandledToaster2 3 жыл бұрын
@@amanmishra-vt8hk I'm sorry, I don't know what you meant to say
@amanmishra-vt8hk
@amanmishra-vt8hk 3 жыл бұрын
@@HandledToaster2 He works at google.
@HandledToaster2
@HandledToaster2 3 жыл бұрын
@@amanmishra-vt8hk oooh I didn't know that! Makes sense.
@hmm7458
@hmm7458 3 жыл бұрын
@@HandledToaster2 this channel used to run by two individuals unfortunately one passed away in a tragic car accident (Indian roads you know) and other just stop will to continue the channel so he just go to work for google
@rajanand7047
@rajanand7047 9 жыл бұрын
sir i want to hug you.i watched this video and now i am certain that i will perform better in my exam
@AV-yz2cf
@AV-yz2cf 6 жыл бұрын
xD but really. He's got the best lectures of DS with crystal clear explanations.
@miw879
@miw879 6 жыл бұрын
holy
@jayant9151
@jayant9151 6 жыл бұрын
@NOTyoutuber no u
@rahulsharma-fk8ly
@rahulsharma-fk8ly 5 жыл бұрын
gay.
@ashokgupta3105
@ashokgupta3105 5 жыл бұрын
Great work sir
@thecodinghustle1006
@thecodinghustle1006 5 жыл бұрын
give this man an oscar!
@arvindpanchal2721
@arvindpanchal2721 4 жыл бұрын
Isn't oscar is for entertainment industry he is teaching us not entertaining, doing much greater work than entertainment
@siddhartharaja9413
@siddhartharaja9413 4 жыл бұрын
@@arvindpanchal2721 :-bhawnao ko samjho!☺️☺️
@danhle7999
@danhle7999 4 жыл бұрын
@@arvindpanchal2721 then give him a Nobel for Education XD
@hamzaashoaib4644
@hamzaashoaib4644 3 жыл бұрын
Done
@mohitpandey4655
@mohitpandey4655 Жыл бұрын
He is not alive 😭
@bitethebyte
@bitethebyte 3 жыл бұрын
You are awesome sir, You taught me the whole postfix and prefix concept in just 14 minutes including algorithm. Thank you sir
@chirag_soni_07
@chirag_soni_07 4 жыл бұрын
alright, please add one more thank you to your list. And sir i can't express what kind of respect you owe in every students heart.
@arihantjammar8888
@arihantjammar8888 5 жыл бұрын
Sir your teaching speed is as perfect as it can be.
@AbhishekPandey-yl3bp
@AbhishekPandey-yl3bp 3 жыл бұрын
You gave strength to my self taught programming journey
@peterwan816
@peterwan816 2 жыл бұрын
OMG thank you so much! you explained it much better than my college teacher! Thanks for sharing this valuable information with us for free! thanks a lot!
@whacoder725
@whacoder725 2 жыл бұрын
Where u study
@Juanbaez_
@Juanbaez_ 4 жыл бұрын
Sir, you are the best. If you thought in a University, I would totally go there.
@ajaychinni3148
@ajaychinni3148 4 жыл бұрын
Even after 7 years he has the short and best video on this topic
@HeyThereGuy
@HeyThereGuy 4 жыл бұрын
Beautiful tutorial. Very good English. You saved me so much time.
@laxmandora8404
@laxmandora8404 2 жыл бұрын
What a voice you got!!What an exaplanation skillsyou got!! Loved it
@biswendrajonchhen124
@biswendrajonchhen124 4 жыл бұрын
This is a very crystal clear explanation. Thank you for the video sir.
@luxamateuramvs6800
@luxamateuramvs6800 7 жыл бұрын
dude this is the best video i've ever watched, i totally understood everything, you are really good at teaching.
@dragonore2009
@dragonore2009 7 жыл бұрын
You saved me again, I have exam coming up where I have to evaluate these.
@imsunilvaghela
@imsunilvaghela 6 жыл бұрын
Hi, Your explanation skills are way greater than any of the youtuber with data-structure videos. I recommend your channel to each of my colleagues whose base seem unclear in data-structures. You have did a great job. I have one query in this lesson. How can we convert an infix expression to pre/postfix expression, which contains an unary operator in it? Please edit your video with this content or please make a separate video for this. Thanks in advance.
@sameerahmed5078
@sameerahmed5078 4 жыл бұрын
I heard he is no more, but he left such good videos, he lives with us as long as these videos help people like us.
@avinashmaurya3625
@avinashmaurya3625 3 жыл бұрын
He is alive. His partner and cofounder of mycodeschool is no more. You can google for "humblefool"
@bhagyashreekakwani9508
@bhagyashreekakwani9508 2 жыл бұрын
Your videos help a lot in building the logic !! Thanks a lot!!
@gargrishab
@gargrishab 8 жыл бұрын
thank you sir for such a wonderful ds experience i am seriously obliged thanks
@dylanwatkins1158
@dylanwatkins1158 5 жыл бұрын
awesome ! so clear and understanding, thank you so much! the book for computer architecture just makes no sense. your videos are getting me through this class !
@Camatio
@Camatio 9 жыл бұрын
This was very helpful. You have my thanks, good sir.
@林霈瑄
@林霈瑄 Жыл бұрын
Best version of explanation
@rishabh8808
@rishabh8808 3 жыл бұрын
You are an amazing teacher. Keep up the amazing work!
@bahar2207
@bahar2207 10 ай бұрын
Saved my semester. Thanks
@vijayalakshmi8337
@vijayalakshmi8337 4 жыл бұрын
It's a shame the world lost you so soon. I really wish you be reborn and teach us more.
@curiousenough5906
@curiousenough5906 4 жыл бұрын
what happened?
@MohamedHossam-in1yn
@MohamedHossam-in1yn 4 жыл бұрын
It was his friend Harsha (the co-founder of this channel) who died not him
@mahesh-ve2bp
@mahesh-ve2bp 5 жыл бұрын
There is no words to say Mind blowing explanation
@mithileshpandit1071
@mithileshpandit1071 5 жыл бұрын
too OP man... You are the best teacher on the planet
@AnilSingh-rg2eq
@AnilSingh-rg2eq 8 жыл бұрын
sweet and simple...u make concepts looks so simple..Thanks a lot :)
@ryanyoung2583
@ryanyoung2583 5 жыл бұрын
This is so well done. Thank you so much for creating these videos.
@563woodcock
@563woodcock 10 жыл бұрын
A small correction in your code.... In else if(IsNumericDigit(expression[i])) don't do int operand = 0; Remove this line otherwise every time the control enters this else if statement it will assign the index of the string to 0 and start reading from the very beginning of the string.
@ankitajain4194
@ankitajain4194 6 жыл бұрын
It will be really good if you can explain Time and space complexity too with your videos.
@kumarpriyansh4238
@kumarpriyansh4238 4 жыл бұрын
awesome. Very clear explanation sir.Understood it totally
@ahmedsoliman4015
@ahmedsoliman4015 6 жыл бұрын
Thank you! an awesomely detailed explanation, and the visualization was very informative too!
@tanishkaachaturvedi2173
@tanishkaachaturvedi2173 2 жыл бұрын
best video on the internet
@theneonlotus
@theneonlotus 7 жыл бұрын
great video, very clear description of pre and post fix. found it very useful
@lordstinson8095
@lordstinson8095 4 жыл бұрын
Great video! How do we evaluate prefix/postfix expressions in case of *unary operators* ?
@dumdumbringgumgum2940
@dumdumbringgumgum2940 2 жыл бұрын
in case of prefix the operand immediately succeeding the unary operator. and in case of postfix. the operand immediately preceding the unary operator.
@buddhiniwalakuluarachchi8281
@buddhiniwalakuluarachchi8281 5 жыл бұрын
thank sir.. this is best video for post-fix which i met
@AkGautam_1904
@AkGautam_1904 3 жыл бұрын
Awesome explanation ❤️. Thank you sir 🤩🤩✨.
@mato4430
@mato4430 3 жыл бұрын
You are absolutely genius
@ManojChausali
@ManojChausali 7 жыл бұрын
Program for prefix evaluation #include #include #include using namespace std; bool isOperand(char C) { if(C>='0' && C
@culturapoliticaycomputador9999
@culturapoliticaycomputador9999 3 жыл бұрын
Amazing, thank you so much, for this kind of video. God bless you sir.
@amanmalhotra724
@amanmalhotra724 9 жыл бұрын
fab u all did a fab job awesome explanations this has become one of my fav site and videos thanks and keep it up u guys
@jangandilogout8653
@jangandilogout8653 6 жыл бұрын
Big thanks sir. Very helpful for my exam 😍
@shaikgousiya2151
@shaikgousiya2151 4 жыл бұрын
You are a good teacher
@thatoneuser8600
@thatoneuser8600 4 жыл бұрын
10:48 shouldn't it be 9 - 26 which would be -17? I don't understand which operand is the leader when it comes to subtraction.
@earthisadinosaur2338
@earthisadinosaur2338 Жыл бұрын
truly a godly video my dude
@moazelsawaf2000
@moazelsawaf2000 5 жыл бұрын
Really thanks a lot sir
@imjustjoshying
@imjustjoshying 10 жыл бұрын
Nice Video but you made a mistake in the video during "prefix" notation. You popped 5 & 4 and you multiplied them even though the symbol was + addition.
@SandeepVerma1429
@SandeepVerma1429 10 жыл бұрын
printing mistake dear...
@btsarmyonly5774
@btsarmyonly5774 4 жыл бұрын
Good explanation sir... Thank you so muchhh
@rohananjaria1009
@rohananjaria1009 4 жыл бұрын
Code for prefix evaluation #include #include #include using namespace std; // Function to evaluate Porefix expression and return output int EvaluatePrefix(string expression); // Function to perform an operation and return output. int PerformOperation(char operation, int operand1, int operand2); // Function to verify whether a character is operator symbol or not. bool IsOperator(char C); // Function to verify whether a character is numeric digit. bool IsNumericDigit(char C); int main() { string expression; cout
@vikramsapate8703
@vikramsapate8703 3 жыл бұрын
Miss you man ............!!!!!
@PiyushYadav-hf1ec
@PiyushYadav-hf1ec 3 жыл бұрын
Great Explanation👍🏻👍🏻👍🏻👍🏻
@narmadapasumarthi9190
@narmadapasumarthi9190 8 жыл бұрын
Really excellent explanation. Thank you very much..
@taimoorsk
@taimoorsk 4 жыл бұрын
Great teacher 😍😍
@tree78254
@tree78254 8 жыл бұрын
In evaluation of prefix exp, atlast... If d operator comes, u hav two pop two elements...n here 2nd element is the 2nd operand.. So d final ans should be like -17 right???
@lagend0066
@lagend0066 7 жыл бұрын
thanks a lot for so much easy method .....GOD bless you man
@Klish47
@Klish47 8 жыл бұрын
amazing..thanku sooo muchh... understood like never before
@AmrendraKumar-ko8yf
@AmrendraKumar-ko8yf 7 жыл бұрын
yeah ..absolutely So, what r u doing these days . job or studying
@shivanshmathur403
@shivanshmathur403 4 жыл бұрын
@@AmrendraKumar-ko8yf are chacha......kaahe itna...thoda sabr karo
@udz26
@udz26 3 жыл бұрын
The prefix expression -+*23+549 is evaluating to 6, not 17... I even checked on online prefix analyzers. Correct me if I am wrong, Edit: Please ignore this, the actual expression is -+*23*549.
@manistrikes
@manistrikes 3 жыл бұрын
Well after 23 it's the multiplication operator and not '+'.
@udz26
@udz26 3 жыл бұрын
@@manistrikes Ohh god... and I was frustrated over why my answer is not 17 🤦🤦🤦
@yogieanugrah3865
@yogieanugrah3865 8 жыл бұрын
Thanks! you helped me get my homework done. :)
@amanmishra-vt8hk
@amanmishra-vt8hk 3 жыл бұрын
By the way answer should for the prefix be 6. If I am wrong please correct me.
@ericnelsonelem5241
@ericnelsonelem5241 6 жыл бұрын
Very illustrative. Thank you!
@eldadkanawa6527
@eldadkanawa6527 3 жыл бұрын
Nice Explanation, Thanks a lot
@gmunni17
@gmunni17 7 жыл бұрын
for the prefix example, could you not write it as: - 9 + * 5 4 * 2 3 this gives me the same final answer of 17
@MYtantrums
@MYtantrums 6 жыл бұрын
on evaluation of postfix, which one did u pop first? 26 or 9, since OP1 should be 9 because it is the first one to pop and OP2 is 26 (following LIFO), please clarify
@jeetbardapurkar4912
@jeetbardapurkar4912 6 жыл бұрын
9 was the first to pop and then 26 was popped. The way he has programmed, op2 holds the value of the element which was popped first and op1 holds the value of the element popped later. You can interchange what op1 and op2 mean when you write your own code.
@iam_a_sad_khan
@iam_a_sad_khan 6 жыл бұрын
I also got confused first but look 9 pops out first as op2 and then 26 pops out as op1. Now perform the operation op1- op2 that is 26- 9. I hope that makes sense.
@DarkLordAli95
@DarkLordAli95 8 жыл бұрын
thank you so much kumar.
@ganapatibiswas5858
@ganapatibiswas5858 4 жыл бұрын
come back mycodeschool
@BladeAndrade
@BladeAndrade 7 жыл бұрын
why at the subtraction you place 26 as operand 1 instead of 9? isn't supposed to pop the topmost elements of the stack? 9 is the topmost and must pop out first then 26 so you will have 9-26, I'm confused.
@yashmehan3944
@yashmehan3944 5 жыл бұрын
very well explained, thank you very much!
@dearvivekkumar
@dearvivekkumar 10 жыл бұрын
Great explanation as always
@harshmairh495
@harshmairh495 10 жыл бұрын
thank u for this amazing video. u r doing a great job!!
@redmood1097
@redmood1097 10 жыл бұрын
Thank you very much it was very helpful .
@tigershroff8026
@tigershroff8026 6 жыл бұрын
4:01 there is a mistake. The stack is 26 9 - at the end. It should be popped as 9 - 26 = -17 but it is popped as 26 - 9 = 17. Am I right?
@golubhai1910
@golubhai1910 4 жыл бұрын
getting answer 9 from your source code.
@rztutul8824
@rztutul8824 7 жыл бұрын
just awesome explanation ....Tnx
@vengtCent
@vengtCent 6 жыл бұрын
Great explanation!
@meenugabalachandra325
@meenugabalachandra325 6 жыл бұрын
answer may me -17 because last last stage 9,26 are in the stack so 9-26=-17
@mazlumorhan
@mazlumorhan 3 жыл бұрын
omg his voice doesn't annoy me at all :D Im sure it'll be great video
@mohitdaga2356
@mohitdaga2356 7 жыл бұрын
You were a genius,no wonder!
@shantanumaitra8192
@shantanumaitra8192 5 жыл бұрын
Best explanation🤗🤗🤗🤗😘
@abhishekkumar-so7ww
@abhishekkumar-so7ww 4 жыл бұрын
you have got good vocal cords
@5thbatman
@5thbatman 5 жыл бұрын
great explanation...
@bolu3307
@bolu3307 5 жыл бұрын
Python implementation of postfix expression evaluation. Note: Parses single-digit numbers only. You may implement your preferred parser for input. #Stack class implementation class stack(): def __init__(self): self.headNode = None def trav(self): if(self.headNode): checkNode = self.headNode print checkNode.data while checkNode.next: next = checkNode.next print next.data checkNode = next def push(self,val): NN = Node(val) NN.next = self.headNode self.headNode = NN def pop(self): if(not self.headNode): return None CNode = self.headNode self.headNode = self.headNode.next return CNode def not_emp(self): if(self.headNode!=None): return True return False def top(self): return self.headNode #import operator module to match operator characters with Arithmetic functions import operator def postfix_eval(exp): #operator dictionary, pairing characters with arithmetic functions operators = {"+":operator.add,"-":operator.sub,"*":operator.mul,"/":operator.div} exp_stack = stack() for i in exp: #if not operator, i.e if operand, add to top of stack if(not i in operators): exp_stack.push(i) else: #if character operator, pop last two top elements in stack, be mindful of the order operand2 = int(exp_stack.pop().data) operand1 = int(exp_stack.pop().data) #call arithmetic operator with character as key in operators dictionary, and pass the last two popped elements as parameters result = operators[i](operand1,operand2) exp_stack.push(result) #when all done, return top(only) element left in stack return exp_stack.pop().data
@MegaBdboy
@MegaBdboy 7 жыл бұрын
What code should i write to evaluate the expression from right ?
@tune_into_gaming
@tune_into_gaming 7 жыл бұрын
best explanation...
@shamim-io
@shamim-io 6 жыл бұрын
Thanks.. Helped me a lot!!
@nabilaaziz3446
@nabilaaziz3446 9 жыл бұрын
Good job!! Great explanation. thanks :)
@whacoder725
@whacoder725 2 жыл бұрын
I have tried 3 days to solve this question but i can't why it is showing null value
@TechnoForbes
@TechnoForbes 8 жыл бұрын
Awesome Explanation .. Thanks a Lot :)
@niamatullahbakhshi9371
@niamatullahbakhshi9371 8 жыл бұрын
in 13:16 , it was addition(+) but you multiplied however multiplication has not reached ! why ?
@ashutoshsingh419
@ashutoshsingh419 8 жыл бұрын
thanks so much for this explanation
@himanshugupte5543
@himanshugupte5543 8 жыл бұрын
You guys are awesome!
@dragansmoljan7917
@dragansmoljan7917 9 жыл бұрын
what if i want to write an expression without spaces or comas? 2+3*4-5? i get a error, i dont know why
@ankitjangid1
@ankitjangid1 9 жыл бұрын
Sir can you please tell how to convert complex expressions into postfix, for ex :- in my book a question is given i.e A*(B+D)/E-F-(G+H/K) and (A+ B ^ D)/(E-F)+G (^ IS NOT POWER). Please help!!
@jameslussier3143
@jameslussier3143 10 жыл бұрын
this was very helpful, thanks a lot
@sunandareddy5126
@sunandareddy5126 6 жыл бұрын
Evaluate the following prefix expression " ++ 26 + - 1324" sir can u plz explain
@aliesapour79
@aliesapour79 4 жыл бұрын
Thank you so much for your video
@tomlynd8836
@tomlynd8836 8 жыл бұрын
Awesome explanation, thanks!
@mairaabid4538
@mairaabid4538 8 жыл бұрын
if statement is that ( a=b=x=y=0) so what we do in postfix and prefix?
@andreasan1783
@andreasan1783 Жыл бұрын
thanks, very helpful
Infix to Postfix using stack
18:20
mycodeschool
Рет қаралды 756 М.
Infix, Prefix and Postfix
13:38
mycodeschool
Рет қаралды 932 М.
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 5 МЛН
Муж внезапно вернулся домой @Oscar_elteacher
00:43
История одного вокалиста
Рет қаралды 6 МЛН
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 5 МЛН
Check for balanced parentheses using stack
14:13
mycodeschool
Рет қаралды 478 М.
L3. Prefix, Infix, and Postfix Conversion | Stack and Queue Playlist
50:47
3.9 Evaluation of Prefix and Postfix expressions using Stack | Data Structures
21:03
New divisibility rule! (30,000 of them)
26:51
Stand-up Maths
Рет қаралды 280 М.
3.4 Infix Prefix and Postfix expressions | Data Structures Tutorials
14:14
Jenny's Lectures CS IT
Рет қаралды 1 МЛН
Stack | Set 2 (Infix to Postfix) | GeeksforGeeks
14:27
GeeksforGeeks
Рет қаралды 149 М.
Beginners Should Think Differently When Writing Golang
11:35
Anthony GG
Рет қаралды 123 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 5 МЛН