Quick Check of Priority Queue Code

You're going to write a Python program called pcheck.py checker for your priority queue code.  It will be executed on the command-line and be given the filename of an input file and the filename of an output file.  Like he command-line below with python3 instead of python if the first line of your code is "#! /usr/bin/python3" instead of "#! /usr/bin/python".

python pcheck.py inputfile.txt outputfile.txt

Your file will contain your priority-queue class (min-heap).  The input file will contain the following types of comma-separated commands, one-commnd-per-line:

Command Example Meaning
push,num... push,5,-1,18 push one or more numbers onto the queue
peek peek write the value of the root to the output file (or "None")
pop pop pop the root and write it to the output file (or "None")
tolist tolist write the result of the tolist() method to the output file (comma-separated, or "None")

So, now, use the "File/Download as..." menu item inside your priority-queue Jupyter notebook to export the code into a .py file.  Edit the file to remove any cells and comments that are the detritus of Jupyter.  Then add the code to read the inputfile and implement the commands above.

Now try pcheck.py with the following inputfile:

push,12,3,20,1,8
peek
pop
push,0,0,3
tolist
pop

Submit the file: pcheck.py to the homework server, and put the results into the Comments-to-Teacher that the program writes into the outputfile when it digests the inputfile above.