Reverse Polish Notation and The Stack - Computerphile

  Рет қаралды 304,074

Computerphile

Computerphile

10 жыл бұрын

Reverse Polish, or Postfix notation is commonly used in Computer Science, particularly in reference to Stacks - but what are stacks and how does postfix work? Professor David Brailsford takes us through it.
Upside Down (Huffman) Trees: • How Huffman Trees Work...
Quick Sort: • Quick Sort - Computerp...
Getting Sorted: • Getting Sorted & Big O...
/ computerphile
/ computer_phile
This video was filmed and edited by Sean Riley.
Computer Science at the University of Nottingham: bit.ly/nottscomputer
Computerphile is a sister project to Brady Haran's Numberphile. See the full list of Brady's video projects at: bit.ly/bradychannels

Пікірлер: 347
@duckrutt
@duckrutt 8 жыл бұрын
The best part about having a RPN calculator is it will only be borrowed by anyone once and you will always get it back.
@Jarzyniak
@Jarzyniak 10 жыл бұрын
As a Pole, I'm incredibly impressed by his pronunciation of Łukasiewicz's name.
@tomasznikiel2508
@tomasznikiel2508 9 жыл бұрын
Perfect spelling of the Polish name, respect for digging it up.
@thesnowedone
@thesnowedone 10 жыл бұрын
The key thing to remember here is that not only is this efficient processor wise; RPN is also efficient memory wise. You don't have to keep track of multiple variables all over the place; everything you need to complete your operations is in the stack in the order you are going to have to process them. It's a very tidy system and a core component of computing that is normally hidden by higher level languages.
@vagramAU
@vagramAU 8 жыл бұрын
Wish i had such a passionate professor at uni, good stuff.
@jamestaylor7974
@jamestaylor7974 6 жыл бұрын
So many of these videos are brilliantly educational that I have started editing and improving the captions for people like myself who are hard-of-hearing or deaf. If you find my changes suitable, please use and alter them as you please. I have so far done this for two videos and intend to continue if you will approve the changes. It is the least I can do for such a great channel. :)
@IMortage
@IMortage 10 жыл бұрын
I've always thought the Reverse Polish sounded like a Chess Opening. Which makes it even better.
@ArnavDhamija
@ArnavDhamija 10 жыл бұрын
This guy is a phenomenal teacher.
@mikelipsey8837
@mikelipsey8837 10 жыл бұрын
It's very refreshing having a gentleman this age teaching these with this passion! Great teacher! Thank you, sir.
@Karthik-yy6up
@Karthik-yy6up 8 жыл бұрын
Too bad I did not find this channel when I was supposed to be studying all this.
@wattage
@wattage 8 жыл бұрын
Wonderful video. I first encountered an fell in love with RPN when I got my HP 32SII, back in high school. It was so great. You never needed parentheses and you could enter formulas by reading left to right. So nice to hear Prof. Brailsford explain the history and explain why it was so great.
@Chaosdude341
@Chaosdude341 10 жыл бұрын
It's interesting to watch these coding videos because of the benefits it brings to my own logic. Coding is incredible at showing different ways to do the same thing. Before watching this video, I'd never thought in mathematical terms any different from infix notation. It's incredible to see how that suddenly changes the approach to the entire problem. Long story short, thank you for uploading these, Brady and Sean.
@unvergebeneid
@unvergebeneid 10 жыл бұрын
My first contact with RPN was in a maths exam when I had forgotten my calculator. The teacher was kind enough to let me borrow hers but it was RPN. The first couple of minutes I thought I was as good as dead but I got used to it surprisingly quickly.
@shayneoneill1506
@shayneoneill1506 10 жыл бұрын
If you understand this, you pretty much understand everything you need to know to program a language called "Forth". Forth is a brilliant language that is as low level as C (its almost superpowered assembly code) but can be as expressive and powerful as LISP. Its often used for programming very low level stuff, and thus gets called a "toaster language" (Because you might program the chip in a toaster with it). The most astonishing result of forth is;- you can program very very low level stuff without ever needing to set a register.
@angeldude101
@angeldude101 10 жыл бұрын
I have a calculator app on my tablet that I usually keep in rpn mode. Makes it easier to do bulk operations and it makes sure the calculator doesn't mess up the order of operations.
@MrAntiKnowledge
@MrAntiKnowledge 9 жыл бұрын
Damn. One of my assigments is to program a calculator which interprets a string in postfix notation. After watching this video that's an laughably easy task. Just have to push everything on a stack and I'm as good as done. I can understand now why they like RPN.
@JAN0L
@JAN0L 10 жыл бұрын
Pretty good pronunciation on Łukasiewicz's name.
@aries_9130
@aries_9130 10 жыл бұрын
Brilliant explanation, love this guy.
@fuzzylilpeach6591
@fuzzylilpeach6591 6 жыл бұрын
Its like the euler's identity of computer science. Somehow seemingly unrelated conclusions come together in a beautiful way.
@Ostsol
@Ostsol 10 жыл бұрын
Funny how just the small hint of the title instantly made it clear to me just what the benefit of postfix notation was. I hadn't actually thought about it until now.
@thenorup
@thenorup 10 жыл бұрын
I learned about RPN by programming in FORTH on the Redpower computer from the Minecraft mod :)
@Ghost00117
@Ghost00117 10 жыл бұрын
I remember when I first learned about this a Comp. Sci. course at uni. The prof. was printing out a tree using a recursive method and just moved the print out statement between different conditions to convey the idea to us. Really cool stuff. :D
@JimCullen
@JimCullen 10 жыл бұрын
I think this is Professor Brailsford's best Numberphile video yet!
@IceDave33
@IceDave33 10 жыл бұрын
Prof Brailsford is great! I'm really enjoying all the Computerphile videos, you've got some great people to talk to, and they're really well edited! Thanks Sean, keep them coming :)
@GogiRegion
@GogiRegion 5 жыл бұрын
I love RPN calculators. They’re so much faster to use, incredibly intuitive once you understand how to use them, it uses less keystrokes, the system runs faster because it doesn’t need to “compile” the code, and nobody ever will want to borrow it after you show them how to use it. 😆
@LimeGreenTeknii
@LimeGreenTeknii 10 жыл бұрын
I'm gonna pop some stacks, only got operands in my pocket.
@Fhuaran
@Fhuaran 10 жыл бұрын
Brailsford's videos just get better and better. It's like a story unfolding.
@AstroTorch
@AstroTorch 9 жыл бұрын
Thanks for this Brady, exam tomorrow.
@Computerphile
@Computerphile 9 жыл бұрын
Evan. glad you liked it - my colleague Sean made this video though... I was just a viewer like you! >Brady
@vivianrichards3434
@vivianrichards3434 10 жыл бұрын
You just gave me new confidence to take on Compilers courses. Thank you.
@KaiserSpherical
@KaiserSpherical 10 жыл бұрын
I remember having a similar reaction as Professor Brailsford here when I was first introduced to postfix notation and their relation to stacks. It's just brilliant! Absolutely a match made in heaven :D
@intermarer9145
@intermarer9145 Жыл бұрын
Whoa, does this man have a playlist or something? What a great teacher! I feel I could watch him for hours and get super smart 😊
@krishnaindani8414
@krishnaindani8414 3 жыл бұрын
Just saw two videos on this channel and really impressed by the way they go into explaining it by doing into details. The professor is really amazing.
@NotMarkKnopfler
@NotMarkKnopfler 5 жыл бұрын
The programming language called Forth, invented by Charles H. Moore has stacks and reverse Polish notation at it's very heart. It's an incredibly powerful and beautifully simple language.
@Grngnak
@Grngnak 10 жыл бұрын
A number of years ago I tried learning a programming language that used RPN and couldn't quite understand how it all went together... I wish I had this video back then, it explains things very simply and make sense out of something that has had me confused for over a decade. Thank you professor!
@esra_erimez
@esra_erimez 6 жыл бұрын
I'm a time traveler from 4 years into the future and this is still the best explanation of the subject matter
@ElectiveTool
@ElectiveTool 10 жыл бұрын
Please don't stop filming this wonderful man, and I won't stop watching :]
@BlakeHelms
@BlakeHelms 10 жыл бұрын
Best and most easy to understand explanation I've seen of RPN and stacks. Professor Brailsford always does a good job of breaking things down like this,
@peterlilliegeo
@peterlilliegeo 6 жыл бұрын
I love how passionate this gentleman is about his craft. Great video and quite easy to understand! Thanks Computerphile.
@goodguy686
@goodguy686 10 жыл бұрын
These videos, like the ones about sorting algorithms and huffman trees are my favourite by far on this channel. Keep it up!
@ozymet
@ozymet 5 жыл бұрын
I love how you are able simplify really complicated topics. Computerphile... thank you.
@WinBear
@WinBear 10 жыл бұрын
Oh man, that takes me back to the mid-80s with HP calculators that use RPN and my sophomore data structures class!
@aquere
@aquere Жыл бұрын
It's wonderful to see someone as passionate as this gentleman about his professional field
@anakso
@anakso 10 жыл бұрын
I am so glad you started a podcast with CGPGrey. I had seen your numberphiles videos before and found them interesting but had no idea compterphiles existed until I decided to look at what your many other channels actually are (idea for future pod cast to mention all your channels and what they actually are)As a computer science student I found this very helpful. Thank you!
@StankyPickle1
@StankyPickle1 10 жыл бұрын
Thank you! Please do more videos like this. My compsci professor would always mention the stack but never took the time to explain it, and the book we were using was only focused with teaching the basic semantics of the language. This seems like an important concept to know if you're trying to optimize run time.
@kaptenrobert
@kaptenrobert 10 жыл бұрын
These videos are so informative. I never leave this channel without learning something new. Great initiative!
@BrendonWilliams
@BrendonWilliams 6 жыл бұрын
This was what made reading RPN click for me. Great video.
@MattBrookes1304
@MattBrookes1304 10 жыл бұрын
Probably the most interesting video on the channel. Professor Brailsford is very interesting
@RMoribayashi
@RMoribayashi 10 жыл бұрын
Loved my HP-15 with its RPN and 4 level stack. Many still think it was the best scientific calculator ever made. Enough for Hewlett Packard to put out a limited edition in 2011, *_22 years_* _after the original had been discontinued_! Mine went to silicon heaven after almost 30 years of use. I make do with an RPN calculator on my PC.
@QDinar
@QDinar 9 жыл бұрын
uralic-altaic languages almost always use reverse p. n. word order: like : "i go to school" is "i school to go". adding at 21: 45 utc+3 : more complex example: i every day big school to go. and arabic almost always uses forward p. n. word order: go i to school big day every.
@XNAforyou
@XNAforyou 10 жыл бұрын
One of the most important videos for any Computer Scientist. The stack is a fundamental data structure.
@sydniusalminia5364
@sydniusalminia5364 5 жыл бұрын
I really appreciate you taking the time to make this video. It really encourages me and its super informative.
@JohnJohnson-xt7zf
@JohnJohnson-xt7zf 5 жыл бұрын
I love listening to this guy talk about literally everything.
@Urahara12
@Urahara12 10 жыл бұрын
Absolutely brilliant explanation, and loved the stacking disks! Keep up the informative videos!
@unvergebeneid
@unvergebeneid 10 жыл бұрын
I bet he has them to demonstrate the Tower of Hanoi: en.wikipedia.org/wiki/Tower_of_Hanoi
@ericmiller3231
@ericmiller3231 10 жыл бұрын
These videos are so, so good. Thank you guys for putting them together.
@Spender604
@Spender604 6 жыл бұрын
Always learning things from Professor Brailsford.
@AaronPaden
@AaronPaden 10 жыл бұрын
This is great, I love this guy. I already had a passing understanding of these concepts, but I had no idea they were related.
@woonsuen545
@woonsuen545 5 жыл бұрын
Splendidly explained! My year-long question on how computer determines which operation to be done first has FINALLY been solved.
@ApostolisTympakianakis
@ApostolisTympakianakis 10 жыл бұрын
I wish I had such good tutors when I was a student. I enjoy every single one of his videos.
@ntfsguy3601
@ntfsguy3601 4 ай бұрын
Best explanation of RPN and stack I’ve heard yet. 😊
@yellownexusoftheworlds8646
@yellownexusoftheworlds8646 8 жыл бұрын
Hello there, i must say, this is one of the best videos i have ever seen on this subject, right now i am studying for a Compiler Design class and i must say, i just loved it, so much clarity, if you are able to, please give my thanks to your colleagues and also thank you, tell them to keep it up
@bazsturgeon3017
@bazsturgeon3017 8 жыл бұрын
Very nicely explained and awesome demonstration, much appreciated.
@adelahmed5886
@adelahmed5886 4 жыл бұрын
Marvelous way of explaining. Thank you computerphile.
@GogiRegion
@GogiRegion 5 жыл бұрын
A lot of the older RPN calculators didn’t use a stack system and instead used 4 registers that just transposed with each other, which was about 2 hz faster (practically null), but it limited you to 4 numbers in the “stack” without needing to use variables. This actually was less limiting than you might expect, but it is nice to have an actual stack that’s limited only to the calculator’s memory.
@evatokkallos5723
@evatokkallos5723 Жыл бұрын
Amazing explaination and demonstration. Thank you so much for posting this video!
@flemish4
@flemish4 10 жыл бұрын
these videos are brilliant
@LimitedWard
@LimitedWard 10 жыл бұрын
I remember having to write a program exactly like this in my data structures course. I think my brain was hemorrhaging a little by the time I finished it.
@MrCanigou
@MrCanigou 10 жыл бұрын
Brilliant as usual. Reminds me of a friend at the "classes préparatoires" who tried to convince me that his HP stack calculator was way more fitted and nimble than my casio fx 180 P. I couldn't argue and felt a bit clumsy. 30 y. ago, feels like yesterday.
@valseedian
@valseedian 8 жыл бұрын
I love this. when I made a scripting interpreter with compiler in c I used reverse polish notation in my compiled scripts. id never heard of this before today but it made the most sense. especially when parsing nested function calls.
@conkerconk3
@conkerconk3 2 жыл бұрын
i cannot explain how big of a smirk i had when he started talking about loading values into registers, and then using the arithmetic unit... its such a cool process
@bruinflight1
@bruinflight1 10 жыл бұрын
Brilliant! So illuminating of processes once mysterious to me! Thanks for another great video!
@mosesnah2893
@mosesnah2893 8 жыл бұрын
love you guys computerphile
@AlexMaday
@AlexMaday 10 жыл бұрын
Fantastic! Can't wait to learn more about stacks!!
@CusterFlux
@CusterFlux 10 жыл бұрын
Best explanation of this I've ever seen.
@MichailShaposhnikov
@MichailShaposhnikov 10 жыл бұрын
OMG, I requested this one and they actually made it real. THANK YOU SO MUCH! =D
@mbalicki
@mbalicki 10 жыл бұрын
Professor Brailsford's pronunciation of "Jan Łukasiewicz" is nearly perfect :) Thank you for that!
@connorbunch3577
@connorbunch3577 6 жыл бұрын
Great explanation and examples.
@Maxflay3r
@Maxflay3r 10 жыл бұрын
Wuh-kah-shye-veech with the accent on wuh. The "shye" is a bit different, but i can't think of anything in english that would use the intended sound. It's kind of a merge between a "sh" and a "see".
@DudokX
@DudokX 10 жыл бұрын
Really simple yet powerful and effective! great!
@Pedritox0953
@Pedritox0953 2 жыл бұрын
Love your videos Professor
@Dayanto
@Dayanto 10 жыл бұрын
Will be taking a course on assembly in a week or so, this was a nice introduction. :)
@ThomasGiles
@ThomasGiles 10 жыл бұрын
A great explanation of stacks and polish notation. Would love to see a follow-up on how things like brackets and unary (negative -) operators work with this.
@Beer_Dad1975
@Beer_Dad1975 10 жыл бұрын
You don't need brackets as you control precedence by order of the operands and operators For example 4;5;6;+;x might be (5+6)x4, whilst 4;5;+;6;x would be (4+5)x6. Hope you can follow my notation - had to use x as a multiplier as asterisk seems to cause bold type. The system I work with uses semi-colons to indicate a push and then calculates left to right pushing the the result from the last operator back onto the stack.
@xxPow3rslave
@xxPow3rslave 4 жыл бұрын
I love this channel.
@cyprinus
@cyprinus 10 жыл бұрын
These videos are great!
@hm6052
@hm6052 5 жыл бұрын
Fantastic explanation. Thank you
@coreyredmon5611
@coreyredmon5611 10 жыл бұрын
Yes. I would like to see more of this please. Very interesting.
@AndrewBlundon
@AndrewBlundon 10 жыл бұрын
Excellent. I've been waiting for this one, I suggested it last year as a topic for Numberfile. RPN takes a while to learn but once you get it things become so much easier.... I'd be lost without my HP48G calculator (which doesn't have an "=" button but has an "ENTER" button instead).
@batsali99
@batsali99 10 жыл бұрын
I've had a HP50G for 4 years now. I'm so much used to RPN notation that I have trouble using "normal" calculators with any efficiency :D RPN is a much faster and error proof way to tackle hairy expressions. RPN users unite! :D
@seth094978
@seth094978 10 жыл бұрын
batsali99 I had my first taste of programming on a 28S, and ever since then I haven't been able to get away from RPN. I now own two 50G's and a 35S. I love how "=" is a secondary function. It really discourages people from "borrowing" my calculators.
@batsali99
@batsali99 10 жыл бұрын
seth094978 Yeah, the borrowing thing is quite true :)
@tobias-edwards
@tobias-edwards 6 жыл бұрын
Great video, better than my lecturer by far
@mcvoid1
@mcvoid1 10 жыл бұрын
Good video! I like the computer science topics, like the trees and stacks and math.
@DoctorDARKSIDE
@DoctorDARKSIDE 10 жыл бұрын
This was spectacular, thank you!
@sureshseneviratne1841
@sureshseneviratne1841 8 жыл бұрын
Thank you soo much for this video ! Helped alot to understand RPN !
@SallowDawn
@SallowDawn 3 жыл бұрын
Beautiful video
@666Tomato666
@666Tomato666 10 жыл бұрын
props to professor Brailsford! very good pronunciation of Łukasiewicz surname
@KristoffDoe
@KristoffDoe 10 жыл бұрын
I was impressed, it was very good pronaunciation of name Łukaszewicz. :)
@amigojapan
@amigojapan 8 жыл бұрын
I owuld of liked the video to continue the explanation on how it then evaluates (a+b)+c in reverse polish stack notation... but great video, this is something i always wanted to know, how a stack evaluates stuff!
@TheLadyApollo
@TheLadyApollo 10 жыл бұрын
Absolutely fantastic
@karimkohel3240
@karimkohel3240 4 жыл бұрын
thanks for the simplification it was really helpful
@magnusmaynard
@magnusmaynard 10 жыл бұрын
What a great explanation! :)
@philipmifsud1638
@philipmifsud1638 9 жыл бұрын
Thanks Brady :) very simple and cleared my mind on this :) cheers
@user-le3tu8pq7e
@user-le3tu8pq7e Жыл бұрын
What a great channel
@GeoffreyBernardo
@GeoffreyBernardo 8 жыл бұрын
Very good lecture! LISP languages use the opposite: forward polish notation. There parentheses are required to show where the list of operands end for a operator.
Programming in PostScript - Computerphile
15:22
Computerphile
Рет қаралды 245 М.
Reverse Polish Grows on Trees - Computerphile
9:51
Computerphile
Рет қаралды 92 М.
Дибала против вратаря Легенды
00:33
Mr. Oleynik
Рет қаралды 2,6 МЛН
Super gymnastics 😍🫣
00:15
Lexa_Merin
Рет қаралды 105 МЛН
Getting Sorted & Big O Notation - Computerphile
10:59
Computerphile
Рет қаралды 316 М.
Ep 081: Introduction to the Stack Pointer
16:09
Intermation
Рет қаралды 46 М.
What on Earth is Recursion? - Computerphile
9:40
Computerphile
Рет қаралды 739 М.
CycleGAN Generative Adversarial Network - Ian Goodfellow GAN inventor
0:54
The Data Science Channel
Рет қаралды 250
Entropy in Compression - Computerphile
12:12
Computerphile
Рет қаралды 390 М.
The Font Magicians - Computerphile
19:31
Computerphile
Рет қаралды 366 М.
EEVblog #1159 - World's Most Precise Pocket Calculator
17:57
EEVblog
Рет қаралды 504 М.
Дибала против вратаря Легенды
00:33
Mr. Oleynik
Рет қаралды 2,6 МЛН