Answered step by step
Verified Expert Solution
Question
1 Approved Answer
It is extremely important that you understand how to build linked list software and what each software element contains. In this exercise, we will build
It is extremely important that you understand how to build linked list software and what each
software element contains. In this exercise, we will build a singly linked list that hold integers.
The software provided will build and execute without modification. You will be asked to answer
questions on what it contains and how it is working.
Note that the code maintains something called AllocationCount. It is incremented whenever a
malloc is done and decremented whenever a free is done, so it always tells us how many
things are currently dynamically allocated.
The Solution Steps:
Create a project by copying the following files into a project, building it and running it
The files are:
a UserData.h this file defines what each node contains
b LinkedList. this file contains the declarations of the linked list functions
c SinglyLinkedList.c this file is the implementations of all of the singly linked list
functions
d LinkedListTester.c this file contains the implementation of a test routine for
the linked list functions.
Examine the output and answer the following questions about the test code, the test
output and the contents of SinglyLinkedList.c:
a After the first call to LLInit, the AllocationCount has gone from to Why?
b If the test code's first loop, what did the calls to LLAddToFront do How? Why
did the AllocationCount increase? Does the output printed data order make
sense?
C After the test code's first call to LLDelete the AllocationCount has gone back to
What dynamically allocated things have been freed? How?
d After the test code's second call to LLInit, there is a loop that calls
LLAddAtEnd. What does LLAddAtEnd do Explain the AllocationCount.
When the data is printed out, does the data order make sense?
e How do LLGetAtIndex and LLSetAtIndex work?
f How did LLSwap work? Does the data order printed after it has been called
make sense? Did we swap the linkages to the data or did we swap the data
content itself?
g After the last call to LLDelete is made, the AllocationCount has returned to
What has been released?
h What does UserData.h contain? When would you have to change it
i What does LinkedList.h contain? Why was an include of UserData.h needed?
j SinglyLinkedList.c contain all the code that implements the linked list. Why did it
include LinkedList.h Why did it include UserData.h Did any code in this file
need to understand that UserData contained an int?
Submit the program output and the answers to these questions. Don't forget that the
questions MUST be provided when giving the answers.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started