## Deletion of an element from the linked list, Data Structure & Algorithms

Assignment Help:

ALGORITHM (Deletion of an element from the linked list)

Step 1  Begin

Step 2  if the list is empty, then element cannot be deleted

Step 3  else, if the element to be deleted is the first node, then make the start (head) point to the second element.

Step 4  else, Remove the element from list by calling a find function & returning the found address of the element.

Step 5 End

DELETE_LIST FUNCTION

/* prototype of delete_function */

list *delete_list(list *);

list *find(list *, int);

/*definition of delete_list */

list *delete_list(list *start)

{

int key; list * f, * temp;

printf("\n Insert the element to be purged \n");

scanf("%d", &key);

if(start->data == key)

{

temp=start->next;

free(start); start=temp;

}

else

{

f = find(start,key);

if(f==NULL)

else

{

temp = f->next->next;

free(f->next);

f->next=temp;

}

}

return(start);

}

void main()

{

void create(list *);

int count(list *);

void traverse(list *);

printf(" \n traverse created list \n");

printf("\n number of elements within the list   %d \n", count(head));

printf(" \n traverse list after adding desiredelement \n");

printf(" \n traverse list after delete_list \n");

}

Program: Deletion of any element from the linked list by searching for element i.e. to be deleted

#### Luminous Jewels - The Polishing Game, Byteland county is very famous for lu...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

#### Queues, Queue is a linear data structure utilized in several applications o...

Queue is a linear data structure utilized in several applications of computer science. Such as people stand in a queue to get a specific service, several processes will wait in a q

#### Data flow diagrams, How to construct a data flow diagram for a college assi...

How to construct a data flow diagram for a college assignment and marking systemA

#### Several operations on a aa-tree, The following are several operations on a ...

The following are several operations on a AA-tree: 1. Searching: Searching is done using an algorithm which is similar to the search algorithm of a binary search tree. 2. Ins

#### Tree traversals, There are three kinds of tree traversals, namely, Postorde...

There are three kinds of tree traversals, namely, Postorder , Preorder and Inorder. Preorder traversal: Each of nodes is visited before its children are visited; first the roo

#### Depth first search and breadth first search, Q. Illustrate the result of ru...

Q. Illustrate the result of running BFS and DFS on the directed graph given below using vertex 3 as source.  Show the status of the data structure used at each and every stage.

#### Merging, Merging two sequence using CREW merge

Merging two sequence using CREW merge

#### Splaying algorithm, Insertion & deletion of target key requires splaying of...

Insertion & deletion of target key requires splaying of the tree. In case of insertion, the tree is splayed to find the target. If, target key is found out, then we have a duplicat

#### Average case anaysis, what is the impoartance of average case analysis of ...

what is the impoartance of average case analysis of algorithm

#### File organization, Define File organization''s and it''s types

Define File organization''s and it''s types