Answered step by step
Verified Expert Solution
Link Copied!

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 4 files into a project, building it and running it.
The files are:
a. UserData.h - this file defines what each node contains
b. LinkedList. h- 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 LL_Init, the AllocationCount has gone from 0 to 1. Why?
b. If the test code's first loop, what did the calls to LL_AddToFront do? How? Why
did the AllocationCount increase? Does the output printed data order make
sense?
C. After the test code's first call to LL__Delete the AllocationCount has gone back to
0. What dynamically allocated things have been freed? How?
d. After the test code's second call to LL_Init, there is a loop that calls
LL_AddAtEnd. What does LL_AddAtEnd do? Explain the AllocationCount.
When the data is printed out, does the data order make sense?
e. How do LL_GetAtIndex and LL_SetAtIndex work?
f. How did LL_Swap 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 LL_Delete is made, the AllocationCount has returned to 0.
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.
image text in transcribed

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

Step: 3

blur-text-image

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

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions