Algorithm for Merging two sorted arrays
Algorithm Merge Input // A, B, N, M// i<--1 j<--1 k<--1 while (i<=N and j<=M) do if A[i] < B[j] then C[k] <-- A[i] i <-- i + 1 else C[k] <-- B[j] j <-- j + 1 end_if k <-- k + 1 end_while Copy the remaining array elements Output // C // End Merge
Your browser does not support the
<canvas>
-element. Please think about updating your browser!
Run
Step
Pause
Stop
Speed
Insert Array Elements
Array A =
Array B =
Insert