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

Write the additional code needed in the space below so that the attached singly

ID: 655657 • Letter: W

Question

Write the additional code needed in the space below so that the attached singly linked list program will function correctly as a linked list and produce the output below

0 1 2 3

4 5 6 7

0 1 2 3

4 5 6 7

8

l Liat code problem 12 inelude ciostream sing nanespace templates typenane st typenane NODETYPE elass 14s ETYPE friend claes Liate NODETYPE 1 to ca to class oveo these o class veo publie explicit ListNode ( conat soorrmg “ato ) data( info. nextPtEto NODETYPE getData ) conse return data might need something here tor Problem 1 public for Problem 13 NODETYPE data ListNode 3gDrTYP® > .nextPtr, templatec typename NODETYPE class List public List (int aize) firstptr (0) int i-0 Li.tNodeNODETYPg > .prePtr- o; while (i ml (8) cout

Explanation / Answer

#include<stdio.h>

#include<conio.h>

struct node

{

int data;

struct node*next;

}

void Number(struct node**head_ref)

{

struct node*end=*head_ref;

struct node *prev=NULL;

struct node *cur="head_ref;

while(end->next!=NULL)

{

end=end->next;

struct node*new_node=end;

while(curr->data%2!=0 && curr!=end)

{

new_end->next=curr;

curr=curr->next;

new_end->next=NULL;

new_end=new_end->next;

if(curr->data%2==0)

{

*head_ref=curr;

while(curr!=end)

{

if(curr->data%2==0)

{

prev=curr;

curr=curr->next;

}

else

{

prev->next=curr->next;

curr->next=NULL;

new_end->next=curr;

new_end=curr;

curr=prev->next;

}

}

}

else prev=curr;

if(new_end!=end&&(end->data)%2!=0)

{

prev->next=end->next;

end->next=NULL;

new_end->next=end;

return;

}

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;

}

}

int main()

{

struct node * head=NULL;

push(&head,0);

push(&head,1);

push(&head,2);

push(&head,3);

push(&head,4);

push(&head,5);

push(&head,6);

push(&head,7);

push(&head,8);

printf(" Original linked list");

printList(head);

number(&head);

printf(" Linked List");

printList(head);

return 0;

}