CS/CE 2336 – Computer Science II (Advanced Java Programming), Summer 2012
Due at 11:59pm, Sunday July 22 nd
- 100pts
Directions: You are a software engineer for the University of Texas at Dallas, and you are designing a system to store student information files. These files are stored in a database and identified by a unique key, student ID numbers. You are to implement various data structures and determine which is best suited to handle this information. Therefore, you are to implement a class or classes which contain the following: a singly linked list, a doubly linked list, a stack, a queue, and a binary search tree. Your input file (data_structure_input.dat) will consist of text file which contains an unknown number of unordered student ID numbers. You will also prompt the user to enter a query number to search for in each data structure. Your output should show the building of each data structure displayed on the screen similar to:
Singly linked list:
Add 2011137675
Add 2011143454
…
Enter value to search for:
<value> is found/not found
Would you like to search for another value (Y/N)?
Enter value to search for:
<value> is found/not found
…
Doubly linked list (head to tail):
Add 2011137675
Add 2011143454
…
In reverse order (tail to head):
2011144565
2011114776
…
Enter value to search for:
<value> is found/not found
Would you like to search for another value (Y/N)?
1
Enter value to search for:
<value> is found/not found
…
Stack:
Push 2011137675
Push 2011143454
…
Enter value to search for:
<value> is found/not found
Would you like to search for another value (Y/N)?
Enter value to search for:
<value> is found/not found
…
Queue:
Enqueue 2011137675
Enqueue 2011143454
…
Enter value to search for:
<value> is found/not found
Would you like to search for another value (Y/N)?
Enter value to search for:
<value> is found/not found
…
Binary search tree:
Add node 2011137675
Add node 2011143454
…
Select type of traversal (in-order, pre-order, post-order):
In-order traversal: (example)
2011137675
2
2011143454
…
Would you like to use another traversal (Y/N)?
Select type of traversal (in-order, pre-order, post-order):
Post-order traversal: (example)
2011137675
2011143454
…
Enter value to search for:
Select type of search (depth-first, breadth-first):
<value> is found/not found
Would you like to search for another value (Y/N):
Enter value to search for:
Select type of search (depth-first, breadth-first):
<value> is found/not found
…
ArrayList:
2011137675
2011143454
…
Enter “x” to exit
As shown above, once each data structure is built, the user should be prompted to enter a query value. Your program will search the data structure and return whether or not it is found. The user will continue to be prompted to enter search values/types, etc. until “N” is entered. Then the program will move on to the next data structure. If you wish, you may add a menu which will allow the user to keep selecting data structures until the user exits, but this is not required .
The binary search tree should allow the user to traverse the tree using in-order, pre-order, and postorder traversals, displaying the values in the tree for each traversal. The user should also be able to select the search type (as shown above).
Next, store the elements in the binary search tree in a ArrayList, in sorted order from lowest to highest, and display them on the screen as shown above. You should implement a Java Iterator to move through the list as shown here: http://www.java-samples.com/showtutorial.php?tutorialid=235
3
Finally, you will write a short report to your supervisor (Dr. Kirtzic) indicating which of the above data structures would be best to use for this application. You should have a brief analysis of how they compare to each other, using such metrics as efficiency, ease of implementation, ease of use, time/space usage, etc. This report should be 5-10 sentences, and no more than a paragraph, as Dr.
Kirtzic is a busy, busy man. Submit this report as a Word, text, or pdf document along with the rest of the assignment.
Notes:
In addition to the above described functionality for each data structure, after you build and display your doubly linked list, you should display it values from the tail (end) to the head (beginning) in reverse order (as shown above).
None of your data structures should allow duplicate values, as they are unique keys.
Tree: Following the format in the Session 12 slides, implement a Tree data structure. You should create a Tree<E> interface and AbstractTree<E> abstract class.
Binary search tree: Using the above Tree data structure, implement a binary search tree with a
BinaryTree<E> class, as shown in the Session 12 slides. In particular, you will need to implement all of the abstract methods in the Tree<E> interface.
Requirements: Programming assignments should be submitted using your eLearning account. Each programming assignment must contain the following:
1. A text copy of all source code including its documentation (.java)
2. A file showing test cases for your programs input and displayed output (.doc)
3. Copies of all Java executable code (.class) files needed to execute the program.
4. All files (.java, .class, .jar, .doc, etc.) should be submitted in a single .zip file.
5. A Word, text, or pdf document containing the report described above.
Grading: Programming assignments will be graded according to the following metrics:
Code Development - 30% (compile w/o error)
Program Execution - 20% (run successfully)
Program Design - 25% (conform to spec)
Documentation - 15% (program, comments) see below
Coding Style - 10% (clear, efficient)
Program documentation standards (example):
/***************************************************************************************
* Program: program name
* Function: program function (descriptive, not literal)
* Input: program input (descriptive, not literal)
* Output: program output (descriptive, not literal)
* Notes: any additional information about this program, particularly if it uses code written by other authors,
4
* in which case it should be properly referenced (i.e., other author name, website, etc.)
***************************************************************************************/ import…
//global variables int x; //describes global variable x int y; //describes global variable y
…
//this class does something really important… public class makeItCool ( )
{ double z;
…
//describes local variable z stuff; //this stuff does some really cool stuff
…
//if this stuff isn’t cool, then make it cool if (! cool)
{
} cool = true;
} else
{
} public class…( )
… return 0;
//now everything’s cool
//already cool
5