1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
V125BC [204]
3 years ago
5

Write a program that reads a string of characters, pushing each character onto a stack as it is read and simultaneously adding i

t to a queue. When the end of the string is encountered the program should use basic stack and queue operations to determine if the word is a palindrome.
Computers and Technology
1 answer:
sleet_krkn [62]3 years ago
4 0

Answer:

#include <iostream>

#include <stack>

#include <queue>

#include <string>

int main()

{

   while ( true )

   {

       std::string letters;

       std::cout << "Please enter a word (Enter - exit): ";

       std::getline( std::cin, letters );

       if ( letters.empty() ) break;

       std::stack<char>

           s( std::stack<char>::container_type( letters.begin(), letters.end() ) );

       std::queue<char>

           q( std::queue<char>::container_type( letters.begin(), letters.end() ) );

       while ( !s.empty() && s.top() == q.front() )

       {

           s.pop();

           q.pop();

       }

if ( s.empty() ) std::cout << "The word is a palindrome" << std::endl;

       else std::cout << "The word is not a palindrome" << std::endl;

   }

   return 0;

}

Explanation:

A <em>stack</em> is used to replicate a stack data structure in C++  while <em>Queue </em>container is a replica of the queue data structure in C++, Unlike stack, in the queue container, there are two ends, i.e. front, and back.

In the code above to be able to use used stack and queue, we included the headers #include <stack> and#include <queue>.

You might be interested in
) A stub network has ______. (Points : 2) one backup route
jeyben [28]

Answer: One backup router

Explanation:

 A stub network is the type of the packet network that basically describe the computer notwork. It typically capable for sending the complex data in the single network path when the network aware about its destination.

A stub network contain the one backup router as the stub routing is the typically designed for conserve the resources of the local router like the central processing unit (CPU) and the memory. It basically improve the stability of the network in the system.

6 0
3 years ago
In computing, what does Bcc mean. The topic in which this is found is HOW TO CREATE AN E MAIL ACCOUNT ​
galina1969 [7]

Answer:

BCC stands for "blind carbon copy."

3 0
3 years ago
Read 2 more answers
What is the command for opening a spreadsheet object in a separate spreadsheet window
zavuch27 [327]
I had that problem all the time. do this:
right click on the excel icon on the computer and click for a new excel sheet

go to file and open
find the excel sheet
and now you have 2 sheets open
6 0
3 years ago
Read 2 more answers
The length of a rectangle is 6cm and its perimeter is 20 cm . find its breadth​
Natali [406]

Answer:

4 cm

Explanation:

Width you mean?

The perimeter of a rectangle is 2*length+2*width, so

2*6+2w=20

12+2w=20

2w=8

w=4

The width is 4 cm.

5 0
3 years ago
in demand paging, the collection of pages residing in memory that can be accessed directly without incurring a page fault is cal
slava [35]

In demand paging, the collection of pages residing in memory that can be accessed directly without incurring a page fault is called the working set.

<h3>What does demand paging mean?</h3>

Demand paging is the process of moving data from secondary storage to RAM as needed. This means that not all data is stored in main memory due to limited RAM space. So when the CPU requests a process when its page is not in RAM, it needs swapping.

<h3>What is demand paging and its benefits?</h3>

Request paging instead of loading all pages at once.Only load pages requested by running processes. With more space in main memory, more processes can be loaded, reducing resource-intensive context switch times.

Learn more about demand paging:

brainly.com/question/28902146

#SPJ4

3 0
1 year ago
Other questions:
  • Format Painter cannot be used to copy only character attributes. True or False
    12·1 answer
  • Do you think Google has an unfair advantage as a social media marketing platform? Explain.
    10·2 answers
  • Which of the following is not a job title associated with a career in visual and audio technology? master control operator produ
    9·1 answer
  • i will be doing an interview to someone so plz comment down below something random and you will automatically enter
    11·1 answer
  • The concept of a process in an operating system embodies two primary characteristics, one of which is:
    15·1 answer
  • Int [] val = { 3, 10, 44 };
    12·1 answer
  • The method needed to arrange for an object to be notified when a window's close-window button has been clicked is
    6·1 answer
  • Find out the names of at least 20 programming languages and their developers.
    12·2 answers
  • Which of the following is NOT an algorithm?
    15·1 answer
  • QUESTION 11
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!