https://vichithanh.github.io Practice - Stack
• See file StackApp.java
• Practice: • Write methods to display the stack array and the stack itself. Use them to trace the stack operation. • Extend the push and pop methods to deal with a full and empty stack.
THURSDAY, 21 SEPTEMBER 2023 2
Practice - Stack
• See file ReverseApp.java
• Practice: • Create a stack of objects of class Person and use to reverse a list of persons.
THURSDAY, 21 SEPTEMBER 2023 3
Practice - Queue
• See file QueueApp.java
• Practice: • Write a method to display the queue array and the front and rear indices. Understand how wraparound works. • Display the array, the queue, and the front and rear indices. • Insert fewer items or remove fewer items and investigate what happens when the queue is empty or full. • Extend the insert and remove methods to deal with a full and empty queue.
THURSDAY, 21 SEPTEMBER 2023 4
Practice – Priority Queue
• Look at file PriorityQApp.java
• Write a method to display the queue and use to trace the queue operation. • Modify the insert method to insert the new item at the rear.