Homer has two companions Alice and Bob. The two of them are string fans.    At some point, Alice and Bob choose to play a game on a string s=s1s2… sn of length n comprising of lowercase English letters. They move in turns on the other hand and Alice takes the primary action.    In a move, a player should

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Correct answer will be upvoted else downvoted. Computer science.

 

 Homer has two companions Alice and Bob. The two of them are string fans. 

 

At some point, Alice and Bob choose to play a game on a string s=s1s2… sn of length n comprising of lowercase English letters. They move in turns on the other hand and Alice takes the primary action. 

 

In a move, a player should pick a file I (1≤i≤n) that has not been picked previously, and change si to some other lowercase English letter c that c≠si. 

 

At the point when all files have been picked, the game closures. 

 

The objective of Alice is to make the last string lexicographically as little as could really be expected, while the objective of Bob is to make the last string lexicographically as extensive as could be expected. The two of them are down specialists, so they generally mess around ideally. Homer is certainly not a game master, so he thinks about what the last string will be. 

 

A string an is lexicographically more modest than a string b if and provided that one of the accompanying holds: 

 

a will be a prefix of b, however a≠b; 

 

in the main position where an and b contrast, the string a has a letter that shows up prior in the letters in order than the comparing letter in b. 

 

Input 

 

Each test contains different experiments. The main line contains t (1≤t≤1000) — the number of experiments. Depiction of the experiments follows. 

 

The main line of each experiment contains a solitary string s (1≤|s|≤50) comprising of lowercase English letters. 

 

Output 

 

For each experiment, print the last string in a solitary line.

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Topological Sort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education