Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

coding in c using # stdio stdlib limits Complete the function find_min_max, which returns the maximum and minimum of a nonempty array of positive integers.

coding in c using

# stdio

stdlib

limits

  1. Complete the function find_min_max, which returns the maximum and minimum of a nonempty array of positive integers. The minimum and maximum are returned by find_min_max as out parameters. The parameters are:

    • an array of positive integers

    • the length (number of elements) of the array

    • a pointer to an integer (min_ptr)

    • a pointer to an integer (max_ptr)

    For example, after a call to find_min_max with the array with elements {3, 2, 2, 4, 3, 5}, min_ptr should point to the value 2 and max_ptr should point to the value 5.

  2. Complete the function make_star_string, which, given a nonnegative integer n, returns a heap allocated string of n stars (*).

    For example, a call to make_star_string(5) should return the string "*****".

  3. Complete the function make_histogram, which, given a nonempty array of positive integers a, returns a heap allocated array representing a histogram of the elements of a as well as the length of the histogram (hist_len_ptr) as an out parameter. The parameters are:

    • an array of positive integers

    • the length of the array

    • a pointer to an int (hist_len_ptr)

    For example, a call to make_histogram with the array with elements {3, 2, 2, 4, 3, 5} should return an array with elements {2, 2, 1, 1}. Furthermore, hist_len_ptr should point to the value 4. There are two 2s, two 3s, one 4, and one 5 in the input array. The element at index 0 of the output array is the number of occurrences of the minimum value in the input array.

  4. Complete the function make_star_array, which, given a nonempty array of nonnegative integers a representing a histogram, returns a heap allocated array of strings. Each string is a string of stars. The number of stars is the value of the corresponding element of a. The parameters are:

    • an array of nonnegative integers

    • the length of the array

    For example, a call to make_star_array with the array with elements {2, 2, 1, 1} should return an array with elements {"**", "**", "*", "*"}.

  5. Complete the function make_histogram_visualization, which, given a nonempty array of positive integers a, returns a heap allocated array of strings representing a visualization of a histogram of the elements of a. make_histogram_visualization also returns the length of the histogram (hist_len_ptr) as an out parameter. The parameters are:

    • an array of positive integers

    • the length of the array

    • a pointer to an integer (hist_len_ptr)

    For example, a call to make_histogram_visualization with the array {3, 2, 2, 4, 3, 5} should return an array with elements {"**", "**", "*", "*"}. Furthermore, after the call to make_histogram_visualization, hist_len_ptr should point to the value 4.

    In Exercises 3, 4, and 5, you should call the functions youve already written to avoid repeating your work. In this task, you should make use of your make_histogram function as an intermediate step. Be sure to free the heap allocated array returnd by make_histogram when you no longer need it.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions