Linked List

A linked list is a collection of data structures that are linked together.

A linked list is a series of links that contain items. Each link is connected to another link. After the array, the linked list is the most commonly used data structure. The following are key terms to comprehend the notion of Linked List.

It consists of 3 parts:-

(i) Link – A linked list’s links can each store data known as elements.

(ii) Next – Each link in a linked list encompasses a Next link to the next link.

(iii) First – A Linked List contains its connection link to the first link, which is called First.

Characteristics of Linked List:-

(i) The first link element in a Linked List is called the first.

(ii) Each link has a data field(s) as well as a link paddock called next.

(iii) Each link is connected to its next link via its next link.

(iv) To indicate the conclusion of the list, the last link contains a null link.

Types of Linked List :

  • Singly Linked List − Item navigation is forward only.
  • Doubly Linked List − Items can be navigated forward and backward.
  • Circular Linked List − The last item contains link of the first element as next and the first element has a link to the last element as the previous.

Basic Operations

Following are the basic operations supported by a list.

  • Insertion − Adds an element at the beginning of the list.
  • Deletion − Deletes an element at the beginning of the list.
  • Display − Displays the complete list.
  • Search − Searches an element using the given key.
  • Delete − Deletes an element using the given key.
  • Insert Last − Adds an element at the end of the list.
  • Delete Last − Deletes an element from the end of the list.
  • Insert After − Adds an element after an item of the list.
  • Delete − Deletes an element from the list using the key.
  • Display forward − Displays the complete list in a forward manner.
  • Display backward − Displays the complete list in a backward manner.

Singly Linked List – A Singly Linked List is a subset of a generic linked list. Each node in a single linked list links only to the next column in the sequence, therefore if we started traversing the list starting with the first node, we can only travel in one way.

Insertion – Following code explains inserion operation on singly linked list

#include<stdio.h>  

#include<stdlib.h>  

void beginsert(int);  

struct node  

{  

    int data;  

    struct node *next;  

};  

struct node *head;  

void main ()  

{  

    int choice,item;  

    do   

    {  

        printf(“\nEnter the item which you want to insert?\n”);  

        scanf(“%d”,&item);  

        beginsert(item);  

        printf(“\nPress 0 to insert more ?\n”);  

        scanf(“%d”,&choice);  

    }while(choice == 0);  

}  

void beginsert(int item)  

    {  

        struct node *ptr = (struct node *)malloc(sizeof(struct node *));  

        if(ptr == NULL)  

        {  

            printf(“\nOVERFLOW\n”);  

        }  

        else  

        {  

            ptr->data = item;  

            ptr->next = head;  

            head = ptr;  

            printf(“\nNode inserted\n”);  

        }  

    }  

Deletion – Following code demonstrate deletion operation.

#include<stdio.h>  

#include<stdlib.h>  

void create(int);  

void begdelete();  

struct node  

{  

    int data;  

    struct node *next;  

};  

struct node *head;  

void main ()  

{  

    int choice,item;  

    do   

    {  

        printf(“\n1.Append List\n2.Delete node\n3.Exit\n4.Enter your choice?”);  

        scanf(“%d”,&choice);  

        switch(choice)  

        {  

            case 1:  

            printf(“\nEnter the item\n”);  

            scanf(“%d”,&item);  

            create(item);  

            break;   

            case 2:  

            begdelete();  

            break;   

            case 3:  

            exit(0);  

            break;    

            default:  

            printf(“\nPlease enter valid choice\n”);  

        }  

    }while(choice != 3);  

}  

void create(int item)  

    {  

        struct node *ptr = (struct node *)malloc(sizeof(struct node *));  

        if(ptr == NULL)  

        {  

            printf(“\nOVERFLOW\n”);  

        }  

        else  

        {  

            ptr->data = item;  

            ptr->next = head;  

            head = ptr;  

            printf(“\nNode inserted\n”);  

        }  

    }  

void begdelete()  

    {  

        struct node *ptr;  

        if(head == NULL)  

        {  

            printf(“\nList is empty”);  

        }  

        else   

        {  

            ptr = head;  

            head = ptr->next;  

            free(ptr);  

            printf(“\n Node deleted from the begining …”);  

        }  

    }  

0

