# Implementation of Linked List

- Link: https://technotaught.com/linked-list/
- Published: 2018-11-10T19:22:08+05:30
- Author: Ashishkumar Vishwakarma

Before the implementation of Linked List, we first learn what is LL, Operation, 
and Types.

## Implementation of Linked List

Q. What is a linked list?
 ANS.: Collection of a node representing data and a next
pointer pointing to the next node.

Q. Operations performed on a linked list?
 ANS.: Creation, insertion, deletion, 
traversing, searching, concatenation, split, reversing and display.

Q. Advantages of a linked list? 
ANS.: Dynamic, memory-efficient & insertion and
deletion is faster.

Q. Types of the Linked list?
 ANS.: Linear, Circular & Doubly.

 Also, you can use c [compiler](https://ideone.com/fork/LcWvyH) to compile a program.

### Graphical Representation.

![Linked list.](https://technotaught.com/wp-content/uploads/2018/11/1_CrURRR67gmINv3bP5Y4ieQ.
png)

## Program.

### Source code.

    ```c
    //stack using linked list
    #include<stdio.h>
    #include<stdlib.h>

    struct node
    {
    	int data;
    	struct node * addr;
    };
    struct node * start;
    void ins(int);
    void del(int);void disp();	
    int main()
    {
    	printf("-insert-");
    	ins(10);
    	ins(20);
    	ins(15);
    	ins(30);
    	printf("\n-del-20");
    	del(20);
    	printf("\n-del-15");
    	del(15);


    }
    void ins(int val)
    {
    	struct node * temp,*curr,*prev ;
    	temp=(struct node *) malloc (sizeof (struct node));
    	temp -> data=val;
    	temp-> addr=NULL;

    	if(start==NULL)
    	{
    		start=temp;
    	}
    	else
    	{
    	curr =start;
    	prev = NULL;
    	while(curr!=NULL && curr->data<val)
    	{
    		prev= curr;
    		curr=curr->addr;
    	}
    	if(prev==NULL)
    	    {
    		start = temp;
    		 }
    	    else
    	   {
    	   prev->addr=temp;
    		}
    	  temp->addr=curr;                    

    	}

    	disp();
    }


    void disp()
      {
      	struct node * i=start;

      		printf("\nstack: ");
      		while(i!=NULL)
      		{
      			printf("%d ",i->data);
      			i=i->addr;
    		}

      }	
    	void del(int x)
    {
    	struct node *curr, *prev;
    	curr = start;
    	prev = start;
    	while(curr-> data!=x && curr!=NULL)
    	{
    		prev = curr;
    		curr = curr->addr;
    	}
    	if(curr == NULL)
    		printf("\nError : %d\n not found\n",x);
    	else if(curr == start)
    		start = curr->addr;
    	else
    		prev->addr = curr->addr;
    	disp();
    }
    ```

### Output.

> -insert-
> stack: 10stack: 10 20stack: 10 15 20stack: 10 15 20 30-del- 20stack: 
> 10 15 30-del- 15stack: 10 30

Also View – [Stack using Linked List](https://technotaught.com/stack-using-linkedlist/).

Also View – [Queue using a linked list](https://technotaught.com/stack-using-linkedlist/)
s.

Also View- [Write a java program to create a window using swing.](https://technotaught.com/22-write-a-java-program-to-create-a-window-using-swing/)

### Share this:

 * [  X ](https://technotaught.com/linked-list/?share=twitter)
 * [  Facebook ](https://technotaught.com/linked-list/?share=facebook)
 * [More](https://technotaught.com/linked-list/#)

 * [  WhatsApp ](https://technotaught.com/linked-list/?share=jetpack-whatsapp)
 * [  LinkedIn ](https://technotaught.com/linked-list/?share=linkedin)
 * [  Email ](https://technotaught.com/linked-list/?subject=%5BShared%20Post%5D%20Implementation%20of%20Linked%20List&body=https%3A%2F%2Ftechnotaught.com%2Flinked-list%2F&share=email)
 * [  Reddit ](https://technotaught.com/linked-list/?share=reddit)
 * [  Tumblr ](https://technotaught.com/linked-list/?share=tumblr)
 * [  Pinterest ](https://technotaught.com/linked-list/?share=pinterest)
 * [  Telegram ](https://technotaught.com/linked-list/?share=telegram)
 * [  Print ](https://technotaught.com/linked-list/#print?share=print)

### _Related_

## Comments

### By: Grace J

- Link: https://technotaught.com/linked-list/#comment-130
- Published: 2020-04-22T13:01:23+05:30

Incredible points. Sound arguments. Keep up the great work.
