.. | ||
assets | ||
src | ||
.clang-format | ||
.gitignore | ||
Assignment.pdf | ||
CMakeLists.txt | ||
README.org |
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
- 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: 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)
- Write a program that will have pre-defined input as numbers (
- Output
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:
-