59 lines
2.4 KiB
Org Mode
59 lines
2.4 KiB
Org Mode
|
* Assignment 4
|
||
|
|
||
|
- 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-4]]
|
||
|
|
||
|
** 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: Avl Tree (3 points)
|
||
|
- Prompt
|
||
|
- Write a program that will have pre-defined input as numbers (~1,2,3,4,5~)
|
||
|
- Then the program will create a BST of the input and print that out
|
||
|
- Then the program will balance the BST and print out the AVL tree (pre-order)
|
||
|
|
||
|
_Steps_:
|
||
|
- Create BST (0.5 points)
|
||
|
- Balance the tree (0.5 points)
|
||
|
_Output_:
|
||
|
- Print BST Pre-order (1 point)
|
||
|
- Print Balanced-AVL Pre-order (1 point)
|
||
|
- Output
|
||
|
[[./assets/PartOne/img1.png]]
|
||
|
|
||
|
*** Part Two: Building Huffman Tree using Heap (2 Points)
|
||
|
- Prompt
|
||
|
- Write code to generate a Huffman Encoding (Variable Bit) using Heap.
|
||
|
- The characters and their frequency can be seen in the output screen shot and in the Tables 1 & 2
|
||
|
- Despite the different variable bit coding (i.e. Table 1 & Table 2) the total bits are the same
|
||
|
- Include the Table for Total Bits in your PDF file with the output screenshot
|
||
|
- Output
|
||
|
- Table of total bits:
|
||
|
| Char | Code | Freq | Bits = Code * Freq |
|
||
|
|------------|------|------|--------------------|
|
||
|
| a | 100 | 5 | 15 |
|
||
|
| b | 101 | 9 | 27 |
|
||
|
| c | 00 | 12 | 24 |
|
||
|
| d | 01 | 13 | 26 |
|
||
|
| e | 11 | 16 | 32 |
|
||
|
|------------|------|------|--------------------|
|
||
|
| Total Bits | | | 124 |
|
||
|
|------------|------|------|--------------------|
|
||
|
- Screenshot of program running:
|
||
|
[[./assets/PartTwo/img1.png]]
|