Check for balanced parentheses using stack

preview_player
Показать описание
See complete series on data structures here:

Algorithm or program to check for balanced parentheses in an expression using stack data structure. This is a popular programming interview question.

See source code here:

Рекомендации по теме
Комментарии
Автор

I clearly understand this subject now. I saw this for free and am in debt from school for something they couldn't teach. The irony. Thanks for the lovely video!!

mymysf
Автор

the best data structures video on the internet i've ever seen. thanks for the clarity and understandability even 9 years later. hope you're okey

selenayyalcn
Автор

No one can explain any clearer that this!!! thank you

abocidejofa
Автор

The best explanation of this concept, Last Un-Closed, First Un-Closed, makes it clear why a stack must be used. This detail has been left out it most explanations. Great work. @9:27

suvansingh
Автор

I've learned more abuout data structures from your videos, than I have from school. Thank you.

rebelutionarygaming
Автор

your classes are very interactive as programming perspective. I could say this is the best data structure tutorial till now we have in web.

tejasrawat
Автор

This guy is one enough to make learn coding the whole student community

poseidon
Автор

You're a bloody genius... Thanks!

aswinpranav
Автор

Thank you for this explanation. I have to do this exact problem for a job interview coming in the fall.

dephcn
Автор

I'm really grateful sir, I will forever remember you.
Thank you from the bottom of my heart ❤

neelanshsharma
Автор

Your classes are all fantastic. Thanks so much!!!

drkato
Автор

Wow, exactly the same as what I did in an Amazon phone interview. I forgot to check s.isEmpty while peeking the stack until it threw exception in one testing, but after adding it back, it is exactly the same as what it shows here. Cool!

plsjustinit
Автор

Words are short to express my gratitude. I am able to code it in C# with your advised alsogrithm, it works in all conditions. Thank you once again.

DineshKumar-lqck
Автор

I’ve been asked this question in coding interview.

parasdesh
Автор

Sir your explanation is too good thanks for explaining me this topic of stack... 😃

vedangkavathiya
Автор

I am really grateful to the person for this awesome compilation of Data Structures Thanks You!

bhaktitarang
Автор

You have the best way of teaching..🔥🔥🔥

mdkaif-kfoh
Автор

thank you for this input method, made it way easier for me to understand

Hyperflow
Автор

We can maintain two data structure stack and queue. stack for the opening and queue for the closing parentheses.

The we can compare these two if all the parentheses are in the order.

hemantyadav
Автор

using a stack seems a bit excessive to me, since for each character to match it must make a call to the C ++ library and this consumes cpu and memory, you can simply use a byte array of fixed length, as large as the number of characters or symbols to compare, in which in each element you can save a number corresponding to the character to be balanced, e.g. 1 corresponds to square brackets and 2 corresponds to round brackets and a global pointer which moves to the right (g_ptr ++) to insert char x, y, z and to move to the left (g_ptr--) to compare and remove char z, y, x, (if the characters do not match or if the pointer goes below zero then there is an unbalance) a method that can also be used to keep track of the states of C directives (for example excluding everything that descends from #else (including other #if #else #endif and resuming the block at the exit of the first #endif) where it is not worth using a stack or a parser e.g. LALR

davidechiappetta