Complete the method SelectionSort in the file Sorting.java. Print out the sequence when there is a change in the sequence. Note that the methods swap, printArray and findIndexSmallest are provided.
เปิดโจทย์และวิธีทำ Exercise 1
Exercise 2InsertionSort
Complete the method InsertionSort in the file Sorting.java. Print out the sequence when there is a change in the sequence. Note that the method swap is provided.
Complete the method RecursiveMergeSort in the file Sorting.java. Call RecursiveMergeSort for leftHalf, rightHalf, and merge them. Note the method merge is provided.
จุดที่พลาดกันบ่อยleftHalf กับ rightHalf เป็นอาเรย์ใหม่คนละก้อนกับ A ถ้าเรียกตัวเองแล้วไม่ merge กลับเข้า A ผลที่เรียงแล้วจะหายไปกับก้อนชั่วคราว · และดัชนีของก้อนขวาเยื้องอยู่ ต้องเขียน rightHalf[i - midIndex] ครับ
Exercise 4RecursiveQuickSort
Complete the method RecursiveQuickSort in the file Sorting.java. Call itself for sorting the leftHalf and the rightHalf.
เปิดโจทย์และวิธีทำ Exercise 4
คำว่า end สองความหมายในไฟล์เดียวกันใน RecursiveQuickSort ตัว end คือช่องสุดท้ายที่รวมอยู่ด้วย (เพราะบรรทัด int pivot = A[end]; ต้องหยิบค่ามาได้) แต่ใน findIndexSmallest ตัว end คือช่องที่ไม่รวม (ลูปข้างในเป็น j < end) จึงต้องส่ง A.length ไม่ใช่ A.length - 1 ครับ
Complete the method fillHashTable. Step1: Find an original address according to the Hash function. Step2: check collision. if collision, find an open address.
เปิดโจทย์และวิธีทำ Exercise 5 a
Exercise 5 b & csearch และ delete
Complete the method Search. Searching for a key is similar to filling in data to Hash. Most code can be cut and pasted from the method fillHashTable. · Complete the method delete to delete a key from the hash table.