Press "Enter" to skip to content

Linked List

Hello, Linear List is a linear data structure which keeps the every data separately. Arrays are static but Linked Lists has dynamic structure. We may have difficulty to add a data to the array but if we use linked lists, we can add the data where ever we want. Number of the data is not sure in the Linked Lists, we can add data or delete data whenever we want. Node is the location of the data in the linked list. Whenever we add a data this data called a node. If we in the last node, Last node next must be the show NULL value. There can be some disadvantages to use linked list instead of the using array. In the array, We can reach the data by pointing the location of the data but in the linked list we should route the all nodes to find the data. In this article, I will try to make Linked List application and in the application, I will try to add and delete data to the Linked List.

I will try to make this Linked List example using by the C programming language. After the creating our project, I add the neccessary libraries to the project. Like stdlib.h, thanks to this library, we can arrange the size of the memory using the malloc function. Now, I created a Node structure and in this structure, I keep the data and the point of the next node. In the main function, I created a root node and i arranged the memory size of the this root node using by the malloc. If there will not be a new data, node’s next must show the NULL. For that reason we make the root’s next equal to the NULL.

In the function, I am controlling the some conditions. If the node is NULL, i created a new node. The other condition is make the decision, if the number big add to the right, if data small add left. All the nodes connected to the each other and the last node always show the NULL.

I do not want to write printf all the time. For that reason, I write a function which shows the data of the linked list.

These are the codes of the Main function;

After the making adding process, we should write the deleting process. This function return a node. In the function, we will get the deleted data and then we will make the deleting process. These are the codes for the deleting process;

Main Function;

You can ask your questions via e-mail or comments.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *