课程: Java Algorithms
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Stack algorithms: Matching parentheses
- [Instructor] The stack data structure can be a very useful tool when solving software problems that require keeping track of state. Let's say we need to determine whether a given piece of text has matching parentheses. These are some examples where the parentheses are matching. For each of these, the opening symbol comes before the closing symbol and every open symbol has an associated closed symbol. These are some examples where the parentheses are not matching. These do not start with the opening block symbol, or do not have a closing symbol for each opening. We can use the stack data structure to keep track of whether we've seen an opening symbol or not. Let's take a look. Here, we have a function that returns true or false, depending on whether the parentheses are matching. We also have some test cases written for us. The first four should return true, because they have matching parentheses. The others should return false, because they do not have matching parentheses. For the…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
(已锁定)
What is a queue?1 分钟 53 秒
-
(已锁定)
Standard queue operations in Java3 分钟 38 秒
-
(已锁定)
Queue algorithms: Generate binary numbers4 分钟 41 秒
-
(已锁定)
What is a stack?1 分钟 58 秒
-
(已锁定)
Basic stack operations in Java3 分钟 32 秒
-
(已锁定)
Stack algorithms: Theorizing an algorithm5 分钟 21 秒
-
(已锁定)
Stack algorithms: Next greater element3 分钟 57 秒
-
(已锁定)
Stack algorithms: Matching parentheses4 分钟 49 秒
-
(已锁定)
Solution: Evaluate reverse polish notation4 分钟 16 秒
-
(已锁定)
-
-
-