For many, Easter is a time for receiving chocolate eggs. Large ones, small ones, solid ones, hollow ones, filled ones. D
Posted: Thu Jun 02, 2022 8:31 am
void init_egg (egg *e, double v, int w, chocolate c, wrapping r, filling f); double get_volume (egg e); int get_weight (egg e); chocolate get_choc (egg e); wrapping get_wrap (egg e); filling get_fill (egg e); void set_volume (egg e, double v); KIT107 Programming void set_weight (egg e, int w); void set_choc (egg e, chocolate c); void set_wrap (egg e, wrapping r); void set_fill (egg e, filling f); char *to_string (egg e); The types and variables required to implement my basket (a group of chocolatiers) and a collection (a cluster of eggs) for each chocolatier include the following: struct node_int { void *data; node next; }; typedef struct node_int *node; typedef ??? collection; typedef struct { char *name; Continued... -6-
collection eggs; } chocolatier; typedef ??? chocolatiers; chocolatiers basket; a. Which underlying data structure (array or linked-list) will you use as a basis to model the overall collection of chocolatiers (i.e. the chocolatiers type)? In two-three sentences, justify your answer. Click or tap here to enter text. [4 marks] b. Which kind of abstract data type (binary tree, general tree, array, stack, priority queue, double-ended queue, set, list, etc.) would you use to model the collection of chocolatier? In two-three sentences, justify your answer by indicating the functionality required. Click or tap here to enter text. [4 marks] C. Which underlying data structure (array or linked-list) will you use as a basis to model the collection of eggs (i.e. the collection type)? In two-three sentences, justify your answer. Click or tap here to enter text. [4 marks] d. Which kind of abstract data type (binary tree, general tree, array, stack, priority queue, double-ended queue, set, list, etc.) would you use to model the collection of eggs? In two-three sentences, justify your answer by indicating the functionality required. Click or tap here to enter text. [4 marks] Continued...
e. Given your definition for the collection of sessions in parts (a) and (c) above: i. Using typedefs, define the types collection and chocolatiers that represent a collection of eggs and chocolatiers respectively. Click or tap here to enter text. [5 marks] ii. Implement the following functions that allow the manipulation of a collection of chocolatiers given your answers above: void init_chocolatiers () - create an empty data set; Click or tap here to enter text. [5 marks] • void add_egg (egg e, char *maker) — add the egg e to basket for the named chocolatier; Click or tap here to enter text. [10 marks] print all eggs in void display_eggs (char *maker) basket for the indicated chocolatier; Click or tap here to enter text. [5 marks] • int count_wrap (int w) - count and return the total number of eggs in basket with wrapping w; and Click or tap here to enter text. [5 marks] bool full () - determine whether basket is full returning true if so and false otherwise. (It is full if there are five eggs for all known chocolatiers.) Click or tap here to enter text. [5 marks]