Advertisement
What_Ever

Untitled

Dec 30th, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. //Merging A and B
  2. left = right = counter = 0
  3. i = 0
  4. while left < length(A) && right < length(B)
  5. if A[left] > B[right]:
  6. C[counter] = B[right]
  7. counter = counter + 1
  8. right = right + 1
  9. end if
  10. else:
  11. C[counter] = B[right]
  12. counter = counter + 1
  13. right = right + 1
  14. end else
  15. end for
  16. if left < length(A)
  17. while left < length(A)
  18. C[counter] = A[left]
  19. left = left + 1
  20. counter = counter + 1
  21. end while
  22. end if
  23. if right < length(B)
  24. while right < length(B)
  25. C[counter] = B[right]
  26. right = right + 1
  27. counter = counter + 1
  28. end while
  29. end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement