You have an arrangement a with n components 1,2,3,… ,k−1,k,k−1,k−2,… ,k−(n−k) (k≤n<2k).    How about we call as reversal in a couple of files ia[j].    Assume, you have some change p of size k and you assemble an arrangement b of size n in the accompanying way: b[i]=p[a[i]].

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.

 

 You have an arrangement a with n components 1,2,3,… ,k−1,k,k−1,k−2,… ,k−(n−k) (k≤n<2k). 

 

How about we call as reversal in a couple of files i<j to such an extent that a[i]>a[j]. 

 

Assume, you have some change p of size k and you assemble an arrangement b of size n in the accompanying way: b[i]=p[a[i]]. 

 

You will probably find such change p that the absolute number of reversals in b doesn't surpass the all out number of reversals in a, and b is lexicographically greatest. 

 

Little update: the grouping of k integers is known as a stage in the event that it contains all integers from 1 to k precisely once. 

 

Another little update: a grouping s is lexicographically more modest than another succession t, if either s is a prefix of t, or for the primary I to such an extent that si≠ti, si<ti holds (in the principal position that these arrangements are unique, s has more modest number than t). 

 

Input 

 

The principal line contains a solitary integer t (1≤t≤1000) — the number of experiments. 

 

The solitary line of each experiment contains two integers n and k (k≤n<2k; 1≤k≤105) — the length of the arrangement an and its most extreme. 

 

It's dependable that the all out amount of k over experiments doesn't surpass 105. 

 

Output 

 

For each experiment, print k integers — the stage p which augments b lexicographically without expanding the complete number of reversals. 

 

It tends to be demonstrated that p exists and is novel.

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Hash Table
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
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