1. The Arraystack implementation in Chapter 12 uses the top variable to point to the next array position available in th

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

1. The Arraystack implementation in Chapter 12 uses the top variable to point to the next array position available in th

Post by answerhappygod »

1 The Arraystack Implementation In Chapter 12 Uses The Top Variable To Point To The Next Array Position Available In Th 1
1 The Arraystack Implementation In Chapter 12 Uses The Top Variable To Point To The Next Array Position Available In Th 1 (27.14 KiB) Viewed 40 times
1 The Arraystack Implementation In Chapter 12 Uses The Top Variable To Point To The Next Array Position Available In Th 2
1 The Arraystack Implementation In Chapter 12 Uses The Top Variable To Point To The Next Array Position Available In Th 2 (27.14 KiB) Viewed 40 times
1 The Arraystack Implementation In Chapter 12 Uses The Top Variable To Point To The Next Array Position Available In Th 3
1 The Arraystack Implementation In Chapter 12 Uses The Top Variable To Point To The Next Array Position Available In Th 3 (23.71 KiB) Viewed 40 times
1. The Arraystack implementation in Chapter 12 uses the top variable to point to the next array position available in the stack i.e. above the actual top of the stack. Modify the array implementation such that stack [top] is the actual top of the stack. Do not introduce any other counter variables. Make sure your driver demonstrates any method that you modify. (Adapted from PP 12.4.) Hint: Start with the Arraystack code that you completed as part of Lab 3. Consider starting top at a value other than 0 and altering where top may be incremented or decremented. 2. There is a data structure called a drop-out stack that behaves like a stack in every respect except that the size is fixed. If the stack size is the bottom element is lost when the n-1 element is pushed onto the top, implement a drop-out stack using links, by modifying the Linkedstack code that you completed as part of Lab 3. The driver should create a stack of moderate size (say five) and push on that many String elements consisting of people's names (include your own). Output the contents of the stack and the results of the aize () and peek () operations. Push two more elements onto the stack, outputting the contents and the results of the size () and peek () operations for each. (Adapted from PP 13.8.) endured in Continn 14 R. With a denue vou can add remove or view elements.
3. A double-ended queue, or deque (pronounced like "deck"), is introduced in Section 14.8. With a deque you can add, remove, or view elements from both ends of the queue. Rather than use the Deque interface supplied by the Java API, design your own DequeADT interface (patterned after QueueAD?). Then, implement a deque using links. Hint: Start with the LinkedQueue code that you completed as part of Lab 4. Also, each node will need both a next and a previous reference. The driver should create a deque of moderate size (say five or six). It should repetitively add elements to the front, and then the rear. For each addition, output the contents of the deque as well as the size, front element, and last element. Then, repetitively remove elements from the deque. For each removal, output the contents of the deque as well as the size, front element, and last element. (Adapted from PP 14.6 and PP 14.7.)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply