3. Merging two sorted arrays #
Created Wednesday 11 December 2019
- No waiting, step by step, do it in one go.
Algorithm
- Start i=0, j=0. Make an array of length n1 + n2.
- Run a while loop, with condition i<n1 and j<n2. Copy to the result array.
- When the loop exits, declare (p and t-size = of the unfinished array, i.e n1 or n2) assign it to the unfinished array.
- Run a while loop(t<n1 or n2){p++}, easy done. No need to count. t was needed for anchor, i.e from where to resume).
Traversal was done directly by using pointer.