.. | ||
assets | ||
src | ||
.clang-format | ||
.gitignore | ||
Assignment.pdf | ||
CMakeLists.txt | ||
README.org |
Assignment 3
- ABC123:
zfp106
- Name:
Price Hiller
- Course:
CS2124
- Section:
0C3
- Semester:
Spring 2024
Source Code
The full source code for this project can be found at https://git.orion-technologies.io/Price/college/src/branch/Development/Spring-2023/CS-2124/Assignment-3
Running the Programs
- Install cmake version 3.25 or greater.
- Ensure you have a recent version of
make
at the time of writing. This project successfully compiles withGNU make
version4.4.1
. - Go the directory with
CMakeLists.txt
and runcmake .
to generate a Makefile. - Run
make all
to compile all the programs. - Go into the newly created
bin
directory where all the compiled programs will be output to - Programs will be named
PartOne
,PartTwo
, andPartThree
Questions/Prompts with Answers
Part One: Priority Queue
-
Prompt
- Students are to implement a priority queue using C language
- Ask user for number of elements for the Priority Queue
- User input elements and their Priority
- Display elements with their Priority
- Ask use for Dequeue.
- If user input dequeue, the element with highest priority should be removed from the existing list and then display the new list.
- 5 is the highest priority, 1 is the lowest priority for a process
- Students can use any data structure to implement the Priority Queue
- Image of Program running:
As a note I implemented this using a stack via a vector/arraylist/dynamically resized
array/rain dance for the rain gods down in Africa for resizable drops that was implemented by
me for a previous assignment (assignment 2).
As part of this I chose to sort the list and use a custom
pop
method to grab the highest priority item off the top.
Part Two: Huffman Encoding
Create a Huffman Encoding Table and Tree for your first or last name
-
Huffman Code/bit representation Table of your name.
- Fixed bit representation
- Variable bit representation
-
Huffman Tree of your name. (You mut use a software to draw the tree i.e. MS word, Visio etc. Do not hand draw the tree)
- Fixed bit representation
- Variable bit representation
- Highlight which Huffman bit representation requires less bits for encoding i.e. Fixed bit representation or variable bit representation, just like in the lecture slides
Tables
-
Fixed bit representation
Character Bits Frequency Number of Bits Used P 000 1 3 r 001 1 3 i 010 1 3 c 011 1 3 e 100 1 3 Total Number of Bits Used: $15$
-
Variable bit representation
Character Bits Frequency Number of Bits Used P 00 1 2 r 01 1 2 i 110 1 3 c 111 1 3 e 10 1 2 Total Number of Bits Used:
12
Fewer bits used for variable bit representation!
Trees
- Fixed bit representation
- Variable bit representation