Data Structure, second semester 2010

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 ds.cp.cu@gmail.com. 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:

  1. void multiAdd(Object e, int count). This method adds count copies of object e to the collection. The value of count is non-negative.

  2. int count(Object e). 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) Object get(int index) and 2) void set(int index, Object e). You also must change the declaration of int indexOf(Object element) 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:

  1. void append(List lst). This method appends members in l to our list

  2. void minus(List lst). This method removes from our list EVERY members that appear in l.

  3. void reverse(int start, int stop). 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 ds.cp.cu@gmail.com.

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 bool contain(Object e) 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:

Random rnd = new Random();
int value = rnd.nextInt(1000) + 1;

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 ds.cp.cu@gmail.com
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

File attachments: 

3 comments

by u51ejr on Tue, 26/10/2010 - 21:18

by look-in on Tue, 16/11/2010 - 00:17

อ. คะ ใน method int count(Object e, int count)

มี int count ไว้ใช้ทำอะไรคะ

by dae on Fri, 19/11/2010 - 10:01

ผมพิมพ์ผิดน่ะครับ มันต้องไม่มี count ครับ แก้ให้แล้วครับ ขอบคุณมากครับ

Syndicate

Subscribe to Syndicate
© 2014 Nattee Niparnan. Drupal theme by Kiwi Themes.