answersLogoWhite

0


Best Answer

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

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you delete a node in linklist without traversing?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Steps of algorithum for delete node in linklist?

To delete a node (this) in a linked list, first you need to find the address of the parent node (parent).Iterate through the list, checking to find if the head pointer (head) or a child node (parent) points to (this).Store the next pointer of (this) in (parent) or (head), as determined by step 2.Delete (this).


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.


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;


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.

Related questions

Can you insert a node at any place in linklist without traversing it?

Yes, with limitations... If you have the address of a node in the linklist, you can insert a node after that node. If you need to insert the node before that node, you need to traverse the list, unless the linklist is a doubly-linkedlist


Steps of algorithum for delete node in linklist?

To delete a node (this) in a linked list, first you need to find the address of the parent node (parent).Iterate through the list, checking to find if the head pointer (head) or a child node (parent) points to (this).Store the next pointer of (this) in (parent) or (head), as determined by step 2.Delete (this).


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.


Explain the difference between depth first and breadth first traversing techniques of a graph?

In depth first traversing, the node that is below the current node is considered first. For breadth first traversing, the node to the rightmost of the current mode is considered.


What is the difference between circular linklist and linklist?

In a circular linked list every node is connected to another node. In a non-circular linked list. There are definitely starting and ending nodes are lacking an incoming and outgoing link, respectively.


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;


What is the difference between sax and dom?

Both SAX and DOM are used to parse the XML document. Both has advantages and disadvantages and can be used in our programming depending on the situation SAX: 1. Parses node by node 2. Doesnt store the XML in memory 3. We cant insert or delete a node 4. Top to bottom traversing DOM 1. Stores the entire XML document into memory before processing 2. Occupies more memory 3. We can insert or delete nodes 4. Traverse in any direction. If we need to find a node and doesnt need to insert or delete we can go with SAX itself otherwise DOM provided we have more memory.


What is the difference between height and depth of a tree?

height and depth of a tree is equal... but height and depth of a node is not equal because... the height is calculated by traversing from leaf to the given node depth is calculated from traversal from root to the given node.....


Algorithm in creating delete method in linked list?

To delete an node in a linked list...If the head node is empty, stop, and return failed.Interate thorugh each member of the list.Remember at each iteration, the address of the privious node.If the current node is the head node or not the desired node, continue to the next iteration.Move the current node's pointer value to the previous node's pointer.Delete the current node, and return success.Return failed..


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.


I have a C plus plus project Visual binary search tree showing traversing graphically . . Can someone explain what it means?

It means you have to represent the tree graphically, much like a family tree, such that when traversing the tree you highlight the currently active node in some way.