Looking for ECE2071 - Systems Programming - MUM S1 2026 test answers and solutions? Browse our comprehensive collection of verified answers for ECE2071 - Systems Programming - MUM S1 2026 at learning.monash.edu.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
Disclaimer: This question is significantly more challenging than the rest of this exam. It is strongly recommended that you complete all other questions before attempting this question.
The level first order is a method of node insertion in a binary tree wherein the nodes are inserted from left to right at each level of the tree with an aim to completely fill up all the lower levels of the tree before considering the higher levels.
For example:
If the numbers 1 2 3 4 5 6 are inserted into a binary tree following the level first order, the resulting tree can be graphically depicted as follows:
Utilizing the skeleton code available at this link, complete the definition of the function insert_node_level_first() that inserts a node into a binary tree following the level first order.
void insert_node_level_first(struct node **rootPtr, struct queue_node** headPtr, int data)The function has a return type of void and utilizes the following arguments:Consider a modified version of the IEEE754 single-precision floating-point format as depicted in the figure below.
The floating-point format consists of the following fields:
Represent the number -5789.125 in 32-bits based on the floating-point standard described above. Further, explain how this format changes the range of floating-point numbers that can be represented as compared to the IEEE754 single-precision format.
Define a histogram class that creates histograms (counting how many values fall in each of a number of intervals) given the values and bounds. The class should satisfy the following:
The constructor should be passed a single argument that is a vector of doubles containing the bounds of the histogram bins. The elements of the vector can be assumed to be strictly increasing (each value is greater than the previous value). For example, instantiating the class with the vector: {0.0, 3.14, 20.0, 42.42, 69} would create a histogram with four bins, corresponding to the intervals: [0, 3.14), [3.14, 20), [20. 42.42), [42.42, 69).
The histogram class should have a method named clear, that clears the histogram statistics.
The histogram class should have a method named update, that is passed a single argument: a double that represents a new data point to add to the histogram. You can assume all data passed to this method will be within the range of the histogram bins.
The histogram class should have a method named display, that prints each bin’s range, followed by the number of values that fall into that bin.
For example, if the histogram was initialised with the vector : {0.0, 3.14, 20.0, 42.42, 69} and the update method was called with the following numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, then calling the display method would print the following:
[0, 3.14): 3
[3.14, 20): 7
[20, 42.42): 3
[42.42, 69): 2
All data attributes of the class should be private.
Consider the following C++ program that performs the following activities:
The first few lines of the .csv file are shown below.
025,057,22050,16,25
016,087,10000,8,25
001,004,44100,16,60
015,022,05000,16,45
Answer the following questions:
Consider the C program below and then answer the following questions.
Part 1 (15 marks)
int string_hash (char* string_1, int starting_value)
Write a C function string_hash that takes in the following input arguments:
Step 1: Find the smallest composite number (integer greater than 1 and has more then 2 factors) that is greater than starting_value and stores this as the current composite value (current_composite)
Step 2: Starting from the first character, for each character in the string (except the terminating NULL character), calculate the sum of the ASCII value of the current character and current_composite.
Step 3: Add the result of the calculation in Step 2 to the accumulator value (accumulator), which is initialized as zero at the start of the function.
Step 4: Find the next smallest composite number that is greater than the current_composite and assign this as the new value of current_composite.
Step 5: Repeat steps 2-4 until all non-NULL characters in the string have been considered.
Step 6: Return the value of accumulator upon exit.
Part 2 (5 marks)
Write a C code inside the main function that performs the following activities:
Scan a string (string_1) with a maximum of 20 non-NULL characters (inclusive of whitespaces) and an integer (starting_value) in one line as input from the user through the terminal. The two pieces of information should be separated using a comma delimiter.
Call the hash_string function written in Part 1, using string_1 and starting_value as the inputs
Prints string_1, starting_value and accumulator in the following format on the terminal:
<string_1><whitespace><starting_value><whitespace>-<whitespace><accumulator>'\n'
Note: