college/Spring-2024/CS-2124/Assignment-4
2024-05-12 01:18:21 -05:00
..
assets Rename Spring-2023 -> Spring-2024 2024-05-12 01:18:21 -05:00
src Rename Spring-2023 -> Spring-2024 2024-05-12 01:18:21 -05:00
.clang-format Rename Spring-2023 -> Spring-2024 2024-05-12 01:18:21 -05:00
.gitignore Rename Spring-2023 -> Spring-2024 2024-05-12 01:18:21 -05:00
Assignment.pdf Rename Spring-2023 -> Spring-2024 2024-05-12 01:18:21 -05:00
CMakeLists.txt Rename Spring-2023 -> Spring-2024 2024-05-12 01:18:21 -05:00
README.org Rename Spring-2023 -> Spring-2024 2024-05-12 01:18:21 -05:00

Assignment 4

  • ABC123: zfp106
  • Name: Price Hiller
  • Course: CS2124
  • Section: 0C3
  • Semester: Spring 2024

Running the Programs

  1. Install 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 /Price/college/media/commit/d929ecedc61512114652613e4058f95fbf64202d/Spring-2024/CS-2124/Assignment-4/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: /Price/college/media/commit/d929ecedc61512114652613e4058f95fbf64202d/Spring-2024/CS-2124/Assignment-4/assets/PartTwo/img1.png