Question: Problem 1 : Exercise 8 . 1 8 ( with one change as mentioned below ) Instead of having a return type of void, your
Problem : Exercise with one change as mentioned below
Instead of having a return type of void, your zip should return an integer: if execution is successful and for malformederror input. What would constitute a malformed input for this problem? For starters, it is an error to call zip with a nonempty list as third argument. It is also an error to call zip with one of the input lists the same as the output list. For instance, zipllllll Can you see the problem such a call would cause? On the other hand, it's OK to call zip with empty ll or llor both Finally, passing NULL pointers for some or all of the lists in not allowed either but you already knew that from previous assignments Your zip function should check all of these error conditions and return if any of them are true.
Problem : Exercise with one change just like in the above problem: return if execution is successful and for malformed input
What would constitute a malformed input for this problem? Use similar ideas as mentioned above in Problem this is llist.c #include
#include
#include "llist.h
Private node ADT.
typedef struct node node;
struct node
node next;
void e;
;
static node newNodevoid e
node n mallocsizeofnode;
if n return NULL;
nnext NULL;
ne e;
return n;
static void deleteNodenode n
freen;
Linked list library.
struct llist
node head;
;
llist newLListvoid
llist ll mallocsizeofllist;
if ll return NULL;
llhead NULL;
return ll;
void deleteLListllist ll
if ll return;
node n llhead;
while n
node next nnext;
deleteNoden;
n next;
freell;
int isEmptyLListllist const ll
if ll return ;
returnllhead NULL;
int putLListllist ll void e
node n;
if ll return ;
n newNodee;
if n return ;
nnext llhead;
llhead n;
return ;
int getLListllist ll void e
node n;
if ll e return ;
if llhead NULL nothing to get
e NULL;
return ;
n llhead;
e ne; write element
llhead nnext;
deleteNoden;
return ;
int peekLListllist const ll void e
if ll e return ;
if llhead NULL
Nothing to get.
e NULL;
return ;
e llheade; write element
return ;
int printLListllist const ll printFn f
node n;
int cnt;
if ll f return ;
cnt ;
for n llhead; n NULL; n nnext
Print the index of the element.
cnt;
printfd: cnt;
Call userprovided f to print the element.
fne;
printf
;
return ;
int zipllist ll llist ll llist ll
Your code goes here.
return ;
int unzipllist ll llist ll llist ll
Your code goes here.
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
