Тёмный

The Shunting Yard Algorithm Demystified: Transform Expressions Like a Pro! 

Gary Explains
Подписаться 313 тыс.
Просмотров 6 тыс.
50% 1

Welcome to my in-depth tutorial on the Shunting Yard Algorithm! 🚂💻 In this video, I unpack and explain this intriguing and useful algorithm. Designed by Edsger Dijkstra, this algorithm is a cornerstone for understanding expression evaluation and conversion, as it converts infix expressions to postfix (or Reverse Polish Notation) expressions.
---
Source code: github.com/gar...
Twitter: / garyexplains
#garyexplains

Опубликовано:

 

16 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 30   
@rezkamali
@rezkamali 13 дней назад
Great explanation! Just a quick point to avoid any confusion: while it's possible to implement the algorithm using two stacks, the original method actually uses one stack and a queue. To clarify, when you use the output list in your code and create the output text using join, it functions as a First-In-First-Out (FIFO) structure, similar to a queue, not like a stack.
@tommurphy7157
@tommurphy7157 6 месяцев назад
Brilliantly explained and very timely! Just what I needed to create the 'advanced' search for my app
@dono42
@dono42 6 месяцев назад
I used RPN on my HP48G calculator while in high school. I also learned the Shunting Yard algorithm in my Computer Science degree; however, I guess I never really understood what "shunting yard" meant. It seems to be the British expression for a rail yard. I don't think it is a common term in US English. I recall classmates jokingly interpret it as "shatting yard" as in a place to to take shit.
@muddyexport5639
@muddyexport5639 6 месяцев назад
Excellent explanation and demo.
@GaryExplains
@GaryExplains 6 месяцев назад
Glad you liked it!
@nickeax
@nickeax 4 месяца назад
Thank you for the great presentation.
@user-jv1js9oc8l
@user-jv1js9oc8l 6 месяцев назад
This was perfect timing thank you!
@GaryExplains
@GaryExplains 6 месяцев назад
So glad!
@alejandroguardiola9085
@alejandroguardiola9085 4 месяца назад
Great video, but I have a question, in the explanation it seems like the output is a queue instead of a stack?
@bertblankenstein3738
@bertblankenstein3738 6 месяцев назад
Once upon a time I coded a stack and the operators were numbers in an array of pointers to functions. I was kind of hoping to learn how this relates to railyards tho.
@kenc4026
@kenc4026 4 месяца назад
Great work, sir. I got an idea because of this. Does this logic applies to Boolean Algebra too?
@cxrbon637
@cxrbon637 4 месяца назад
i think so
@Garythefireman66
@Garythefireman66 6 месяцев назад
Thanks professor! 🤓
@GaryExplains
@GaryExplains 6 месяцев назад
My pleasure!
@AlwaysCensored-xp1be
@AlwaysCensored-xp1be 6 месяцев назад
I wonder if LLM can solve those model train shunting games?
@berjancemdarc4345
@berjancemdarc4345 4 месяца назад
What would this code do on situations like 10+2 ?
@Lumelore
@Lumelore 2 месяца назад
When it parses the input it uses space as a delimiter, so 10 would be interpreted as 10 but 1 0 would be two separate entries. In the stack, 10 is stored as a single element and not multiple separate ones for each digit.
@HyyskanPolttaja
@HyyskanPolttaja 6 месяцев назад
Great! But what about square roots & stuff?
@GaryExplains
@GaryExplains 6 месяцев назад
For other operations you would use functions like cos (), sqrt(), etc. This is how you could write a compiler or interpreter using this method. It is the same principle. Functions have a lower precedence than plus and minus. Raise-to-power ^ has the highest precedence.
@uvatham
@uvatham 6 месяцев назад
00:06
@GaryExplains
@GaryExplains 6 месяцев назад
🚂
@jameslewis7620
@jameslewis7620 5 месяцев назад
🤣
@K9-33
@K9-33 6 месяцев назад
Just use the FORTH programming language.
@GaryExplains
@GaryExplains 6 месяцев назад
That isn't the point. The point is to know how to do it yourself.
@sssyt4837
@sssyt4837 6 месяцев назад
First!
@LA-MJ
@LA-MJ 6 месяцев назад
Exit takes an exit code not a calculation result 😂
@GaryExplains
@GaryExplains 6 месяцев назад
And why can't the exit code be a calculation result?
@LA-MJ
@LA-MJ 6 месяцев назад
@@GaryExplainsbecause non-zero exit code means error occurred in standard semantics
@GaryExplains
@GaryExplains 6 месяцев назад
No, not necessarily. If you want a program to calculate something it can return the calculation as an exit code. This is very useful for scripting. You are making an assumption about the return codes, I assume based on Unix/Linux. On VMS for example SUCCESS was never 0.
@LA-MJ
@LA-MJ 5 месяцев назад
@@GaryExplainsof course it's UNIX. Which matters more
Далее
Binary Search Algorithm in 100 Seconds
2:20
Просмотров 564 тыс.
Comp Sci in 5: Shunting Yard Algorithm
5:55
Просмотров 31 тыс.
The One BIG Reason to Learn Google's Go Language
17:55
Просмотров 158 тыс.
Can ChatGPT Teach You to Program in C?
11:52
Просмотров 12 тыс.
Reverse Polish Grows on Trees - Computerphile
9:51
Просмотров 93 тыс.
Fast and Beautiful Assembly
34:28
Просмотров 9 тыс.