answersLogoWhite

0

This depends on whether the list is singly or doubly(or multiply) linked, and on the actual implementation of the list. For example, you can write a CDLL(circular doubly linked list) without maintaining your beginning or ending nodes, using only a current pointer, thus this question doesn't really apply as there would be no "last" node and thus it would be like deleting any node.

A typical implementation of a circular singly-linked list (CSLL) list actually maintains the pointer to the last element (hence it's FIFO nature) and thus there are both last and first nodes.

This deletion is a little tricky. Consider that you have situations where the next pointer will point to the current element. On the other hand, you also have a situation where there are n-values that you have to iterate over to find the next-to-last value. Typically you would delete the first node in these lists, again dictated by the FIFO nature of these lists, but deletion of the last node is also not impossible.

set struct node *last to list->end

if (list->end->next == list->end){

set list->end to null (leaving an empty list)

} else {

while(true){

if(last->next == list->end){

break

}

set last to last->next

}

set link->last to list->end->next (this temporarily sets list's end node to current first node)

free last->next (frees the last node)

set last->next to list->end (set the new last node next pointer to the first node)

set list->end to last (set the list's end node to the new last node)

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Write a algorithm for doubly linked list in c?

sorry


How do you write a Java program to implement weighted queue using circular doubly linked list?

Add weights to the elements of the queue and use an algorithm to sort the queue every time an element is added.


Write a program in C to create a Circular Linked list?

#include<iostream.h>


Write an algorithm for the implementation of a circular doubly linked list?

Create a new node, making sure it is not allocated locally in the function and thus will not be destroyed when the function execution finishesFill in dataUse the "last node" pointer in the list and copy the "next" pointer location (pointing to the first node) into the new nodes "next" pointerSet the "last node" "next" pointer to point to the new nodeChange the list's "last node" pointer to point to the new nodeFor an example of implementation see: How_you_insert_a_newnode_in_singly_circular_link_list


Write an Algorithm to delete a last element from the array?

// Assuming you dynamically allocated this array using "new"... delete array[arraysize - 1]; arraysize--;


How to write aC program to merge two singly linked list?

write a c program to circular queue


Explain Pseudo code for circular linked list?

write pseudocode for link list


Write an algorithm for inserting an element in a circular linked list?

Given a currentNode pointer, perform the following steps: Create a newNode. Assign currentNode->next to newNode->next. Assign currentNode to newNode->prev. Assign newNode to currentNode->next.


3 Write the algorithm of inserting an element at middle of a linked?

theory part to how u can insert element at middle of link list ?


Write an algorithm?

Algorithms are simply a set of steps to take in order to reach an answer. It is often linked with computer programming and can be written in plain english.


What is algorithm to write algorithm to the program to access a pointer variable in structure?

Here is the algorithm of the algorithm to write an algorithm to access a pointer in a variable. Algorithmically.name_of_the_structure dot name_of_the _field,eg:mystruct.pointerfield


Write an algorithm to find the root of quadratic equation?

Write an algorithm to find the root of quadratic equation

Trending Questions
WHAT IS EOF value in c? Why is collector current increased slowly with the increase of collector to emitter voltage of a common emitter? What is used to make a cast of a tool mark? What metal still has many uses because it is heat resistant but it is no longer widely used in new home construction.? Q 1 Name a device that helps to maintain the potential difference across a conductor? How do you initialize graphics mode in Borland Turbo Pascal 7.0? Can a Auto transformer have more load losses than its no load losses? What is the most resistance that can be in series with the capacitor if the capacitor is to charge to at least 88 percent of its final voltage in no more than 8.0 s? In VB Limit reached cannot create any controls in the form error has prompted can you be guided how to add more controls in that form? Engineering college rank list in tamilnadu? Why is a hammer a lever? What is another name for fashion design? Can mirrors be made out of recycled glass? What is the php code to close the existing window using button? How do you get rid of a cistern? Is algorithm a pictorial representation of flowchart? Where you will use krichoffs voltage law in our daily life? What are the systems used to step down energy so that it can be delivered to home or other building? What is methanol that produce from crude? When two or more transformers are interconnected with the positive terminal of each transformer connected to a phase and all the negative terminals are connected together what kind of interconnec?