Skip to content

Latest commit

 

History

History

singly-linked-list

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Singly Linked List

list.c

struct data {
  unsigned int key;
  int value;
};

struct node {
  struct data *data;
  struct node *next;
};

list.h

Creates a linked list.

Node* create(void);

Inserts a node at the beginning of the list.

void insertFirst(Node **head, unsigned int key, int value);

Inserts a node at the end of the list.

void insertLast(Node *head, unsigned int key, int value);

Finds the last node of the list.

Node* findLast(Node *head);

Finds a node with the specified key.

Node* findNode(Node *head, unsigned int key);

Updates the value of a node with the specified key.

void updateNode(Node *head, unsigned int key, int value);

Removes the first node from the list.

void removeFirst(Node **head);

Removes the last node from the list.

void removeLast(Node **head);

Removes the node with the specified key.

void removeNode(Node **head, unsigned int key);

Reverses the order of nodes in the list.

void reverseList(Node **head);

Prints all nodes in the list.

void printList(Node *head);

Prints all nodes in the list in reverse order.

void printReverse(Node *head);

Prints the value of a node.

void printNode(Node *node);

Checks if the list is empty.

bool isEmpty(Node *head);

Calculates the length of the list.

unsigned int length(Node *head);

Calculates the sum of the values ​​in the list.

unsigned int sum(Node *head);

Sorts the list based on values ​​in ascending order.

void sortList(Node *head);