90 lines
3.5 KiB
Org Mode
90 lines
3.5 KiB
Org Mode
* 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
|
|
1. Install [[https://cmake.org/download/][cmake]] version 3.25 or greater.
|
|
2. Ensure you have a recent version of ~make~ at the time of writing. This project successfully
|
|
compiles with ~GNU make~ version ~4.4.1~.
|
|
3. Go the directory with ~CMakeLists.txt~ and run ~cmake .~ to generate a Makefile.
|
|
4. Run ~make all~ to compile all the programs.
|
|
5. Go into the newly created ~bin~ directory where all the compiled programs will be output to
|
|
6. Programs will be named ~PartOne~, ~PartTwo~, and ~PartThree~
|
|
|
|
** Questions/Prompts with Answers
|
|
|
|
*** Part One: Priority Queue
|
|
- Prompt
|
|
1. Students are to implement a priority queue using C language
|
|
2. Ask user for number of elements for the Priority Queue
|
|
3. User input elements and their Priority
|
|
4. Display elements with their Priority
|
|
5. Ask use for Dequeue.
|
|
6. If user input dequeue, the element with highest priority should be removed from the
|
|
existing list and then display the new list.
|
|
7. 5 is the highest priority, 1 is the lowest priority for a process
|
|
8. Students can use any data structure to implement the Priority Queue
|
|
- Image of Program running:
|
|
[[./assets/PartOne/img1.png]]
|
|
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
|
|
|
|
1. Huffman Code/bit representation Table of your name.
|
|
a. Fixed bit representation
|
|
b. Variable bit representation
|
|
2. 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)
|
|
a. Fixed bit representation
|
|
b. Variable bit representation
|
|
c. 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
|
|
[[./assets/PartTwo/fixed-bits-huffman.png]]
|
|
- Variable bit representation
|
|
[[./assets/PartTwo/variable-bits-huffman.png]]
|
|
|