subject

#include #include

typedef struct nod{
int info;
struct nod *next;
}node;

node* SortInsert(node *root, int item); //this function is complete
void simplePrint(node* root); //this function is complete
int countNodes (node* root); //to create this function
node* EvenCopy(node * root); //to create this function

int main()
{
node* head=NULL;
node* head2 = NULL;

node *t;
int ch, ele;
head = SortInsert(head, 4);
head = SortInsert(head,6);
head = SortInsert(head,3);
head = SortInsert(head,5);

printf("\nSimple print List 1: ");
simplePrint(head);

printf("\nCount Nodes %d", countNodes(head)); //modify the countNodes function to make it work

head2 = EvenCopy(head); //modify the EvenCopy function to make it work
printf("\nSimple print after EvenCopy: ");
simplePrint(head2); //This call should print 4, 6

return 0;

}

void simplePrint(node* root)
{
node* t=root;
while(t!=NULL)
{
printf("%d ",t->info);
t=t->next;
}
}

node* SortInsert(node* root, int item)
{
node *temp;
node *t;
temp= (node *) malloc(sizeof(node));
temp->info=item;
temp->next=NULL;
if (root==NULL || root->info >=item)
{
temp->next = root;
root = temp;
}
else
{
t = root;
while (t->next != NULL && t->next->info next;
temp->next = t->next;
t->next = temp;
}

return root;
}

THE FOLLOWING QUESTIONS ARE HERE:

int countNodes (node* root)
{
/*this function takes the head of a linked list and returns the number of nodes available in the linked list. You can use for loops or recursion */

}

node* EvenCopy(node * root)
{
/*this function takes the head of a linked list and copies all the even numbers to a new linked list and return the
head of the new linked list. Note that a number is considered as even if number%2 is 0.
Example: passing the head of a linked list containing 3, 4, 5, 6 would return another linked list containing 4, 6 */

}

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 07:30, haleyblu6351
By refraining from constructing a building until they are certain that it will not cause harm to the environment, an organization is adhering to the
Answers: 2
image
Computers and Technology, 22.06.2019 08:10, josued123321
Alook-up table used to convert pixel values to output values on a monitor. essentially, all pixels with a value of 190 or above are shown as white (i. e. 255), and all values with a value of 63 or less are shown as black (i. e. 0). in between the pixels are scaled so that a pixel with a value p is converted to a pixel of value 2/127 −+3969). if a pixel has a value of 170 originally, what value will be used to display the pixel on the monitor? if a value of 110 is used to display the pixel on the monitor, what was the original value of the pixel?
Answers: 1
image
Computers and Technology, 22.06.2019 15:10, reycaden
David is in week 3 of his current ashford course and has a paper due by monday night at midnight. he has finished everything but the concluding paragraph. as he boots up his computer to work on it, he sees a flash across the screen and then the screen goes black. he begins to panic as he tries desperately to turn the laptop back on. david should have saved his work on what kind of portable device?
Answers: 2
image
Computers and Technology, 23.06.2019 04:31, mona92
Which of the following is not a way in which trees benefit the environment? a. they remove a significant amount of carbon dioxide from the atmosphere. b. they remove a significant amount of oxygen from the atmosphere. c. their roots hold soil in place, reducing rates of erosion. d. they remove ozone and particulates from the atmosphere. select the best answer from the choices provided a b c d
Answers: 1
You know the right answer?
#include #include

typedef struct nod{
int info;
struct nod *next;
}n...

Questions in other subjects:

Konu
Law, 22.11.2019 05:31
Konu
Law, 22.11.2019 05:31