Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I don't need the code, just need to answer the following questions: In the comments section of your code think about your data structure and

I don't need the code, just need to answer the following questions:

In the comments section of your code think about your data structure and what might be missing. Come up with one proposed function that you could add to the interface (you do not have to write it) and explain why you think it should be added (what it would do and how it would be useful). image text in transcribed

This program will take the first few daily assignments and combine their behaviors to make an opaque object wrapper that allows for all the behaviors we want in a bit collection data structure called BIT FLAGS #ifndef BIT FLAGS H #define BIT FLAGS H #include "status, h" typedef void" BIT_FLAGS; //Intentionally leaving out a default init function to force user to at least guess at the size needed //If one WERE to be used it would have the following prototype: //BIT_FLAGS bit flags_init_default(void); //Precondition: number of bits is a positive integer. //Postcondition: Returns the handle to a valid Bit flags object that has the ability to store up to number_of bits bits but currently all flags are set at zero. Returns NULL on failure. The container // is assumed to hold size-number_of bits after the init function runs BIT_FLAGS bit_flags_init_numberof_bits (int number_of bits); //Precondition: flag_position is a non-negative integer and hBit_flags is a handle to a valid Bit flags object //Postcondition: The flag at the flag position index is set to 1. Function will attempt to resize the // internal representation if the flag_position is too large instead of failing for out of bounds. Returns SUCCESS if the operation is successful and FAILURE if the operation fails a needed resize. This /I operation is considered to be expensive if flag_position is constantly going out of bounds by a small /I amount because the resize always attempts to minimize the amount of space required to store the bits. / All new flags created in a resize operation (except the one being set) will be set as zero Status bit flags_set flag (BIT_FLAGS hBit flags, int flag_position); //Precondition: flag_position is a non-negative integer and hBit_flags is a handle to a valid Bit flags object //Postcondition: The flag at the flag position index is set to . Function will attempt to resize the // internal representation if the flag_position is too large instead of failing for out of bounds. Returns SUCCESS if the operation is successful and FAILURE if the operation fails a needed resize. This /I operation is considered to be expensive if flag_position is constantly going out of bounds by a small /I amount because the resize always attempts to minimize the amount of space required to store the bits / All new flags created in a resize operation will be set as zero Status bit flagsunset flag (BIT FLAGS hBit flags, int flag position); //Precondition: flag_position is a non-negative integer and hBit_flags is a handle to a valid Bit flags object //Postcondition: returns the value of the flag at index flag_position if it is in bounds or -1 otherwise int bit flags_check flag (BIT_FLAGS hBit flags, int flag position); //Precondition: hBitflags is a handle to a valid Bit flags object //Postcondition: returns the number of bits currently held by the data structure int bit flags_get_size(BIT_FLAGS hBit flags); //Precondition: hBitflags is a handle to a valid Bit flags object //Postcondition: returns the number of bits the object CAN hold int bit_flags_get_capacity (BIT_FLAGS hBit_flags); //Precondition: phBit_flags is the address of a handle to a valid Bit flags object. //Postcondition: The memory for the object referred to by the handle is free'd and the handle is set to NULL void bit flags_destroy (BIT FLAGS* phBit flags); #endif Turn in only your bit flags.h and bit flags.c files for grading. The graders will use their own main program to test your data structure but you should test it as well as you can yourself with your own driver. The graders will also assume you are using the status.h we created irn class. Please note that you may not change prototype of any of these functions as the functions must work with our driver you can only use these This program will take the first few daily assignments and combine their behaviors to make an opaque object wrapper that allows for all the behaviors we want in a bit collection data structure called BIT FLAGS #ifndef BIT FLAGS H #define BIT FLAGS H #include "status, h" typedef void" BIT_FLAGS; //Intentionally leaving out a default init function to force user to at least guess at the size needed //If one WERE to be used it would have the following prototype: //BIT_FLAGS bit flags_init_default(void); //Precondition: number of bits is a positive integer. //Postcondition: Returns the handle to a valid Bit flags object that has the ability to store up to number_of bits bits but currently all flags are set at zero. Returns NULL on failure. The container // is assumed to hold size-number_of bits after the init function runs BIT_FLAGS bit_flags_init_numberof_bits (int number_of bits); //Precondition: flag_position is a non-negative integer and hBit_flags is a handle to a valid Bit flags object //Postcondition: The flag at the flag position index is set to 1. Function will attempt to resize the // internal representation if the flag_position is too large instead of failing for out of bounds. Returns SUCCESS if the operation is successful and FAILURE if the operation fails a needed resize. This /I operation is considered to be expensive if flag_position is constantly going out of bounds by a small /I amount because the resize always attempts to minimize the amount of space required to store the bits. / All new flags created in a resize operation (except the one being set) will be set as zero Status bit flags_set flag (BIT_FLAGS hBit flags, int flag_position); //Precondition: flag_position is a non-negative integer and hBit_flags is a handle to a valid Bit flags object //Postcondition: The flag at the flag position index is set to . Function will attempt to resize the // internal representation if the flag_position is too large instead of failing for out of bounds. Returns SUCCESS if the operation is successful and FAILURE if the operation fails a needed resize. This /I operation is considered to be expensive if flag_position is constantly going out of bounds by a small /I amount because the resize always attempts to minimize the amount of space required to store the bits / All new flags created in a resize operation will be set as zero Status bit flagsunset flag (BIT FLAGS hBit flags, int flag position); //Precondition: flag_position is a non-negative integer and hBit_flags is a handle to a valid Bit flags object //Postcondition: returns the value of the flag at index flag_position if it is in bounds or -1 otherwise int bit flags_check flag (BIT_FLAGS hBit flags, int flag position); //Precondition: hBitflags is a handle to a valid Bit flags object //Postcondition: returns the number of bits currently held by the data structure int bit flags_get_size(BIT_FLAGS hBit flags); //Precondition: hBitflags is a handle to a valid Bit flags object //Postcondition: returns the number of bits the object CAN hold int bit_flags_get_capacity (BIT_FLAGS hBit_flags); //Precondition: phBit_flags is the address of a handle to a valid Bit flags object. //Postcondition: The memory for the object referred to by the handle is free'd and the handle is set to NULL void bit flags_destroy (BIT FLAGS* phBit flags); #endif Turn in only your bit flags.h and bit flags.c files for grading. The graders will use their own main program to test your data structure but you should test it as well as you can yourself with your own driver. The graders will also assume you are using the status.h we created irn class. Please note that you may not change prototype of any of these functions as the functions must work with our driver you can only use these

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

Transactions On Large Scale Data And Knowledge Centered Systems Xxiv Special Issue On Database And Expert Systems Applications Lncs 9510

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Hendrik Decker ,Lenka Lhotska ,Sebastian Link

1st Edition

366249213X, 978-3662492130

More Books

Students also viewed these Databases questions

Question

Graph the function. Give the domain and range. (x) = 2 x + 1

Answered: 1 week ago