Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA Please read carefully. Thanks ****************************************** Question 1: StackOfStrings s = new StackOfStrings(); while (!StdIn.isEmpty()) { String item = StdIn.readString(); if (!item.equals(-)) s.push(item); else if
JAVA Please read carefully. Thanks
******************************************
Question 1:
StackOfStrings s = new StackOfStrings(); while (!StdIn.isEmpty()) { String item = StdIn.readString(); if (!item.equals("-")) s.push(item); else if (s.isEmpty()) StdOut.println("BAD INPUT"); else StdOut.print(s.pop() + " "); }
Suppose the input is " one two three - four five - - six - seven " What would be the second word in the output?
Question 1 options:
two | |
four | |
six | |
none of these |
Question 2:
Consider the code segment below:
Node x = new Node(2); Node a = new Node(3); Node c = new Node(4); Node b = new Node(7); x.next = a; c.next = x; b.next = c;
If we print the list starting at x, the result would be:
Question 2 options:
7 3 2 4 | |
7 3 2 | |
7 4 2 3 | |
none of these |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started