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
weqwewe [10]
3 years ago
8

"Given the input string "abcd", which permutations beginning with the character ‘d’ can be output using the same code fragment c

ombinations (e.g., cin/push, pop/cout) described previously? Why can only these permutations be produced?"
Computers and Technology
1 answer:
NISA [10]3 years ago
4 0

Answer:

For the given input string "abcd", the permutation with an output 'd' is given by "dcba".

Explanation:

This is because for a output strings to begin with 'd', we first need to input and push characters 'a','b','c' and 'd' to stack

cin >> ch; permuteStack.push(ch); // inputs and push 'a' into the stack

cin >> ch; permuteStack.push(ch); // inputs and push 'b' into the stack

cin >> ch; permuteStack.push(ch); // inputs and push 'c' into the stack

cin >> ch; permuteStack.push(ch); // inputs and push 'd' into the stack

Then we need to pop and display character 'd' from stack to console

ch = permuteStack.pop(); cout << ch; // pops and outputs 'd' to console

After popping 'd' from stack , we can only pop the characters in the order 'c','b' and 'a'. No other popping of characters can be done, because, we have taken all the inputs and only operation which can be performed is popping and displaying.

ch = permuteStack.pop(); cout << ch; // pops and outputs 'c' to console

ch = permuteStack.pop(); cout << ch; // pops and outputs 'b' to console

ch = permuteStack.pop(); cout << ch; // pops and outputs 'a' to console

So the only permutation which can be displayed starting with 'd' is "dcba"

You might be interested in
Write a program that repeatedly shows the user a menu to select the shape form three main shapes or to print the shapes created
fomenos

Answer:

Explanation:

The following code is written in Python. It creates a program that keeps printing out a menu allowing the user to create shapes. These shapes are saved in an array called shapes. Once the user decides to exit, it prints all of the shapes in the array along with their total area. The output can be seen in the attached picture below. Due to technical difficulties, I have added the code as a txt file below.

3 0
3 years ago
WILL GIVE BRAINLIEST!!!!!!!
denpristay [2]

Answer:

A drill is one of the most important tools a dentist can have. They run on pneumatic systems which gives the drill power and precision.

Explanation:

So, false

3 0
3 years ago
Read 2 more answers
What are the preset formulas in a spreadsheet called?
Oksanka [162]
They are called functions on a spreadsheet.
5 0
4 years ago
Read 2 more answers
Write an example method that overrides the operator to create a new book whose title is a concatenation of the titles of two boo
Anastasy [175]

next time m8 mmmmmdsaasd

5 0
3 years ago
To support an internet client, you must have six elements. the first three -- a computer, an operating system and tcp/ip -- are
UkoKoshka [18]
<span>Client software, Internet connection and Internet address</span>
6 0
3 years ago
Other questions:
  • 2. Suppose you want to write a method that prints a heading on a new output page, along with a page number that is 1 in the firs
    15·1 answer
  • What is a set of javascript statements that result in an action?
    15·1 answer
  • List the gcc command-line options for each of the following: Generate a .o file rather than an executable. Generate a .s (assemb
    6·1 answer
  • In the code snippet, what is the “win” part called in programming?
    12·1 answer
  • Pharming involves redirecting users to a fraudulent Web site even when the user has typed in the correct address in the Web brow
    7·1 answer
  • Can you please answer the question in the picture ! :)
    6·1 answer
  • Write a program that represents a popular kid’s toy that teaches them about different shapes and colors.
    14·1 answer
  • Atheel tests a program and gets a NameError. How can this be fixed?
    13·2 answers
  • What is system software?
    14·1 answer
  • Write a recursive, string-valued method, reverse, that accepts a string and returns a new string consisting of the original stri
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!