Linked List
Linked List
Write functions to sort and finally delete the entire list at once.
#include <stdio.h>
#include <stdlib. h>
#include <conio.h>
#include <malloc. h>
struct node
{
int data;
struct node •next;
};
struct node *start = NULL;
struct node *create_ll(struct node *);
struct node *display(struct node *);
struct node *insert_beg(struct node *);
struct node *insert_end(struct node *);
struct node *insert_before(struct node *);
struct node *insert_after(struct node *);
struct node *delete_ beg(struct node *);
struct node *delete_end(struct node *);
struct node *delete_node( struct node *);
struct node *delete_after(struct node *);
struct node *delete_list(struct node *);
struct node *sort_list(struct node *);
e l se
ptr=start;
while(ptr->next ! =NULL)
ptr=ptr->next;
ptr->next = new_node;
new_node- >next=NULL;
return start;
return start;
else
while(ptr -> data != val)
{
preptr = ptr;
ptr = ptr - > next;
struct node *ptr; // Lines 252-254 were modified from original code to fix
unresposiveness in output window
if(start ! =NULL){
ptr=start;
while(ptr ! = NULL)
{
printf("\n %d is to be deleted next", ptr -> data);
start = delete_beg(ptr);
ptr = start;
return start;
Output
*****MAIN MENU
1: Create a list
2: Display the list
3: Add a node at the beginning
4: Add the node at the end
5: Add the node before a given node
6: Add the node after a given node
7: Delete a node from the beginning
8: Delete a node from the end
9: Delete a given node
10: Delete a node after a given node
11: Delete the entire list
12: Sort the list
13: Exit