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

in c, do the following function; typedef struct node { ElemType val; struct node

ID: 656729 • Letter: I

Question

 in c, do the following function;  typedef struct node {     ElemType val;     struct node *next; } NODE;   struct list_struct {     NODE *front;     NODE *back; }; 
 int lst_remove_all_slow(LIST *l, ElemType x) { int n=0;   while(lst_remove_first(l, x))         n++;   return n; }  /** TODO  * function: lst_sra_bad_case (sra:  slow_remove_all)  *  * description: constructs a list of length n such that   * the above function takes quadratic time to remove  * all occurrences of a specified value.   *  * By convention, the specified value will be 0  */ LIST *lst_sra_bad_case(int n) {          return NULL;  }  // TODO // desc:  see header file int lst_remove_all_fast(LIST *l, ElemType x) {   return 0; } 

Explanation / Answer

extern int list_remove_all_slow(List *I,Elem Type x);

int list_remove_all_slow(List *I,Elem Type x){

LIST *I Curr , *I' Curr , *I temp , *I' temp;

*I Curr = I->front;

*I' Curr = I'->front;

*I temp = I->front;

*I' temp = I'->front ;

int n =0;

while(lst_remove_first(I,x)

{

n++;

}

return n;

}

void LIST *Ist_sra_bad_case(int n)

{

int n;

return NULL;

}

Int Ist_remove_all_fast( LIST *I,Elem Type X)

{

LIST *I;

int x;

I=x;

}

return 0;

typedef struct node{

Elem Type val;

struct node *next;

}NODE

struct list_struct{

NODE * front ;

NODE * back ;

}