college/Spring-2024/CS-2124/Assignment-3
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 3

  • 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: 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: /Price/college/media/commit/d929ecedc61512114652613e4058f95fbf64202d/Spring-2024/CS-2124/Assignment-3/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.

    1. Fixed bit representation
    2. 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)

    1. Fixed bit representation
    2. Variable bit representation
    3. 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 /Price/college/media/commit/d929ecedc61512114652613e4058f95fbf64202d/Spring-2024/CS-2124/Assignment-3/assets/PartTwo/fixed-bits-huffman.png
  • Variable bit representation /Price/college/media/commit/d929ecedc61512114652613e4058f95fbf64202d/Spring-2024/CS-2124/Assignment-3/assets/PartTwo/variable-bits-huffman.png