Prove that the first list contains numbers from k to 2k and second list contains numbers from 1 to k

Taniyah Estrada

Taniyah Estrada

Answered question

2022-06-12

Prove that the first list contains numbers from k to 2k and second list contains numbers from 1 to k.
There are two lists that contain integers from 1 to 2k such that the first list contains k randomly chosen integers from the range 1 - 2k and the second list contains the remaining numbers.
For Example: A = 8 , 6 , 13 , 14 , 4 , 11 , 12 and B = 1 , 2 , 3 , 5 , 7 , 9 , 10 when k = 7.
Now arrange the first list such that it is in ascending order and the second list such that it is in descending order.Same Example: A = 4 , 6 , 8 , 11 , 12 , 13 , 14 and B = 10 , 9 , 7 , 5 , 3 , 2 , 1 .
Now check the elements in the same position in both lists and make a swap such that the first list contains the greater number while the second list contains the smaller number.
Same Example: A = 10 , 9 , 8 , 11 , 12 , 13 , 14 and B = 1 , 6 , 7 , 5 , 3 , 2 , 1 .
Prove that the first list contains numbers from k to 2k and second list contains numbers from 1 to k.
It will be really helpful if I can get some directions on how to do this question because a similar question of sort was asked but I don't think that the answer to that question was similar.
I have tried it several times and looked for any similar problem but couldn't find them. I know this might be very obvious but please help me out and If there is a similar problem with the solution I would be interested about reading up on it. Thanks.

Answer & Explanation

svirajueh

svirajueh

Beginner2022-06-13Added 29 answers

Step 1
Hint: Take your example. Once A and B are sorted (but before the swapping is done), they have this overall structure:
A = { ( 7 ) , ( 7 ) , ( > 7 ) , ( > 7 ) , ( > 7 ) , ( > 7 ) , ( > 7 ) } , B = { ( > 7 ) , ( > 7 ) , ( 7 ) , ( 7 ) , ( 7 ) , ( 7 ) , ( 7 ) } .
Step 2
The thing to note is that they both start with the same number of elements (in this case 2 elements) that belong in the other set and will be swapped, and after that all elements (i.e. element number 3 on onwards) are already in their proper place and will not be swapped.
Try to generalise this.

Do you have a similar question?

Recalculate according to your conditions!

New Questions in Discrete math

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?