Development of the exhibit in William's cell machine happens iteratively in the accompanying manner:    In the event that the component is dead and it has precisely 1 alive neighbor in the present status of the exhibit, then, at that point, on the following emphasis it will become alive. For a component

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 5SA
icon
Related questions
Question

Computer science. Correct answer will be upvoted else downvoted.

 

 

Development of the exhibit in William's cell machine happens iteratively in the accompanying manner: 

 

In the event that the component is dead and it has precisely 1 alive neighbor in the present status of the exhibit, then, at that point, on the following emphasis it will become alive. For a component at list I the neighbors would be components with files i−1 and i+1. In case there is no component at that list, it is viewed as a dead neighbor. 

 

William is a sympathetic individual so all alive components stay alive. 

 

Check the note area for instances of the advancement. 

 

You are given some underlying condition, everything being equal, and you really wanted to help William discover the condition of the cluster after m emphasess of advancement. 

 

Input 

 

Each test contains various experiments. The principal line contains the number of experiments t (1≤t≤103). Depiction of the experiments follows. 

 

The primary line of each experiment contains two integers n and m (2≤n≤103,1≤m≤109), which are the all out number of cells in the exhibit and the number of emphasess. 

 

The second line of each experiment contains a line of length n comprised of characters "0" and "1" and characterizes the underlying condition of the cluster. "1" signifies a cell is alive and "0" signifies it is dead. 

 

It is ensured that the amount of n over all experiments doesn't surpass 104. 

 

Output 

 

In each experiment output a line of length n, comprised of characters "0" and "1" — the condition of the exhibit after m cycles of development.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning