-
|
Home | Syllabus | Course Outline | Homework | Lecture Notes | Tests | Programs | Contact | |
CSC 311- 01 Data Structures Spring 2015 |
|
Programming Project # 1
(Credit 0 - 10 pts) Experimenting with running time Here is a link http://csc.csudh.edu/suchenek/CSC311/HWProgs/FibbonaciHW.java to a program that for each integer n ranging from 1 to 1024 computes the value of this recursive function F(n): public static int F(int n) { count++; if (n == 0) return 1; if (n%10 == 0) return (F(n/2) + F(n/5)); else if (n%6 == 0) return(F(n/2) + F(n/3)); else return(F(n/3) + F(n/5)); } where k/m
denotes the
integer division (for example, 11/2 = 5, 10/2 = 5, 10/3 = 3, 9/3 = 3,
etc.), and k%m is the remainder of integer division k/m (for example,
11%2 = 1, 10%2 = 0, 11%3 = 2, 10%3 = 1, etc.),
and counts its own worst-case running time measured by the number of calls to function F. Your assignment is to convert the said program onto a complete and running (under NetBeans 8) program that for every size of integer n ranging from 1 to 10 computes and outputs the worst-case running time T(n) (measured by the number of calls to function F) of F. Requirements: 1.
The resulting program
must be 100% your own work (given the program
linked above) with no collaboration/help of any kind with others.
2. The size of input n is the number of bits needed for representation of the value of n, excluding any leading zeros. (Hint: the size of n = (int)Math.floor(Math.log(n)/Math.log(2))+1 3. The actual running time of the program is measured by counter count that counts the number of times that the function F is called. 4. The program must print its own worst-case running time T(size) as a function of the size of input (NOT of the input n itself) together with the actual numeric value of T(size). (Hint: If different inputs n of the same size result in different number of calls to method F then the maximum of the number of said calls yields the value of T(size).) 5. The only methods that your program is allowed to use are those that you have coded yourself and those in java.lang.Math. You should also resolve any technical/implementational issues that arise while completing this project. What to turn in:
Worst-case running time T(4) = 15
Past due Due date: February 17, 2015, by 4 PM. |
Programming Project # 2
(Credit 0 - 10 pts) Unsorted Insert List implementation of Priority Queue Rewrite implementation of priority queue given in class PriorityQueueL.java with List defined as private int count; private List itemList; (see List.java), so that it uses this unsorted, non-recursive metod insert (it is mandatory thet you use this code with no modifications) public void insert(int newItem) { cnt.incr(); List N = new List(); N.head=newItem; N.tail=itemList; itemList=N; count++; } and appropriately modified remove() method (you are supposed to write it by yourself) that removes the largest element from the priority queue passed to it as the implicit argument. You may need to implement a method that finds the largest element in a List defined above, first. After the above modifications, your class PriorityQueueL.java must work as needed when invoked by the sorting method included in class PriorityQueueTestL.java. In particular, both the sorting and the values of T(n) must be correct. You are supposed to add to your program any other classes (for instance, cnt.java) that might be necessary; you may re-use them from previous projects if appropriate. You may use and modify source code posted on class website on page Programs, but you must not use any source code from any other source (e.g., from the Internet, discussion groups, libraries, repositories, etc.). Bonus: If you think
you are really good
at programming then you may try to implement the method remove() by means of recursion.
Although it is a bit more challenging task, it leads to a simpler code
that is easier to troubleshoot. If you do it right then I will add
50% to your score for this assignment. Since in such a case
there is no need for any while-
or for-loops
in class PriorityQueueL.java, class cnt.java must just count the number of
calls to methods in PriorityQueueL.java class and not the number of times the
bodies of the innermost loops
were traversed.
Requirements: 1. The resulting program
must be 100% your own work (given the source code
linked above) with no collaboration (or help) of any kind with (or from) others.
2. The size of input is the number N of elements of the sorted array. 3. The actual running time of the program is measured by class cnt.java that counts the number of times that the body of the innermost loop in each method (if given method has a loop) is executed plus the number of times that each method in class PriorityQueueL.java is called. 4. The only methods that your program is allowed to use are those that you have coded yourself, those posted ahere and on page Programs, and those in java.lang.Math. You should also resolve any technical/implementational issues that arise while completing this project. What to turn in:
Due date: March 12, 2015, by 4 PM. |
Programming Project # 3
(Credit 0 - 10 pts) Doubly-linked implementation of QUEUE 1. Modify project Split (posted at class website) by replacing the array implementation O_QUEUE.java of ADT QUEUE posted here: http://csc.csudh.edu/suchenek/CSC311/O_QUEUE.java with a doubly linked implementatiomn of ADT QUEUE. (Note: It will require modification of class Split, too. ) 2. Determine experimentally the average costs of enqueue per insertion and dequeue per deletion while running Split. Requirements: 1. The resulting program
must be 100% your own work (given the program
linked above) with no collaboration/help of any kind with others.
2. The size of input is the number N of elements of the queue. 3. The actual running time of the program is measured by class cnt.java that counts the number of times that the body of the innermost loop in each method (if given method has a loop) is executed plus the number of times that each method in class that implements ADT QUEUE is called. 4. The only methods that your program is allowed to use are those that you have coded yourself, those posted on page Programs, and those in java.lang.Math. You should also resolve any technical/implementational issues that arise while completing this project. What to turn in:
Due date: April 2 7 , 2015, by 4 PM. |
Programming Project # 4
(Credit 0 - 20 pts) LIST Selection Sort 1. Class ListSelectionSort.java posted at http://csc.csudh.edu/suchenek/CSC311/HWProgs/ListSelectionSort.java is supposed to sort objects of ADT LIST consisting of finitely many elements of Java type Integer (similary to class posted at http://csc.csudh.edu/suchenek/CSC311/SelectionSort/Main.java and discussed in class earlier this semester). Your task is to write a missing code of the method SelectionSort(LIST A) that actually performs the said sorting. Other than that, you are not allowed to modify class ListSelectionSort.java (what exactly are you allowed to change is indicated in a comment above that class in the file). Your program must work seamlessly with all three implementations of ADT LIST covered in this course: a. array implementation: http://csc.csudh.edu/suchenek/CSC311/LIST_AR.java http://csc.csudh.edu/suchenek/CSC311/POSITION_AR.java b. singly-linked list implementation http://csc.csudh.edu/suchenek/CSC311/LIST.java http://csc.csudh.edu/suchenek/CSC311/POSITION.java c. doubly-linked list implementation http://csc.csudh.edu/suchenek/CSC311/LIST_DLL.java http://csc.csudh.edu/suchenek/CSC311/POSITION_DLL.java You will need to incorporate all the above in your program(s), without any modifications, as well as appropriate cnt and Bcnt classes (if needed). Requirements: 1. The resulting program
must be 100% your own work (given the program
linked above) with no collaboration/help of any kind with others.
2. Your method SelectionSort(LIST A) and any other method that it calls (directly or indirectly) must not copy, clone, or duplicate any list, and it must not move elements between any two different lists. 3. The only methods that your program is allowed to use are those that you have coded yourself, those contained in the above links, those posted on page Programs, and those in java.lang.Math. You should also resolve any technical/implementational issues that arise while completing this project. What to turn in:
for N = 12.
Due date: April 23, 2015, by 4 PM. |
Programming Project # 5 (Credit
0 - 30 pts) 3-heap implementation of PRIORITY QUEUE 1. Following exactly the instructions posted at http://csc.csudh.edu/suchenek/CSC311/HWProgs/Assignment5.pdf modify the heap implementation of priority queue onto 3-heap implementation. 2. Run your program on 3 arrays of 40 integers each:
What to turn in:
The resulting program must be 100% your own work (except that you shall use and modify the programs linked in the istructions posted above) with no collaboration/help of any kind with others. Due date: May 7, 2015, by 4 PM. |
Copyright © 2015 Suchenek - All rights reserved |
|
|