Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DATA STRUCTURES - MUST USE JAVA PROGRAMMING A palindrome is a word, phrase, or number which reads the same backward as it does being read

DATA STRUCTURES - MUST USE JAVA PROGRAMMING

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

A palindrome is a word, phrase, or number which reads the same backward as it does being read forwards. It does not matter if there are punctuations marks within the palindrome, these do not count and if they are present, the sequence of word will still fall under the category of the palindrone. Examples of palindrome include: MOM RADAR ROTATOR 721959127 STEP NOT ON PETS 100010001 Develop an application to check palindrome using both the generic stack and generic queue structures. You are required to start by filling up a generic stack with the word, phrase, or number. Display this process in your application. If the element count is an odd number, there is a possibility that the input is a palindrome. Remove the element in the middle of the generic stack. Display this process in your application. See Figure 1 for an illustration. [R] [A] [D] buang/remove [A] [R] Rajah 1: Membuang elemen di pertengahan timbunan generik Figure 1: Removing element in the middle of generic stack Next, prepare two generic queues, say A and B. Move the top element in the generic stack into A, then move the bottom element in the generic stack into B. Display this process in your application. Repeat the moving process until the generic stack becomes empty. See Figure 2 for an illustration. [R] Generic [A] Stack [A] [R] a a [R][A] Generic Queue A [R][A] Generic Queue B Rajah 2: Proses pemindahan elemen-elemen dari timbunan generik kepada kedua-dua baris-gilir generik. Figure 2: The process of moving elements from the generic stack to both generic queues. Finally, compare each elements in between A and B. If all the elements in A matches the elements in B, this means the input is a palindrome. In writing this program application, you are encouraged to give attention to a neat coding arrangement. Consider visualization to display the processes involved in this question for a full mark. Table 1 and 2 are attached as a reference to the commonly used method names and their specifications for the generic stack and generic queue. You are encouraged to implement other methods that are relevant to your application. Jadual 1: Senarai metod-metod dan spesifikasinya untuk timbunan generik Table 1: List of methods and their specifications for the generic stack Pembina/Nama Metod Constructor/Method name i) Constructor for the generic stack class ii) isEmpty iii) is Full Spesifikasi Specification Konstruktor lalai Default constructor Memulangkan sama ada timbunan generik tersebut adalah kosong atau tidak Return whether or not the generic stack is empty Memulangkan sama ada timbunan generik tersebut adalah penuh atau tidak Return whether or not the generic stack is full Memulangkan elemen teratas dalam timbunan generik tanpa membuangnya. Return the value of the top element in the generic stack without removing it iv) peek v) push vi) push Many Menambah elemen ke posisi teratas dalam timbunan generik Add element to the top of generic stack Menambah beberapa elemen ke dalam timbunan generik menggunakan koma sebagai pembatas Add several elements to the generic stack using comma as split delimiter Membuang elemen di posisi teratas dalam timbunan generik Remove element from the top of the generic stack Memaparkan kesemua elemen-elemen di dalam timbunan generik Display all elements in the generic stack vii) pop viii) display Jadual 2: Senarai metod-metod dan spesifikasinya untuk baris-gilir generik Table 2: List of methods and their specifications for the generic queue Pembina/Nama Metod Constructor/Method name i) Constructor for the generic queue class ii) isEmpty iii) isFull iv) peek Spesifikasi Specification Konstruktor lalai Default constructor Memulangkan sama ada baris-gilir generik tersebut adalah kosong atau tidak Return whether or not the generic queue is empty Memulangkan sama ada baris-gilir generik tersebut adalah penuh atau tidak Return whether or not the generic queue is full Memulangkan nilai bagi elemen pertama dalam baris-gilir generik tersebut Return the value of the first element in the generic queue Menambah elemen pada baris-gilir generik Add element to the generic queue Membuang elemen dari baris-gilir generik Remove element from the generic queue Memaparkan elemen-elemen di dalam baris- gilir generik Display all elements in the generic queue v) enqueue vi) dequeue vii) display No marks will be given for any implementation using the existing Stack class or any other Collection classes available from the Java API Library. A palindrome is a word, phrase, or number which reads the same backward as it does being read forwards. It does not matter if there are punctuations marks within the palindrome, these do not count and if they are present, the sequence of word will still fall under the category of the palindrone. Examples of palindrome include: MOM RADAR ROTATOR 721959127 STEP NOT ON PETS 100010001 Develop an application to check palindrome using both the generic stack and generic queue structures. You are required to start by filling up a generic stack with the word, phrase, or number. Display this process in your application. If the element count is an odd number, there is a possibility that the input is a palindrome. Remove the element in the middle of the generic stack. Display this process in your application. See Figure 1 for an illustration. [R] [A] [D] buang/remove [A] [R] Rajah 1: Membuang elemen di pertengahan timbunan generik Figure 1: Removing element in the middle of generic stack Next, prepare two generic queues, say A and B. Move the top element in the generic stack into A, then move the bottom element in the generic stack into B. Display this process in your application. Repeat the moving process until the generic stack becomes empty. See Figure 2 for an illustration. [R] Generic [A] Stack [A] [R] a a [R][A] Generic Queue A [R][A] Generic Queue B Rajah 2: Proses pemindahan elemen-elemen dari timbunan generik kepada kedua-dua baris-gilir generik. Figure 2: The process of moving elements from the generic stack to both generic queues. Finally, compare each elements in between A and B. If all the elements in A matches the elements in B, this means the input is a palindrome. In writing this program application, you are encouraged to give attention to a neat coding arrangement. Consider visualization to display the processes involved in this question for a full mark. Table 1 and 2 are attached as a reference to the commonly used method names and their specifications for the generic stack and generic queue. You are encouraged to implement other methods that are relevant to your application. Jadual 1: Senarai metod-metod dan spesifikasinya untuk timbunan generik Table 1: List of methods and their specifications for the generic stack Pembina/Nama Metod Constructor/Method name i) Constructor for the generic stack class ii) isEmpty iii) is Full Spesifikasi Specification Konstruktor lalai Default constructor Memulangkan sama ada timbunan generik tersebut adalah kosong atau tidak Return whether or not the generic stack is empty Memulangkan sama ada timbunan generik tersebut adalah penuh atau tidak Return whether or not the generic stack is full Memulangkan elemen teratas dalam timbunan generik tanpa membuangnya. Return the value of the top element in the generic stack without removing it iv) peek v) push vi) push Many Menambah elemen ke posisi teratas dalam timbunan generik Add element to the top of generic stack Menambah beberapa elemen ke dalam timbunan generik menggunakan koma sebagai pembatas Add several elements to the generic stack using comma as split delimiter Membuang elemen di posisi teratas dalam timbunan generik Remove element from the top of the generic stack Memaparkan kesemua elemen-elemen di dalam timbunan generik Display all elements in the generic stack vii) pop viii) display Jadual 2: Senarai metod-metod dan spesifikasinya untuk baris-gilir generik Table 2: List of methods and their specifications for the generic queue Pembina/Nama Metod Constructor/Method name i) Constructor for the generic queue class ii) isEmpty iii) isFull iv) peek Spesifikasi Specification Konstruktor lalai Default constructor Memulangkan sama ada baris-gilir generik tersebut adalah kosong atau tidak Return whether or not the generic queue is empty Memulangkan sama ada baris-gilir generik tersebut adalah penuh atau tidak Return whether or not the generic queue is full Memulangkan nilai bagi elemen pertama dalam baris-gilir generik tersebut Return the value of the first element in the generic queue Menambah elemen pada baris-gilir generik Add element to the generic queue Membuang elemen dari baris-gilir generik Remove element from the generic queue Memaparkan elemen-elemen di dalam baris- gilir generik Display all elements in the generic queue v) enqueue vi) dequeue vii) display No marks will be given for any implementation using the existing Stack class or any other Collection classes available from the Java API Library

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

Building The Data Warehouse

Authors: W. H. Inmon

4th Edition

0764599445, 978-0764599446

More Books

Students also viewed these Databases questions

Question

4-6 Is there a digital divide? If so, why does it matter?

Answered: 1 week ago