M.A.M. SCHOOL OF ENGINEERING, SIRUGANUR, TIRUCHIRAPPALLI – 621 105.
Department of Computer Science and Engineering
Department of Computer Science and Engineering
LABORATORY MANUAL – CS 2208 – DATA STRUCTURES LABORATORY
LABORATORY MANUAL – CS 2208 – DATA STRUCTURES LABORATORY
EX: NO: 1 (a)
SINGLY LINKED LIST
AIM:
Step 3:Stop
PROGRAM :
To write a Program to implement a single linked list
ALGORITHM:
Step 1: Start
Step 2:Read the value of ch
Step 3:If ch=1 call create list functions
Step 4:If ch=2 call insert list functions
Step 5:If ch=3 call delete list functions
Step 6:If ch=4 call view list functions
Step 7:Repeat while (ch!=5)
Step 8:Stop
ALGORITHM FOR CREATE LIST
Step 1: Read value of item
Step 2:Allocate the memory far new node
Step 3:Assign values to new node data part
Step 4:Assign new node address part as null
ALGORITHM FOR INSERT LIST
Step 1: Read the value of item
Step 2:Allocate the memory far new node
Step 3:Assign values of data field as null else make link fields of all new nodes to point
Step 4:starting node to new node
Step 5:Set the external pointer from the starting node to new node
ALGORITHM FOR DELETE LIST
Step 1:If the link is empty then return else check whether the list contains more than one element
Step 2:Move the start pointer to the next node
Step 3:Free the first node
ALGORITHM FOR VIEW LIST
Step 1:Using the for loop i
Step 2:Print the linked list
#include
#include
#include struct node
{
int item; struct node *link;
};
typedef struct node NODE;
NODE *head;
NODE *getnode(); void readnode(NODE *newnode); void createlist(); void insertfirst(); void deletefirst(); void viewlist(); void main()
{
int ch; clrscr(); printf("\n\n\t\t SINGLY LINKEDLIST\n"); printf("\t\t *****************\n"); do { printf("\n 1.CREATE LIST"); printf("\n 2.INSERT FIRST"); printf("\n 3.DELETE FIRST");
printf("\n