Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

** Data Structures and Algorithms using Java**Restricted Structures*** a)Give the line numbers of the code presented in Figure 3.13 (see textbook page 140) that perform

** Data Structures and Algorithms using Java**Restricted Structures***

a)Give the line numbers of the code presented in Figure 3.13 (see textbook page 140) that perform the garbage collection for the structure Stack.

image text in transcribed

b) Evaluate the following arithmetic expressions written in postfixed notation:

a) 45 3 21 + 10 *

b) 3 6 * 45 2 + *

c) 12 3 * 2 /

c) Write the following arithmetic expressions in postfixed notation:

a) 45 + 6/2

b) (3 + 4 + 7) / 2

c) (b2 4 * a c) / (2 a)

ue, and the code of the class Listing (see Figure 3.14), are con generic design features discussed in Chapter 2 except that the stack can only objects. A fully generic implementation of the stracture, using the generic feature e ita be presented later in the chapter. of V Line 2 of the class Stack shown in Figure 3.13, declares the array data to be an to Listing objects. As was the case for the structure implementationsprend a fs code of the class Stack does not mention any of the data members of a Listino first step toward a generic implementation of this data structure. 1. pub1ic class Stack 2. private ListinglI data; private int top; 4. private int size; 5. public Stack() { top=-1; size 100; data = new Listing[ 1001; 9 10. 11, 12. 13. public Stack (int n) { top=-1; size data n; new Listing[n]; 15. 16, public boolean push(Listing newNode) {if(top== size. 1) return false; 1 overflow error else { top= top + 1; 19. 20. 21. 22. 23. 24. public Listing pop() 25. int topLocation; 26 27. 28. 29. 30. 31 32. 33. 34. public void showA11() 35, { for (int i # top; i >: 0; i..) 36. 37. 11 end of showAll method 38. end of class Stack data[top] = newNode.deepCopy ( ); return true; push operation successful -1 ) return null; if ( top underflow error* else { topLocation=top; top top 1; return datal topLocation]; System.out.println (data[i].toString())i Figure 3.13 Implementation of a Classical Stack Structure

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_2

Step: 3

blur-text-image_3

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions