Algorithms_in_C 1.0.0
Set of algorithms implemented in C.
|
Implementation of Doubly linked list More...
#include <stdio.h>
#include <stdlib.h>
Data Structures | |
struct | list |
Doubly linked list struct. More... | |
Typedefs | |
typedef struct list | List |
Doubly linked list struct. | |
Functions | |
List * | create (double value) |
Create list function, a new list containing one node will be created. | |
List * | insert (List *list, double value, int pos) |
Insertion by position into the list function. | |
List * | delete (List *list, int pos) |
Deletion by position into the list function. | |
int | search (List *list, double value) |
Search value into the list function. | |
void | print (List *list) |
Print list function. | |
void | example () |
Example function. | |
int | main () |
Main function. | |
Implementation of Doubly linked list
A doubly linked list is a data structure with a sequence of components called nodes. Within that nodes there are three elements: a value recorded, a pointer to the next node, and a pointer to the previous node.
In this implementation, the functions of creating the list, inserting by position, deleting by position, searching for value, printing the list, and an example of how the list works were coded.
List * create | ( | double | value | ) |
Create list function, a new list containing one node will be created.
value | a value to be saved into the first list node |
Deletion by position into the list function.
list | a doubly linked List |
pos | a position into the list for value Deletion |
void example | ( | ) |
Example function.
Insertion by position into the list function.
list | a doubly linked List |
value | a value to be inserted into the list |
pos | a position into the list for value insertion |
int main | ( | void | ) |
void print | ( | List * | list | ) |
int search | ( | List * | list, |
double | value | ||
) |
Search value into the list function.
list | a doubly linked list |
value | a value to be looked for into the list |
1
if the looked up value exists 0
if the looked up value doesn't exist