And here's the output for SIZE 19. Notice the nice tree structure of the
log messages, based on the depth of the recursion.
~~~~
sort (0-19)[0 711 910 912 58 954 63 122 28 668 501 616 496 791 944 902 757 604 91]
sort (0-9)[0 711 910 912 58 954 63 122 28]
sort (0-4)[0 711 910 912]
sort (0-2)[0 711]
sort (0-1)[0]
sort (1-2)[711]
merge (0-2)[0 711]
sort (2-4)[910 912]
sort (2-3)[910]
sort (3-4)[912]
merge (2-4)[910 912]
merge (0-4)[0 711 910 912]
sort (4-9)[58 954 63 122 28]
sort (4-6)[58 954]
sort (4-5)[58]
sort (5-6)[954]
merge (4-6)[58 954]
sort (6-9)[63 122 28]
sort (6-7)[63]
sort (7-9)[122 28]
sort (7-8)[122]
sort (8-9)[28]
merge (7-9)[28 122]
merge (6-9)[28 63 122]
merge (4-9)[28 58 63 122 954]
merge (0-9)[0 28 58 63 122 711 910 912 954]
sort (9-19)[668 501 616 496 791 944 902 757 604 91]
sort (9-14)[668 501 616 496 791]
sort (9-11)[668 501]
sort (9-10)[668]
sort (10-11)[501]
merge (9-11)[501 668]
sort (11-14)[616 496 791]
sort (11-12)[616]
sort (12-14)[496 791]
sort (12-13)[496]
sort (13-14)[791]
merge (12-14)[496 791]
merge (11-14)[496 616 791]
merge (9-14)[496 501 616 668 791]
sort (14-19)[944 902 757 604 91]
sort (14-16)[944 902]
sort (14-15)[944]
sort (15-16)[902]
merge (14-16)[902 944]
sort (16-19)[757 604 91]
sort (16-17)[757]
sort (17-19)[604 91]
sort (17-18)[604]
sort (18-19)[91]
merge (17-19)[91 604]
merge (16-19)[91 604 757]
merge (14-19)[91 604 757 902 944]
merge (9-19)[91 496 501 604 616 668 757 791 902 944]
merge (0-19)[0 28 58 63 91 122 496 501 604 616 668 711 757 791 902 910 912 944 954]
RESULT: (0-19)[0 28 58 63 91 122 496 501 604 616 668 711 757 791 902 910 912 944 954]
~~~~
--=-=-=
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
1.0, user-scalable=3Dyes">
Ruben Safir ruben-at-mrbrklyn.com=
writes:
An array slice is an interesting thought.
I can=E2=80=99t believe you =E2=80=98inspired=E2=80=99 me to spend a cou=
ple hours coding C++. But merge sort is really fun I guess, and I liked my =
slice idea. See code at 62d84642ae08197b4d229eb" class=3D"uri">https://gist.github.com/league/ce470=
244962d84642ae08197b4d229eb
And here=E2=80=99s the output for SIZE 19. Notice the nice tree structur=
e of the log messages, based on the depth of the recursion.
sort (0-19)[0 711 910 912 58 954 63 122 28 668 501 616 496 791 9=
44 902 757 604 91]
sort (0-9)[0 711 910 912 58 954 63 122 28]
sort (0-4)[0 711 910 912]
sort (0-2)[0 711]
sort (0-1)[0]
sort (1-2)[711]
merge (0-2)[0 711]
sort (2-4)[910 912]
sort (2-3)[910]
sort (3-4)[912]
merge (2-4)[910 912]
merge (0-4)[0 711 910 912]
sort (4-9)[58 954 63 122 28]
sort (4-6)[58 954]
sort (4-5)[58]
sort (5-6)[954]
merge (4-6)[58 954]
sort (6-9)[63 122 28]
sort (6-7)[63]
sort (7-9)[122 28]
sort (7-8)[122]
sort (8-9)[28]
merge (7-9)[28 122]
merge (6-9)[28 63 122]
merge (4-9)[28 58 63 122 954]
merge (0-9)[0 28 58 63 122 711 910 912 954]
sort (9-19)[668 501 616 496 791 944 902 757 604 91]
sort (9-14)[668 501 616 496 791]
sort (9-11)[668 501]
sort (9-10)[668]
sort (10-11)[501]
merge (9-11)[501 668]
sort (11-14)[616 496 791]
sort (11-12)[616]
sort (12-14)[496 791]
sort (12-13)[496]
sort (13-14)[791]
merge (12-14)[496 791]
merge (11-14)[496 616 791]
merge (9-14)[496 501 616 668 791]
sort (14-19)[944 902 757 604 91]
sort (14-16)[944 902]
sort (14-15)[944]
sort (15-16)[902]
merge (14-16)[902 944]
sort (16-19)[757 604 91]
sort (16-17)[757]
sort (17-19)[604 91]
sort (17-18)[604]
sort (18-19)[91]
merge (17-19)[91 604]
merge (16-19)[91 604 757]
merge (14-19)[91 604 757 902 944]
merge (9-19)[91 496 501 604 616 668 757 791 902 944]
merge (0-19)[0 28 58 63 91 122 496 501 604 616 668 711 757 791 902 910 912 =
944 954]
RESULT: (0-19)[0 28 58 63 91 122 496 501 604 616 668 711 757 791 902 910 91=
2 944 954]
--=-=-=--
--===============0308526433==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Learn mailing list
Learn-at-nylxs.com
http://lists.mrbrklyn.com/mailman/listinfo/learn
--===============0308526433==--