Java Reference
In-Depth Information
3.
The following stacks are shown bottom to top when read from left to right:
a.
[
b.
{
c.
[
[ {
{ [
[ {
[ { (
{ [ (
[ { [
[ {
{ [
[ { [ (
{ { (
{
[ { [
[ {
[ {
[
[
empty
The algorithm
checkBalance
returns true for the expression in Part
a
and false for the other two.
4.
a.
a b c
*
+
b.
a b
*
c d
-
/
c.
a b
/
c d
-
+
d.
a b
/
c
+
d
-
5.
Always. Segment 5.14 showed that you push
^
onto the stack if another
^
is already at the top of the stack. But if a
different operator is at the top,
^
has a higher precedence, so you push it onto the stack in that situation as well.
6.
a.
a b
+
c d
-
/
b.
a b c
-
/
d
*
c.
a b c d
-
/
e
*
f
+
g
^
-
d.
a b
c
*
-
d e f
^
*
g
*
h
+
/
7.
a.
-
4.
b.
-
58.
c.
-
10.
d.
49.
8.
a.
5.
b.
-
4.
c.
22.
d.
-
37.