answersLogoWhite

0

To delete a node (this) in a linked list, first you need to find the address of the parent node (parent).

  1. Iterate through the list, checking to find if the head pointer (head) or a child node (parent) points to (this).
  2. Store the next pointer of (this) in (parent) or (head), as determined by step 2.
  3. Delete (this).
User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve
RossRoss
Every question is just a happy little opportunity.
Chat with Ross
BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake

Add your answer:

Earn +20 pts
Q: Steps of algorithum for delete node in linklist?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you delete a node in linklist without traversing?

If you don't already have a reference to the node, there is no way to avoid traversing the list to find it.


Algoritm for deleting the last element from a list?

Given a list and a node to delete, use the following algorithm: // Are we deleting the head node? if (node == list.head) { // Yes -- assign its next node as the new head list.head = node.next } else // The node is not the head node { // Point to the head node prev = list.head // Traverse the list to locate the node that comes immediately before the one we want to delete while (prev.next != node) { prev = prev.next; } end while // Assign the node's next node to the previous node's next node prev.next = node.next; } end if // Before deleting the node, reset its next node node.next = null; // Now delete the node. delete node;


Difference between circular and single linklist?

A regular linked list will have a pointer to the start of the list, with each node pointing to the next node, and finally the last node points to NULL. In a circular linked-link, the last node will point to the first node, making the list circular. This requires extra checks to ensure that you don't end up going into an infinite loop while traversing the list.


What operation is supported in constant time by the doubly linked list but not by the singly linked list?

examples:- delete this node (identified by a pointer)- insert a new node before this node- replace this node with another node


Can you delete the head node from doubly linked list?

If by 'head node' you simply mean the first node, then yes; but if 'head node' means the special element which is not supposed to ever be deleted (aka sentinel node), then no.