Question: 1. General Instructions You are given a skeleton C code in the following files: dynArray.h dynArray.c stackapp.c bag2set.c and Makefile Complete the missing functions in

1. General Instructions

You are given a skeleton C code in the following files:

dynArray.h1. General Instructions You are given a skeleton C code in the

dynArray.cfollowing files: dynArray.h dynArray.c stackapp.c bag2set.c and Makefile Complete the missing functions

stackapp.cin dynArray.c, stackapp.c, and bag2set.c. Submit only these three C files via

bag2set.cCanvas by the deadline. Do not submit the header file and compiled

and

Makefile

Complete the missing functions in dynArray.c, stackapp.c, and bag2set.c. Submit only these three C files via Canvas by the deadline. Do not submit the header file and compiled object files (*.o).

You must use the same names of files, functions, and variables as we specified in the skeleton code. This is because our grading will be based on a script that assumes that you use the same names.

Make sure your code compiles without errors using the provided Makefile on the ENGR server.

2. Implementation of the Dynamic Array, Stack, and Bag

Complete the seven functions in dynArray.cobject files (*.o). You must use the same names of files, functions,, listed below. Our comments in the code at the beginning of each of these functions will help you understand their purpose.

Grading policy: max 35 points

void dynArrSetCapacity(DynArr *v, int newCap) = 5 points

void addDynArr(DynArr *v, TYPE val) = 5 points

void removeAtDynArr(DynArr *v, int idx) = 5 points

void removeDynArr(DynArr *v, TYPE val) = 5 points

void pushDynArr(DynArr *v, TYPE val) = 5 points

void popDynArr(DynArr *v) = 5 points

int containsDynArr(DynArr *v, TYPE val) = 5 points

3. Application of Stacks

Stacks can be used to check whether a mathematical expression has balanced parentheses ( ), braces { }, and brackets [ ]. For example, a balanced expression is "{(x + y), [x + (y + z)]}". An unbalanced expression: a) Closes an unopen parenthesis/brace/bracket; or b) Closes a parenthesis/brace/bracket before closing the latest open parenthesis/brace/bracket; or c) Ends before closing all open parentheses/braces/brackets. For example, unbalanced expressions are "[x + (y + z)" or "[x + (y + z])".

Write the function int isBalanced(char* s) in stackapp.cand variables as we specified in the skeleton code. This is because that returns 1 if the input expression is balanced, or 0 otherwise. Alternative solutions that produce correct results BUT DO NOT USE a stack will not receive credit.

Your function should read through the input string using the function nextChar(char* s), which has already been implemented for you. You may use the provided main function for testing your code.

Note that you would need to fix the data type in dynArray.h as #define TYPE char.

Grading policy: max 35 points

4. Convert a Bag into a Set

Complete the function that transforms a bag into a set in bag2set.cour grading will be based on a script that assumes that you. A set cannot have repeated instances of the same element. Your function void bag2set(struct DynArr *da) should call the functions that you implemented for the first part of HW2 in dynArray.cuse the same names. Make sure your code compiles without errors using. In void bag2set(struct DynArr *da), you should also free the memory space allocated to the input bag, since the bag is not needed any more after exiting the function.

You may use the provided main function for testing your code. Note that you would need to fix the data type in dynArray.h as #define TYPE double

here are the files: https://ufile.io/uympq

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!