Skip to content

All files for Assignment 4 in CSC 310 Fall 2019.

Notifications You must be signed in to change notification settings

johnwhh/assignment4

Repository files navigation

Insertion-Sort Sorted Priority Queue program:

To run the Insertion-Sort Sorted Priority Queue program, run "priority_queue_insertion_sort.py" using Python 3. If using the terminal, navigate to this directory and type "python3 priority_queue_insertion_sort.py".

Upon starting the program, an example will be printed out. In the example, 5 different items are added to an example queue. The example queue is printed out. The remove_min() is called on the queue so the item with the smallest key is returned, removed, and, to show the example, printed out. The example queue is printed out again.

Below the example, there is an empty queue printed out. This is the visual representation of the working queue that can be modified by the user. This queue is not the same as the example queue, as it can be seen that it is empty.

Below the working queue is the menu with the following options: A. Add, G. Get minimum, R. Remove minimum, Q. Quit.

To add an item to the sorted priority queue, navigate to the menu, type A and press Enter/Return. The user will be prompted to enter the key. Enter a valid integer key and press Enter/Return. The user will be prompted to enter the value. Enter a value and press Enter/Return. The item with the entered values will be added to the queue in the correct position. The updated version of the queue will printed out. The menu will be printed below the queue.

To print the minimum item in the sorted priority queue, navigate to the menu, type G and press Enter/Return. The item with the smallest key will be printed out. The queue will be printed out. The menu will be printed below the queue.

To print the minimum item and remove it from the sorted priority queue, navigate to the menu, type R and press Enter/Return. The item with the smallest key will be printed out and removed from the queue. The updated version of the queue will printed out. The menu will be printed below the queue.

To quit the program, navigate to the menu, type Q and press Enter/Return.

Binary Tree Traversal program:

To run the Binary Tree Traversal program, run "tree_traversal.py" using Python 3. If using the terminal, navigate to this directory and type "python3 tree_traversal.py".

Upon starting the program, the example from the assignment handout will be printed out. In the example, the list [1, None, 2, 3] is used to form a binary tree. The preorder traversal of the example tree is printed out. Below that, the inorder traversal of the example tree is printed out.

Below the example, there is a menu that has these options: P. Preorder Traversal, I. Inorder Traversal, Q. Quit.

To print out the preorder traversal of a binary tree represented by a list, type P and press Enter/Return. The user will be prompted to input a value of the list. To fill up the list with values, continue entering values and pressing Enter/Return. To stop filling the list, type S and press Enter/Return. The preorder traversal will then be printed out in the form of a list of values in the order that they would be visited with preorder traversal. The menu will be printed out below.

To print out the inorder traversal of a binary tree represented by a list, type I and press Enter/Return. The user will be prompted to input a value of the list. To fill up the list with values, continue entering values and pressing Enter/Return. To stop filling the list, type S and press Enter/Return. The inorder traversal will then be printed out in the form of a list of values in the order that they sould be visited with inorder traversal. The menu will be printed out below.

To quit the program, navigate to the menu, type Q and press Enter/Return.

About

All files for Assignment 4 in CSC 310 Fall 2019.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages