// TestMergeSort.java ปรับปรุง : 2548-06-08 () // เคล็ด : แยกครึ่ง และแยกเป็น biary tree แล้วก็หยิบสมาชิกแต่ละถึง มาจัดเรียงทีละตัว // โปรแกรมสำหรับ จัดเรียงข้อมูล แบบ Merge ซึ่งเหมาะกับ External Sort // แหล่งอ้างอิง // http://www.thaiall.com/class // http://ww3.algorithmdesign.net/handouts/MergeSort.pdf // http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html // http://www.cp.eng.chula.ac.th/%7Eu45dtn/mergesort/mergesort.htm (มีแต่ source กับ awt) // http://www.java2s.com/ExampleCode/Collections-Data-Structure/Sort-Search.htm // ปัญหาที่อาจพบ // ถ้า compile ทุกโปรแกรม แล้ว run ทีละโปรแกรม จะพบปัญหา SortingProcess ซ้ำกัน // แต่ถ้า compile และ run ทีละโปรแกรม จะไม่พบปัญหา เพราะปัญหาเกิดจาก SortingProcess ซ้ำกับในโปรแกรมอื่น // import java.lang.*; class SortingProcess { int temp,elems=0; Comparable ar[] = new Comparable[100]; public void insert(Comparable value) { ar[elems] = value; elems++; } public void printresult(String txt) { System.out.print(txt); for(int i=0;i