Please read the remarks about programming problems for this course.
These are practice problems not to be handed in.
8.1, 8.2
9.1, 9.2, 9.5, 9.15,
10.43, 10.54
11.13a
(Worksheets handed out in class)
Dijkstra's Algorithm Due Tuesday, April 6
Implement the dijkstra function that is part of the code found in the Dijkstra folder of the course code repository. This function uses Dijkstra's single source shortest path algorithm to find the shortest path to all vertices.
All the support code is provided:
You may add helper functions if you like; for example, I wrote a find_min_unknown function to return the index of the vertex with known = false and minimum distance value from a VertexList.
You do not need to use a min-heap for the minimum vertex selection required by Dijkstra's algorithm. You may instead use a simple linear search.
The file graph1.txt contains the adjacency matrix:
-1 10 -1 5 12 7
10 -1 2 2 -1 -1
-1 2 -1 3 -1 -1
5 2 3 -1 -1 1
12 -1 -1 -1 -1 4
7 -1 -1 1 4 -1
(-1 represents no connection.)
A correctly implemented dijkstra function will
result in the provided framework printing
. 10 . 5 12 7 10 . 2 2 . . . 2 . 3 . . 5 2 3 . . 1 12 . . . . 4 7 . . 1 4 . Node | Dist. | Path -----+-------+-------- 0 | 0 | 0 1 | 7 | 0 -> 3 -> 1 2 | 8 | 0 -> 3 -> 2 3 | 5 | 0 -> 3 4 | 10 | 0 -> 3 -> 5 -> 4 5 | 6 | 0 -> 3 -> 5 |
First it prints the adjacency matrix, then it prints the shortest path results. While this sample file is useful for testing your code, your function must work for any valid adjacency matrix with nonnegative edge weights.
You should not modify any existing code in the provided framework; simply complete the dijkstra function and possibly add a few other helper functions.
In this project you will program the artificial intelligence for an object modeling a Reversi player. Your player object must be compatible with the sample code provided. Your team's player will compete in a tournament against players from other teams.
Note: This project is a longer term project. There will be shorter problems assigned to be done concurrently with this project.
These are practice problems not to be handed in.
4.1, 4.2, 4.3, 4.4, 4.5, 4.8, 4.21, 4.25, 4.32, 4.33
5.1, 5.8
6.1, 6.2, 6.3
7.1, 7.2, 7.19
Implement each of the following sorts as individual functions that accept a vector of integers:
Use a Stopwatch object to time the execution of each of the functions for vectors of size 10, 100, 1000, 10,000, and 100,000. Include a table summarizing the results.
Heap Priority Queue Due Tuesday, March 9
You will implement a priority queue using an array-based binary heap.
Create the minheap.cpp file that implements the methods specified in the file minheap.h. The comments indicate what the methods do and what parameters they expect. The file test_heap.cpp is provided for your convenience for testing your code.
As usual, you may not modify minheap.h. Your minheap.cpp file should be perfectly compatible with minheap.h. Please submit only your minheap.cpp file to eclass.
Hash Table Due Tuesday, February 23
You will implement a hash table that can use either linear or quadratic probing to resolve collisions. You are not to use external chaining with linked lists for this assignment.
Create the hashtable.cpp file that implements the methods specified in the file hashtable.h. The comments indicate what the methods do and what parameters they expect. The file test_hashtable.cpp is provided for your convenience for testing your code.
As usual, you may not modify hashtable.h. You are encouraged to modify test_hashtable.cpp--for example, use the hashpjw function, experiment with quadratic probing, and use a bigger (prime-sized) table.
Your hashtable.cpp file should be perfectly compatible with hashtable.h. Please submit only your hashtable.cpp file to eclass.
AVL Tree Due Tuesday, February 16
Create the avl_tree.cpp file that implements the un-implemented methods specified in the file avl_tree.h. The comments indicate what the methods do and what parameters they expect. The file test_avl.cpp is provided for your convenience for testing your code.
Note: You may adapt the code found in your textbook, but be aware the author's insert method expects a node pointer passed by reference and the function does not return anything. In contrast, my code (and, therefore, your code) expects simply a node pointer; the function returns a node pointer result through which the client would update the actual parameter. Also, you will need to provide the symmetric rotations that the author omitted--because of the symmetry involved they are not difficult to write.
Multilists Due Tuesday, February 2
A multilist is a linked structure that allows data to be sorted in more than one way. For example, a set of records containing an identification number (int) and a name (string) can be stored simultaneously in numerical order by ID and lexicographical order by name.
The following figure shows a typical node within a multilist sorted by ID numbers and names:
Given the Multilist interface multilist.h and sample client code testmultilist.cpp, provide the multilist implementation (multilist.cpp) that completes the program. You may not change multilist.h.
A name will contain only alphabetic characters, and not contain spaces. The input of names may contain a mixture of capitalized and uncapitalized letters within the names, but the printed names should be in all upper case. The printing methods traverse the multilist in the appropriate way, printing each record as follows:
+ 145 Fred + 200 Wilma + 300 Betty + 85 Barney + 420 Dino + 50 Pebbles m |
issued to the testmultilist.cpp program would output
Printing by name reverse (WILMA,200) (PEBBLES,50) (FRED,145) (DINO,420) (BETTY,300) (BARNEY,85) |
Your program should output two numbers: the kth largest element in the data set as determined by the two different functions. Your program should produce no other output.
For this assignment you need not worry about malformed data files.
You may use the sample inputs found at http://perl.cs.southern.edu/repository/Misc/314/Assignments/Chapter01/1.1/. You'll see in one file the sample input has 100 integers, and you are looking for the 24th largest integer. In the other file you will find the 130th largest element amongst 1000.
In Excel or Word produce a table comparing the running times of both implementations on lists of sizes 100, 1000, 10000, 50000, 100000, 200000, and 500000. Any data files you construct yourself should comply with the above format with no duplicate elements.
You may use a Stopwatch object to time the execution of the functions.
Here are details for the methods:
The class should have a contructor that fixes the collection's size at the time of the collection's creation; this makes array management easier (no need to dynamically reallocate the array as the program runs).
A simple test file is provided on at http://perl.cs.southern.edu/repository/Misc/314/Assignments/Chapter01/1.13/. (You will find a makefile there as well if you want to use the command line compiler.) Your template class should work with the test file. This test program performs minimal checking; you should perform more exhaustive tests yourself.