Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 27th International Conference Dasfaa 2022 Virtual Event April 11 14 2022 Proceedings Part 2 Lncs 13246

Authors: Arnab Bhattacharya ,Janice Lee Mong Li ,Divyakant Agrawal ,P. Krishna Reddy ,Mukesh Mohania ,Anirban Mondal ,Vikram Goyal ,Rage Uday Kiran

1st Edition

3031001257, 978-3031001253

More Books

Students also viewed these Databases questions