Question: ** 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.

** Data Structures and Algorithms using Java**Restricted Structures*** a)Give the line numbers

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!