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
Potential Energy and Kinetic Energy both mean "energy in motion" True or False​
Irina18 [472]

Answer:

false

Explanation:

pretty sure energy in motion is only for kinetic energy

4 0
3 years ago
Read 2 more answers
Three primary types of data that a forensic investigator must collect, in this order: 1.Volatile data 2.Temporary data 3.Persist
posledela

Answer:

1. volatile data

2. temporary data

3. persistent data

seems like you already got it correct

Explanation:

7 0
2 years ago
Consider the following import statement in Python, where statsmodels module is called in order to use the proportions_ztest meth
den301095 [7]

Answer:

a. count of observations that meet a condition (counts), total number of observations (nobs), Hypothesized value of population proportion (value).

Explanation:

In other to use the proportion_ztest method, the need to make import from the statsmodel module ; statsmodels.stats.proportion.proportions_ztest ; this will allow use use the Z test for proportion and once this method is called it will require the following arguments (count, nobs, value=None, alternative='two-sided', prop_var=False)

Where;

nobs = number of observations

count = number of successes in the nobs trial or the number of successes for each independent sample.

Value = hypothesized value of the population proportion.

7 0
3 years ago
Two electronics technicians are measuring electrical quantities in circuits. Technician A says that copper, glass, porcelain, an
OleMash [197]

The correct answer is A. Only technician B is correct because I don't believe carbon is form of resistors.


8 0
3 years ago
Read 2 more answers
Respond to the following in three to five sentences. Select one netiquette guideline. Explain how this helps you draft more effe
slamgirl [31]

Answer:

Keeping as few emoji's as possible. This helps because lots of emoji's can make things confusing and/or annoying. This just means being kind to the person you're messaging and not making things confusing.

8 0
3 years ago
Other questions:
  • Suppose you send data to the 11111111 11111111 11111111 11111111 ip address on an ipv4 network. to which device(s) are you trans
    15·1 answer
  • When did the silver market drop sharply, hurting Bolivia's income?
    7·2 answers
  • Select the correct answer. Which sentence best describe an effective management strategy? A. Conceal game-related clippings prio
    12·2 answers
  • How do ethics affect people?
    15·1 answer
  • When you minimize a file, folder, or window it is placed on the
    10·1 answer
  • What is the post condition of an expression or variable
    11·1 answer
  • On a Linux system, which command allows you to modify settings used by the built-in packet filtering firewall?
    15·1 answer
  • A user reports that nothing happens when he or she attempts to print from the computer at his desk. This points to a possible pr
    15·1 answer
  • When creating envelopes, how will you adjust the layout?
    10·2 answers
  • ( BRAINLIEST) <br> Name 2 input devices and 2 output devices on a smart phone.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!