

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A homework assignment for a computer science course. Students are required to implement a real number binary min heap adt class using c++ and use it to solve the single source shortest path problem using dijkstra's algorithm. The assignment includes instructions for testing the code and details about what to hand in.
Typology: Assignments
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Homework 4 Assigned Nov 11th Due: Nov 25th
The problem:
You code should not assume that the maximal number of elements that can be inserted into a heap. Basic error handling should be there.
How to test your code : You should name your executables as “hadt” for the heap ADT class, “sssp” for the dijkstra’s algorithm.
For the heap class executable hadt, it should accept an in-line parameter, which is the name of the testing file. For example, to run hadt, you should type: $hadt htest where htest is a testing file. You do not necessary name your test file as htest.
The testing file for the heap ADT class is a set of commands, one at each line. Each command is composed of the name of the related function and the related parameters (without parenthesis and comma, with the exception of the ConstructHeap function). For the ConstructHeap function, you should provide a set of real numbers and their labels. The values (real numbers) and the labels should be separated by a single comma. There can only be one ConstructHeap function and that function must be the first command in the test file. For example the following is a valid testing file for the heap class:
ConstructHeap 0 1.1 3.0 -2.0, A B C D
Print Insert 3.1 E Insert 2.1 F Update 5.1 F DeleteMin Size Print
For the executable “sssp”, it should expect two in-line parameters, the first one is the name of the testing file and the second one is the index of the source node. The testing file contains a single graph, in the adjacency list format. Specifically each line is a list of neighboring nodes (and the related edge weights) associated with a single node, starting with the index of the node, in the format of neighboring node index: weight. For example, the following is a valid testing file for the graph showing below. 1 2:1. 2 1:3.0 3:2.
What to hand in: (1) Source codes with a makefile. If you do not use makefile before, the following is a good tutorial: http://frank.mtsu.edu/~csdept/FacilitiesAndResources/make.htm. Source code needs to be properly commented.
(2) A report with the following components: a. A brief discussion of the data structure that you use to implement the heap ADT. Justify your answer.
b. A brief discussion of the algorithm that you use to solve the problem 2.
c. Show your test files and your testing results. You may use typescript to capture Unix output. If you are not familiar with script and typescript, see http://www.tech-faq.com/capture-unix-terminal-session.shtml.
For example in Unix/Linux environment, assuming you have an executable named “hadt” and a test file “thadt”, you may recode the testing results in the following way:
$script #start scripting $cat thadt #show testing file contents $hadt thadt #run your code $^D (ctrl-D) #stop scripting
1 2 3