In C program. implement list_get( list_t* list, unsigned int position ) function /* * 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: Returns a pointer to the element (i.e., to the node) at * "position" in the data structure pointed to by "list". * The head of "list" is at "position" 0, the first element * (node) in "list" is at "position" 1, etc. Returns NULL * if "position" is out of range. Returns NULL if "list" is NULL. * This function does not modify the data structure. * Time efficiency: O(n) */ element_t* list_get( list_t* list, unsigned int position ){ element_t* anElement = NULL;   // 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_get(...): getting element (node) at position %u in the list.\n", position );   return anElement; }

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
Question
In C program. implement list_get( list_t* list, unsigned int position ) function
/*
* 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: Returns a pointer to the element (i.e., to the node) at
* "position" in the data structure pointed to by "list".
* The head of "list" is at "position" 0, the first element
* (node) in "list" is at "position" 1, etc. Returns NULL
* if "position" is out of range. Returns NULL if "list" is NULL.
* This function does not modify the data structure.
* Time efficiency: O(n)
*/
element_t* list_get( list_t* list, unsigned int position ){

element_t* anElement = NULL;
 

// 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_get(...): getting element (node) at position %u in the list.\n", position );
 
return anElement;
}
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Linked List Representation
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