Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment 2 (60 points) Purpose: To allow you to exercise structs, pointers, linked lists, operator overloading. (make and document any reasonable assumptions). Given the following

image text in transcribedimage text in transcribed

Assignment 2 (60 points) Purpose: To allow you to exercise structs, pointers, linked lists, operator overloading. (make and document any reasonable assumptions). Given the following struct for a node: struct intnode { int value; struct intnode *next; typedef struct intnode IntNode; There is a function called intnode_construct as follows: IntNode *intnode_construct(int value, IntNode *next) IntNode *p = malloc(sizeof(IntNode)); //assert (p != NULL); this is just a guide for you look it up p->value = value; p->next = next; return p; Question 1 (25 point): Create a function called IntNode* interleave (IntNode *head1, IntNode* head2); The function takes two linked lists, interleaves their contents, and returns back a head with the newly interleaved list. For example, if the first linked list is as follows (you don't need the tail): And the second list is as follows: Calling interleave and passing it the two heads will produce a list that looks like this: head tail Note: you should handle the cases where the first list is larger in size compared to the second, or vice versa. You should also handle the case where one or either of the lists is empty. Question 2 (25 point): You are to overload the: 1. == operator such that it checks for the content equality of two linked lists. The RHS and LHS must be of type IntNode * for this to work. It returns 1 if the two list contents are equal, and 0 if not. If the two lists are empty, they are also equal. 2.

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

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students also viewed these Databases questions

Question

Write a letter asking them to refund your $1,500 down payment.

Answered: 1 week ago