课程: Java Algorithms
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Solution: Evaluate reverse polish notation
- [Instructor] Before going into the implementation, let's talk about these helper methods given to us to use. The first is isNumber. This one takes in a token that is a string and returns true or false based on whether it can be parsed into a double. The second is isOperator. It takes in a string and returns whether or not it matches one of the basic operations. That's plus for addition, minus for subtraction and et cetera. The last function we're given is performOperation. Given the operator and both operands, it will perform the operation. If the operator is invalid, it'll throw an exception. We can use these helper methods in our implementation in order to keep our function code more concise. Let's implement evaluateRPN. We know that each operand comes before its operator. This means we'll need to keep track of each number until we see the operator. We can do this with a stack. We also know that each operand and…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
(已锁定)
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 秒
-
(已锁定)
-
-
-