Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 23 19 marks) Here is the declaration for the nodes in a singly-linked list of integers: typedef struct intnode int value; struct intnode *next;

image text in transcribed
image text in transcribed
Question 23 19 marks) Here is the declaration for the nodes in a singly-linked list of integers: typedef struct intnode int value; struct intnode *next; intnode_t A function named move lower is passed a pointer to a singly-linked list: intnode_t move_lower (intnode t "head) The function moves every node that contains a value less than the value in the first node to a new linked list, and returns a pointer to the new list. For example, suppose variable my 1ist points to this linked list: my list 5 6 3 9 2 Notice that the third, fourth, seventh and eighth nodes all contain values less than the value in the first node (5). Suppose move_lower is called this way: other _1ist move_lower(my_1ist) The function returns a pointer to a new list that contains the third, fourth, seventh and eighth nodes from the original list, so other_list points to this linked list: other list 2 When the function returns, the list pointed to by my_1ist contains the nodes that weren't moved; that is, the first, second, fifth, sixth, and ninth nodes from the original list: my_ list 5 7 9 8 move_lower should return an empty list if is passed an empty list or a list that contains only one node. Write the definition of move_lower in the solutions script. Your function cannot call malloc or free or any other function. Hint: this page has the "before and after" diagrams for a linked list in which the last node isn't moved. Before writing any code, draw "before and after" diagrams for linked lists containing 0 nodes, 1 node, and a list in which the last node is moved. Marks will be deducted for a solution that performs unnecessary traversals of the linked list. Question 24 [4 marks] Write a recursive function that calculates the average of the values stored in a singly linked list with a head pointer. Nodes are of type intnode t, as defined in Q23. An iterative function will receive 0 marks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

how would you have done things differently?

Answered: 1 week ago

Question

What were the reasons for your conversion or resistance?

Answered: 1 week ago