Requirement1. General InstructionsYou are given a skeleton C code in the following files:dynArray.hdynArray.cstackapp.cbag2set.candMakefileComplete 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 BagComplete the seven functions in dynArray.c, 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 pointsvoid dynArrSetCapacity(DynArr v, int newCap) = 5 pointsvoid addDynArr(DynArr v, TYPE val) = 5 pointsvoid removeAtDynArr(DynArr v, int idx) = 5 pointsvoid removeDynArr(DynArr v, TYPE val) = 5 pointsvoid pushDynArr(DynArr v, TYPE val) = 5 pointsvoid popDynArr(DynArr v) = 5 pointsint containsDynArr(DynArr v, TYPE val) = 5 points3. Application of StacksStacks can be used to check whether a mathematical expression has balanced parentheses ( ), braces { }, and brackets [ ]. For example, a balanced expression iC代写Dynamic Array, Stack, and Bag代写R编程、R实验作业代做s “{(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.c 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 points4. Convert a Bag into a SetComplete the function that transforms a bag into a set in bag2set.c. 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.c. 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& 转自:http://ass.3daixie.com/2018052510008081.html
讲解:CDynamic Array, Stack, and BagR、R
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 前几天,我有幸见到了这样一些人: 一位专业训练十余年的拳击冠军,一位浙大光学理工博士,一位知识产权知名律师,一位两...