n C program. /* * dataStructure.h * * Provides a data structure made of a doubly-headed singly-linked list (DHSL) * of unsorted elements (integers) in which duplicated elements are allowed. * * A DHSL list is comprised of a single header and zero or more elements. * The header contains pointers to the first and last elements in the list, * or NULL if the list is empty. The first element contains a pointer to * the next element, and so on. The last element in the list has its * "next" pointer set to NULL. * * The interface of this data structure includes several utility * functions that operate on this data structure. * * Precondition: Functions that operate on such data structure * require a valid pointer to it as their first argument. * * Do not change this dataStructure.h file. * */ /*** Data structure ***/ /* List element (node): our DHSL list is a chain of these nodes. */ typedef struct element { int val; structelement*next; } element_t; /* List header: keeps track of the first and last list elements as well as the number of elements stored in our data structure. */ typedef struct list { element_t* head; element_t* tail; unsignedint elementCount; } list_t; /*** Data structure interface ***/ /* A type for returning status codes */ typedef enum { OK, ERROR, NULL_PARAM } result_t; //dataStructure.c   /* Description: Appends a new element, i.e., a node containing "newElement", * to this data structure pointed to by "list" and returns OK. * If "newElement" cannot be appended, leaves the * data structure unmodified and returns ERROR. * Returns NULL_PARAM if "list" is NULL. * Time efficiency: O(1) */ result_t list_append( list_t* list, int newElement ) {   result_t result = OK;   // Stubbing this function // This stub is to be removed when you have successfully implemented this function, i.e., // ***Remove this call to printf!*** printf( "Calling list_append(...): appending newElement %d to list.\n", newElement );   return result; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question
In C program.
/*
* dataStructure.h
*
* Provides a data structure made of a doubly-headed singly-linked list (DHSL)
* of unsorted elements (integers) in which duplicated elements are allowed.
*
* A DHSL list is comprised of a single header and zero or more elements.
* The header contains pointers to the first and last elements in the list,
* or NULL if the list is empty. The first element contains a pointer to
* the next element, and so on. The last element in the list has its
* "next" pointer set to NULL.
*
* The interface of this data structure includes several utility
* functions that operate on this data structure.
*
* Precondition: Functions that operate on such data structure
* require a valid pointer to it as their first argument.
*
* Do not change this dataStructure.h file.
*
*/


/*** Data structure ***/

/* List element (node): our DHSL list is a chain of these nodes. */
typedef struct element {
int val;
structelement*next;
} element_t;

/* List header: keeps track of the first and last list elements
as well as the number of elements stored in our data structure. */
typedef struct list {
element_t* head;
element_t* tail;
unsignedint elementCount;
} list_t;



/*** Data structure interface ***/

/* A type for returning status codes */
typedef enum {
OK,
ERROR,
NULL_PARAM
} result_t;
//dataStructure.c
 
/* Description: Appends a new element, i.e., a node containing "newElement",
* to this data structure pointed to by "list" and returns OK.
* If "newElement" cannot be appended, leaves the
* data structure unmodified and returns ERROR.
* Returns NULL_PARAM if "list" is NULL.
* Time efficiency: O(1)
*/
result_t list_append( list_t* list, int newElement ) {
 
result_t result = OK;
 
// Stubbing this function
// This stub is to be removed when you have successfully implemented this function, i.e.,
// ***Remove this call to printf!***
printf( "Calling list_append(...): appending newElement %d to list.\n", newElement );
 
return result;
}
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Types of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education