Docsity

merge sort algorithm explianed, Lecture notes of Algorithms and Programming

Partial preview of the text

Download merge sort algorithm explianed and more Lecture notes Algorithms and Programming in PDF only on Docsity!

MERGE(A, p, g,r) nm <—q-—ptl nz <-r—@q create arrays L[1..n, + 1] and R[1..n2+ 1) fori < 1ton, do L{i] < A[p+i-1] for j < ltong do R[j] — Alg+ J] L[n, + 1) < co R[nz +1) < co 10 i<1 ll jl 12 fork — ptor 13 do if L[i] < R[j] 14 then A[k] <— L[f] 15 i