Relative Sorting
-
Relative Sorting Ramesh is given two arrays, arr1 and arr2. He wants to sort arr1 in such a way that the relative order of arr2 is maintained in arr1. For elements that are not present in arr2, he wants to add the these elements at the end of the array in sorted fashion. Can you help Ramesh achieve this task? Input Format First line contains two integers n and m denoting size of arrays arr1 and arr2 respectively. Second line contains n space separated integers denoting the array arr1. Third line contains m space separated integers denoting the array arr2. Output Format Print the relatively sorted arr1 Example 1 Input 11 4 2 1 2 5 7 1 9 3 6 8 8 2 1 8 3 Ramesh is given two arrays, arr1 and arr2. He wants to sort arr1 in such a way that the relative order of arr2 is maintained in arr1. For elements that are not present in arr2, he wants to add the these elements at the end of the array in sorted fashion. Can you help Ramesh achieve this task? Input Format First line contains two integers n and m denoting size of arrays arr1 and arr2 respectively. Second line contains n space separated integers denoting the array arr1. Third line contains m space separated integers denoting the array arr2. Output Format Print the relatively sorted arr1 Example 1 Input 11 4 2 1 2 5 7 1 9 3 6 8 8 2 1 8 3
-
Relative Sorting Ramesh is given two arrays, arr1 and arr2. He wants to sort arr1 in such a way that the relative order of arr2 is maintained in arr1. For elements that are not present in arr2, he wants to add the these elements at the end of the array in sorted fashion. Can you help Ramesh achieve this task? Input Format First line contains two integers n and m denoting size of arrays arr1 and arr2 respectively. Second line contains n space separated integers denoting the array arr1. Third line contains m space separated integers denoting the array arr2. Output Format Print the relatively sorted arr1 Example 1 Input 11 4 2 1 2 5 7 1 9 3 6 8 8 2 1 8 3 Ramesh is given two arrays, arr1 and arr2. He wants to sort arr1 in such a way that the relative order of arr2 is maintained in arr1. For elements that are not present in arr2, he wants to add the these elements at the end of the array in sorted fashion. Can you help Ramesh achieve this task? Input Format First line contains two integers n and m denoting size of arrays arr1 and arr2 respectively. Second line contains n space separated integers denoting the array arr1. Third line contains m space separated integers denoting the array arr2. Output Format Print the relatively sorted arr1 Example 1 Input 11 4 2 1 2 5 7 1 9 3 6 8 8 2 1 8 3
I can help Ramesh achieve these tasks, if Ramesh is willing to pay for someone to do Ramesh's homework for Ramesh. Alternatively, Ramesh could do some studying, and thinking, and do this all for himself.
-
Relative Sorting Ramesh is given two arrays, arr1 and arr2. He wants to sort arr1 in such a way that the relative order of arr2 is maintained in arr1. For elements that are not present in arr2, he wants to add the these elements at the end of the array in sorted fashion. Can you help Ramesh achieve this task? Input Format First line contains two integers n and m denoting size of arrays arr1 and arr2 respectively. Second line contains n space separated integers denoting the array arr1. Third line contains m space separated integers denoting the array arr2. Output Format Print the relatively sorted arr1 Example 1 Input 11 4 2 1 2 5 7 1 9 3 6 8 8 2 1 8 3 Ramesh is given two arrays, arr1 and arr2. He wants to sort arr1 in such a way that the relative order of arr2 is maintained in arr1. For elements that are not present in arr2, he wants to add the these elements at the end of the array in sorted fashion. Can you help Ramesh achieve this task? Input Format First line contains two integers n and m denoting size of arrays arr1 and arr2 respectively. Second line contains n space separated integers denoting the array arr1. Third line contains m space separated integers denoting the array arr2. Output Format Print the relatively sorted arr1 Example 1 Input 11 4 2 1 2 5 7 1 9 3 6 8 8 2 1 8 3
If this is a homework then:[Visual C++ General: Can you help me with my homework assignment?](https://forums.codeguru.com/showthread.php?366302-Visual-C-General-Can-you-help-me-with-my-homework-assignment&highlight=homework)
-
Relative Sorting Ramesh is given two arrays, arr1 and arr2. He wants to sort arr1 in such a way that the relative order of arr2 is maintained in arr1. For elements that are not present in arr2, he wants to add the these elements at the end of the array in sorted fashion. Can you help Ramesh achieve this task? Input Format First line contains two integers n and m denoting size of arrays arr1 and arr2 respectively. Second line contains n space separated integers denoting the array arr1. Third line contains m space separated integers denoting the array arr2. Output Format Print the relatively sorted arr1 Example 1 Input 11 4 2 1 2 5 7 1 9 3 6 8 8 2 1 8 3 Ramesh is given two arrays, arr1 and arr2. He wants to sort arr1 in such a way that the relative order of arr2 is maintained in arr1. For elements that are not present in arr2, he wants to add the these elements at the end of the array in sorted fashion. Can you help Ramesh achieve this task? Input Format First line contains two integers n and m denoting size of arrays arr1 and arr2 respectively. Second line contains n space separated integers denoting the array arr1. Third line contains m space separated integers denoting the array arr2. Output Format Print the relatively sorted arr1 Example 1 Input 11 4 2 1 2 5 7 1 9 3 6 8 8 2 1 8 3
You gave the input but you didnt gave the output ,,for us to undertand exactly what he wants. What does he mean with 'relative order'? 2 1 2 5 7 1 9 3 6 8 8 will become 1,1,2,2,3,5,6,7,8,8,9 But i dont undertand what we want arr2 to become...so to help as i am resting in summer.
-
Relative Sorting Ramesh is given two arrays, arr1 and arr2. He wants to sort arr1 in such a way that the relative order of arr2 is maintained in arr1. For elements that are not present in arr2, he wants to add the these elements at the end of the array in sorted fashion. Can you help Ramesh achieve this task? Input Format First line contains two integers n and m denoting size of arrays arr1 and arr2 respectively. Second line contains n space separated integers denoting the array arr1. Third line contains m space separated integers denoting the array arr2. Output Format Print the relatively sorted arr1 Example 1 Input 11 4 2 1 2 5 7 1 9 3 6 8 8 2 1 8 3 Ramesh is given two arrays, arr1 and arr2. He wants to sort arr1 in such a way that the relative order of arr2 is maintained in arr1. For elements that are not present in arr2, he wants to add the these elements at the end of the array in sorted fashion. Can you help Ramesh achieve this task? Input Format First line contains two integers n and m denoting size of arrays arr1 and arr2 respectively. Second line contains n space separated integers denoting the array arr1. Third line contains m space separated integers denoting the array arr2. Output Format Print the relatively sorted arr1 Example 1 Input 11 4 2 1 2 5 7 1 9 3 6 8 8 2 1 8 3
So,,, even if he mean that 2 must be first ,1 second ,8 3rd and 3 4th,,, then lets see steps from input 2 1 2 5 7 1 9 3 6 8 8 arr2[2 1 8 3] 2 ->[2] 1->[2,1] because 1 is after 2 in arr2 2->[2,2,1] or [2,1] depends if he wants/accept same that also didnt clarified. 5->[2,2,1,5] and now arr2->[21835] but if this is the case what will happen if after 5 come 0? will again start from beginning?..because say " add the these elements at the end of the array in sorted fashion" 'Sorted fashion' here mean sorted only for NEW numbers like ar2[21835]->ar2[218305] ???