write an algorithm to mergr 2 arrays and get the result sorted in ascending order.and the sorted array must not contain duplicates
Answers
Answer:
please mark me as brainliest answer
Answer:
Explanation:
Algorithm for Merge:
START
We have to sort both the arrays.
If we haven't yet reached the base case, we again divide both these subarrays and try to sort them.
We have to make an array of the size equal to the sum of the size of the two given array.
Now, we have to initialize two pointers i and j with 0 ( i = 0, j = 0 )
i will iterate on 1st array and j will iterate on 2nd array
Compare array[i] with array[j] if both are equal
Then store the value of array[i] in the final array and increase the value of i and j by 1.
Else if array[i] is smaller then the array[j]
Then store array[i] in the final array and increase the value of i by 1.
Else
Store array[j] in the final array and increase the value of j by 1.
END