Linked List Implementation

5
LINKED LISTS IMPLEMENTATION MARIA SHAIKH LINKED LISTS IMPLEMENTATION IN C++ TRAVERSING IN LINKED LIST It uses array to store info part and link part in implementation so it starts from 0 to N-1 terms. Input can also be given at Run time then there you can have array length from 1 to N terms. -1 (negative number shows null pointer). Linked Lists to be Implemented in Traversing: INFO LINK 5 START

description

DATA STRUCTURES AND ALGORITHM ANALYSIS

Transcript of Linked List Implementation

  • LINKED LISTS IMPLEMENTATION MARIA SHAIKH

    LINKED LISTS IMPLEMENTATION IN C++

    TRAVERSING IN LINKED LIST

    It uses array to store info part and link part in implementation so it starts from 0 to

    N-1 terms. Input can also be given at Run time then there you can have array

    length from 1 to N terms. -1 (negative number shows null pointer).

    Linked Lists to be Implemented in Traversing:

    INFO LINK

    5

    START

  • LINKED LISTS IMPLEMENTATION MARIA SHAIKH

    IMPLEMENTATION OF TRAVERSING:

    #include

    using namespace std;

    int main()

    {

    char info[9]={'a','b','c','d','e','f','g','h','i'};

    int link[9]={8,7,0,6,1,2,-1,3,4};

    int start=5;

    int ptr=start;

    while (ptr!=-1)

    {

    cout

  • LINKED LISTS IMPLEMENTATION MARIA SHAIKH

    Implementation of Inserting a node at the beginning of the

    list:

    #include

    using namespace std;

    const int size=10;

    int main()

    {

    int info[size]={1,0,0,4,0,6,0,0,0,0};

    int link[size]={-1,4,1,0,6,3,7,8,9,-1};

    int start=5,avail=2;

    int item,ptr,newnode;

    cout

  • LINKED LISTS IMPLEMENTATION MARIA SHAIKH

    while(ptr!=-1)

    {

    cout

  • LINKED LISTS IMPLEMENTATION MARIA SHAIKH

    ptr=link[ptr];

    }

    return 0;

    }