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; }

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter13: Structures
Section13.5: Dynamic Data Structure Allocation
Problem 6E
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning