Part A (12 points) Assume a 32 system and consider the following create dlinkedi
ID: 3800999 • Letter: P
Question
Part A (12 points) Assume a 32 system and consider the following create dlinkedist function: DL inked List create dlinkedlist DLinkedi ist. new List (DLinkedList mall oc (sizeof (DLinkedList)) new List head NULL; new List- tail NULL: new List- current NULL; return new List; 1 What integer is passed to malloc when this function executes? A.2 Which region of memory holds the variable newList? Str A.3 How much space (in bytes) is allocated for newList in this region of memo bytes A4 How much space (in bytes) is allocated for the return value of create dlinkedlst? bytes that takas a nninter to an LLNode andExplanation / Answer
Here the question is asking to create a new linked list.The malloc() function is used to allocate memory blocks of heap during the execution of the program.Here we have to pass the parameter(integer passed in the malloc function) for malloc function is exactly the size of the linked list. The question is asking for complete NULL linked list because the current node is also NULL .The elements in the nodes are null.However it occupies some memory during execution just to reate a new linked list. The First answer A.1: The code automatically takes the size of linked list as integer parameter in malloc function. The Second answer A.2: The next element of Node of linked list holds new list, The Third answer A.3: The space allocation of new list depends on malloc function.if you allocate malloc(100) bytes it allocates 100 bytes .But here the linked list contains NULL nodes .Hence the memory will be allocated but NULL will be stored in it. The Fourth Answer A.4: The space taken by return value of linked list depends on linked list itself.