Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have this array of strings array char names[32][4] = { \"ABA\", \"ABC\",\"ABD\

ID: 3697936 • Letter: I

Question

I have this array of strings array char names[32][4] = { "ABA", "ABC","ABD","ABG", "BAA", "BAB", "BAC", "ABA", "CBA", "DAB", "DBC", "DBE","DBA","EAB", "FAB", "FAC", "FAA", "GAB", "GAA", "HAA", "HAB", "CBA","JAA","KAA", "LAL", "LAB", "MAA", "BAB", "MBA", "MUM", "NAN", "NAB", }; There are some duplicates such as ABA and CBA, BAB . Part 1 Add extra field to the structure - say count. Then, I want you to write a program using linked list to print all duplicates. But the restrictions are : 1. You can only pass the array only once. 2. You should add a node to the list only if it is not a duplicate. 3. you should not use any other array. SchoolNames_t *head = NULL ; head = (SchoolNames_t *) malloc ((int) sizeof (SchoolNames_t)); stpcpy (head->name, names[0]); int i ; for ( i = 1 ; i < 32 ; i++) append_node( head, names[i]); // traversing names array only once. Print_all_nodes (head); // CHANGE THE PRINT FUNCTION FOR PART B Part 2 : Also change the same append_node function to count the frequency of the strings Then, Print the name and frequency of each name in a separate line only if the count is greater than 1 . You have to change the Print_all_nodes function, ABA 2 CBA 2 BAB 2. in C langauge

Explanation / Answer

#include<stdio.h>

#include<stdlib.h>

struct node

{

int data;

struct node *next;

};

void removeDuplicates(struct node *start)

{

struct node *ptr1, *ptr2, *dup;

ptr1 = start;

while(ptr1 != NULL && ptr1->next != NULL)

{

ptr2 = ptr1;

while(ptr2->next != NULL)

{

if(ptr1->data == ptr2->next->data)

{

dup = ptr2->next;

ptr2->next = ptr2->next->next;

free(dup);

}

else

{

ptr2 = ptr2->next;

}

}

ptr1 = ptr1->next;

}

}

void push(struct node** head_ref, int new_data);

void printList(struct node *node);

int main()

{

struct node *start = NULL;

push(&start, ABA);;

push(&start, "ABC" );

push(&start, "ABD");

push(&start, "ABG");

push(&start, "BAA");

push(&start, "BAB");

push(&start, "BAC");

push(&start, "ABA");

push(&start, "CBA");

push(&start, "DBA");

push(&start, "DBC");

push(&start, "DBE");

push(&start, "DAB");

push(&start, "EAB");

push(&start, FAB");

push(&start, FAC");

push(&start, "FAA");

push(&start, "GAB");

push(&start, "GAA");

push(&start, "HAA");

push(&start, "HAB");

push(&start, "CBA");

push(&start, "JAA");

push(&start, "KAA");

push(&start, "LAL");

push(&start, "MAA");

push(&start, "LAB");

push(&start, BAB");

push(&start, "MBA");

push(&start, "MUM");

push(&start, "NAB");

push(&start, "NAN");

printf(" Linked list before removing duplicates ");

printList(start);

removeDuplicates(start);

printf(" Linked list after removing duplicates ");

printList(start);

getchar();

}

void push(struct node** head_ref, int new_data)

{

struct node* new_node =

(struct node*) malloc(sizeof(struct node));

new_node->data = new_data;

new_node->next = (*head_ref);

(*head_ref)    = new_node;

}

void printList(struct node *node)

{

while(node != NULL)

{

printf("%d ", node->data);

node = node->next;

}

}

for the 2nd part....