News
- Section list is here. Students must be in the listed section only. Please change your section according to this file.
Section 5
05 Nov 2553
Homework #1. Due 12 Nov 2553. You have to complete a class that can replace "ArrayList" used in this example. Submission must be sent as attachment via email to [email protected]. The subject of the email must be "[data] hw01 YOUR_ID". For example, if your ID is 5230000021 , the subject must be "[data] hw01 5230000021" without quote. Please include your name (in Thai) and ID in the body of the email as well.
12 Nov 2553
This is the basic version of ArrayCollection. In-class quiz is here
15 Nov 2553
Homework #2. Due 19 Nov 2553. Modify the class ArrayCollection, from [Aj. Somchai's package] to have these two methods:
-
[code lang="java]void multiAdd(Object e, int count)[/code]. This method adds count copies of object e to the collection. The value of count is non-negative.
-
[code lang="java]int count(Object e)[/code]. This method returns the number of elements in the collection that each equal to e.
You should check your class with this main.
17 Nov 2553
- Hereafter, for every lab, you must create a project named LabXX_DATE where XX is the number of lab (for 17 Nov, it's 6th lab) and DATE is the date of the lab. For example, today's should be named as Lab06_17Nov
- At the end of the semester, you have to submit the entire workspace as a final project.
- Today, we will use JUnit, please follow instructions given in section "การเตรียม Java Project ให้ใช้ JUnit" in this document.
- Task #1: Create a class ArrayList_rc1, by using ArrayCollection.java as a starting point. Remove the implements List and package dataStructure declaration and create two more methods: 1) [code lang="java]Object get(int index)[/code] and 2) [code lang="java]void set(int index, Object e)[/code]. You also must change the declaration of [code lang="java]int indexOf(Object element)[/code] from private to public.
- JUnit for Task #1 is available here
- Task #2: Create a class ArrayList_rc2, by using ArrayList_rc1 as a starting point and then add the remaining method of List into it.
- JUnit for Task #2 is available here
19 Nov 2553
Task 1
Create a class ArrayList_ex1 that has following methods:
-
[code lang="java"]void append(List lst)[/code]. This method appends members in l to our list
-
[code lang="java"]void minus(List lst)[/code]. This method removes from our list EVERY members that appear in l.
-
[code lang="java"]void reverse(int start, int stop)[/code]. Reverse the order of element from position start to stop. For example, calling reverse(3,5) on a list of {A,B,C,D,E,F,G} will change it into {A,B,C,F,E,D,G}.
Homework #3
Due 26 Nov. You must write a class ArrayCollectionByList, detailed in here. Send the file ArrayCollectionByList.java to [email protected].
24 Nov 2553 (Lab09_24Nov)
Task 1
Write a program, in a class Test01, that adds 1,000 numbers, randomly generated from the range of 1 to 1,000, into an ArrayCollection. After that, randomly call [code lang="java"]bool contain(Object e)[/code] for 1,000 times where e is randomly selected from the same range. Count the number of barometric instruction and report that number per each call of contain.
To get a random number in the range 1 to 1,000, use this code snippet: [code lang="java"] Random rnd = new Random(); int value = rnd.nextInt(1000) + 1; [/code]
Task 2
Do exactly the same thing as Task1 but use the range of 1 to 1,000,000 instead. Using class name as Test02
Task 3
Task 3 is the same as Task 1 but count the barometric instruction in "remove" instead.
Task 4
Task 4 is exactly the same as task 3 but use ArrayList instead of ArrayCollection
15 Dec 2553
Quiz 02 Please send answer as Email to [email protected] subject: [data] Quiz02 ID include a file named Quiz02_ID.txt
Given n integer having at most k digit, analyze the time complexity of Radix Sort. Just give the final asymptotic bound of the Radix Sort in your answer.
05 Jan 2554 (Lab16_05Jan)
Happy new year!!!
Task 1
Write a program in the class Sort01, that takes n int from keyboard and sort the given data and display it on the screen. The sorting should be done by selection sort that, instead of finding a max index and swap it with the last element, find the min index and swap with the first element.
Homework #4
Due 22 Jan 2011 Write a class ArrayUtilEx which extends the ArrayUtil. This class should contains two methods public static void bubbleSortEx(Object[] d) and public static void insertionSortEx(Object[] d). bubbleSortEx is the bubble sort that starts comparing from the last pair and works up until the first pair. insertionSortEx will tries to "insert" element from the last element to the sorted portion in the right. In other words, both new sorts work in reverse direction. However, it must still sort in ascending order (from min to max.)
27 Jan 2554 (Lab19_27Jan)
Task 1
Modify the class LinkedCollection such that when you add an object trough public void add(Object e), that object is appended to the end of the linked list.
29 Jan 2554 (Lab20_29Jan)
Task 1
Modify the class SinglyLinkedList by adding a method public void removeEvery(int k) that removes items (xk)-th items (which have indices of xk-1) from the list.
Submission of Code
All students of Section 5 must send their in-class work (your workspace with all LabXX_XXXX) to ds.cp.cu in zip format. The name of the file must be ID.zip where ID is your ID. The subject of the email must be "[data] workspace ID"
Attachment | Size |
---|---|
2110211-2553-b-section.pdf | 76.53 KB |
- Log in to post comments
…
อ. คะ ใน method int
ผมพิมพ์ผิดน่ะครับ