Question: P20. Write a function, int my_count(list L), that takes as argument a list L of integers (the item is an integer). It should count the

 P20. Write a function, int my_count(list L), that takes as argument

P20. Write a function, int my_count(list L), that takes as argument a list L of integers (the item is an integer). It should count the number of consecutive repetitions of each item and print both the item and the count. A single occurrence is counted as 0. The function should also return the total number of repetitions. For example, for the list 7->2->9->9->9->9->7->7->9->3 -> 3 it will print: 7,0 2,0 9, 3 7, 1 9,0 3, 1 And it will return 5. Your code should not crash. Assume that list are implemented using the types and structs defined below. You should do the pointer manipulation (do not assume for example that there is a function that removes a node or one that inserts at a specific position). typedef struct node * link; typedef struct struct list * list; struct node { int item; link next; }; struct struct_list { link first; int length; }

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!