Related Questions
- I Want Help With Coding Questions In C++
- Urgent Data Structures Term Paper Help
- Understanding The Basics Of Computer Science Principles Essay Writing Assignment
- Assignment On Principles Of Computer Science
- Which Characteristics Support A Sustainable Mis Infrastructure?
- Project For Ist - Computer Science Assignment Website Design 5 Pages
- Comptia Security+ Exam
- Networking Using Packet Tracer
- I Need Help With A Wireshark Assignment
- Can You Do Both My Comptia A+ For Me
- What Is An Algorithm In Computer Science?
- Can You Log Into My College And Do My Ucertify Labs For Each Week And Take My Final Exam?
- Which One Is True For Sprint Planning? The Work To Be Performed In The Sprint Is Planned
- The Cyberapolis Water Company Has Been Taken Over By The Carbon Spector Terrorist Organization
- Hacking Assignment- Gain Access To Admin Credentials
Popular Services
- Coursework writing help
- Term paper writing help
- Writing Help
- Paper Writing Help
- Research paper help
- Thesis Help
- Dissertation Help
- Case study writing service
- Capstone Project Writing Help
- Lab report Writing
- Take my online class
- Take my online exam
- Do my test for me
- Do my homework for me
- Do my math homework for me
- Online Assignment Help
- Do my assignment for me
- Essay Writing Help
- Write my college essay
- Write my essay for me
Post your project now for free and watch professional homework help answers experts outbid each other in just a few minutes.
Question: Write A Program In C++ To Determine If Numbers Are Palindromes Using A Stack-Based Method For Testing.
Asked
Modified
Viewed
59
Objective: Write a program to determine if numbers are palindromes using a stack-based
method for testing.
Program Description:
Write a program that determines if a number is a palindrome. Recall that palindromes are
strings (sequences of characters) that read the same forward or backward after punctuation
and spacing is removed.
The stack sample code that we discussed in class is a good starting point for this assignment. Note that the stack you will need to use is character-based. Consider converting the
integer stack code to characters.
Requirements:
In addition to the functional description above, your solution also:
• Must have the stack implemented as a linked list (class optional). You may use
(extend) any code covered in lecture. You may not use the STL (Standard Template
Library).
• Must have the logic/implementation in a separate file from the stack implementation
(an application file).
• Must organize the source code files in accordance with the class standards. In other
words, separate class declaration files (ADT header file), class implementation files
(ADT implementation file), and application file.
More Instructions
/* link.cpp
*
* Class for a sorted linked list of integers.
*/
#ifdef NOT_USING_CC_WHATEVER_ITS_PREDEF_IS
#include <bool.h>
#endif
#include <iostream.h>
#include "link.h"
// Add an item to the FRONT of the list
void LinkedList::AddNode( int x )
{
nodeptr n;
// allocate new node
n = new node;
n->info = x;
count++;
if( start == NULL )
{
start = n;
n->next = NULL;
}
else
{
nodeptr tmp = start;
n->next = tmp;
start = n;
}
}
//\end{verbatim} \lecpb \begin{verbatim}
void LinkedList::DeleteNode( int x )
{
nodeptr prev, curr;
curr = start;
while( curr != NULL && x > curr->info )
{
prev = curr;
curr = curr->next;
}
if( x == curr->info )
{
if( curr == start )
start = start->next;
else
prev->next = curr->next;
delete curr;
count--;
}
}
//\end{verbatim} \lecpb \begin{verbatim}
int LinkedList::FirstNode()
{
return start->info;
}
void LinkedList::PrintNodes()
{
nodeptr p = start;
while( p != NULL )
{
cout << p->info << endl;
p = p->next;
}
}
//\end{verbatim} \lecpb \begin{verbatim}
#ifdef NOT_USING_CC_WHATEVER_ITS_PREDEF_IS
bool LinkedList::IsInList(int x)
#else
int LinkedList::IsInList(int x)
#endif
{
nodeptr p = start;
while( p != NULL && x > p->info )
p = p->next;
return (x == p->info);
}
int LinkedList::Size()
{
return count;
}
/* link.h
*/
// This is a class for a linked list of integers.
#ifndef LINK_H
#define LINK_H
#ifdef NOT_USING_CC_WHATEVER_ITS_PREDEF_IS
#include <bool.h>
#endif
#include <iostream.h>
class LinkedList
{
private:
struct node
{
int info;
node * next;
};
typedef node * nodeptr;
nodeptr start;
int count;
//\end{verbatim} \lecpb \begin{verbatim}
public:
// Constructor
LinkedList()
{
start = NULL;
count = 0;
}
// Destructor
~LinkedList()
{
nodeptr p = start, n;
while (p != NULL)
{
n = p;
p = p->next;
delete n;
}
}
// Add a node onto the front of the linked list.
void AddNode(int x);
// Delete the first node found with the value x, if one exists.
void DeleteNode(int x);
// Return the first node found in the list
int FirstNode();
// Output the values in the nodes, one integer per line.
void PrintNodes();
// Return true if there in a node in the list with the value x.
//bool IsInList(int x);
int IsInList(int x);
// Return a count of the number of nodes in the list.
int Size();
};
#endif
Answers
0
No answers posted
Post your Answer - free or at a fee
Ask a question for free and get answers to get Computer Science assignment help with a similar task to this question.