3,561 thoughts on “Linked List”

  1. The other day, while I was at work, my sister stole my apple
    ipad and tested to see if it can survive a 30 foot drop, just so she can be
    a youtube sensation. My iPad is now destroyed and
    she has 83 views. I know this is totally off topic but I
    had to share it with someone!

    0
  2. Good ?V I should certainly pronounce, impressed with your site. I had no trouble navigating through all the tabs and related information ended up being truly easy to do to access. I recently found what I hoped for before you know it at all. Reasonably unusual. Is likely to appreciate it for those who add forums or something, site theme . a tones way for your customer to communicate. Nice task..

    0
  3. Its like you learn my thoughts! You seem to know so much approximately this, such as you wrote the e-book in it or something. I believe that you simply can do with a few p.c. to power the message home a bit, however instead of that, this is fantastic blog. An excellent read. I will definitely be back.

    0
  4. Thanks , I’ve just been looking for information about this subject for a while
    and yours is the best I’ve discovered till now. However, what
    concerning the conclusion? Are you certain about the supply?

    0
  5. Throughout this grand pattern of things you’ll secure a B+ with regard to effort. Exactly where you misplaced everybody was first on the facts. As they say, the devil is in the details… And that could not be more true at this point. Having said that, allow me inform you what did give good results. The article (parts of it) can be quite powerful and this is probably the reason why I am taking the effort in order to comment. I do not make it a regular habit of doing that. 2nd, even though I can easily notice a leaps in logic you make, I am definitely not sure of how you seem to connect your points which in turn make the actual final result. For the moment I shall subscribe to your issue but wish in the foreseeable future you link the facts much better.

    0
  6. Just desire to say your article is as amazing. The clarity in your post is just cool and i can assume you’re an expert on this subject. Well with your permission allow me to grab your feed to keep updated with forthcoming post. Thanks a million and please keep up the gratifying work.

    0
  7. I don’t know whether it’s just me or if everyone else encountering issues with your
    blog. It appears like some of the text on your posts are running off the screen. Can somebody else please provide feedback and let me
    know if this is happening to them too? This may be a problem with my
    browser because I’ve had this happen before.
    Thanks

    0
  8. Unquestionably imagine that that you stated. Your favorite reason appeared to be at the net the easiest factor to be mindful of.
    I say to you, I certainly get annoyed while folks consider worries
    that they just do not know about. You controlled to hit the nail upon the highest and also defined out the whole
    thing without having side-effects , other folks could take a signal.
    Will probably be back to get more. Thank you

    0
  9. Read our guide on toss predictions to learn how we analyze and come up with our tips. These teams are not close in the NHL standings, as the Stars are one of the best teams in the Western Conference, and that isn’t the case for the Ducks. There could always be some surprises when betting on the NHL, but this game appears to be a mismatch. Spear Gaming are listed as the favorites of the match in the majority of bookmakers and odds on them are equal to 2.108. World Game Star, in turn, are the outsiders of the match. Odds on their victory are about 3.396. Team Stewart All-Star Starting 5️⃣ Above football betting tips are created for the 1X2 market, or Win-Draw-Win (Home-Draw-Away) for the final of each match. The 1X2 betting market is the most common betting options on football, where punters can choose the winner of the winner of the match at the end of the match. This is not a correct score market, but rather the option of choosing one team as a winner or the draw result. Hence, there are 3 options available to choose from here: 1 – home team to win, X – draw, 2 – away team to win.
    http://thefreeworldpress.com/forums/topic/9034/why-live-streaming-apps-are-so-popular/view/post_id/15035?mobile=0
    No sport is more popular in betting markets than American football, and no league inspires more wagering than the NFL. If you are reading this, you are probably interested in throwing your hat into the ringing and joining the fun. Well, you have come to the right place. We are here to help you bet better on the NFL, not only by explaining how it works but also with a plethora of tips to win. Tom Hatfield of Razor Sharp Sports has been a top sports handicapper and has been seen and heard on national sports radio & TV shows since 1993. He has taken his knowledge of sports, combined with technology to give him the added advantage to be the sharpest handicapper in the country. Razor Sharp Sports has become the most educated sports service in the country, offering free football picks, free basketball picks, and free baseball picks all year long. Tom has hosted and appeared on the FreePlays Radio Show. He hosts the Fantasy King Sports Hour and has also appeared on the Pro Line Sports Show on the USA Network.

    0