answersLogoWhite

0

assuming a circular, doubly linked list that uses its
head pointer as a sentinel (no data is stored in the
head).

#define PTR_SWAP(a, b) \
do { \

const void* t = a; a = b; b = (void*)t; \

} while (0)


void
listReverse(list_type* list) {
node_type* node = list->head;

do {

PTR_SWAP(node->prev, node->next);

node = node->prev;

} while (node != list->head);

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Using recursion reverse a singly linked list?

Let's suppose your list consists of elements that have an integer part (the data) and a reference (or pointer) to the next list element.Now your function would look like this:void Reverse(listitem){if(listitem.next exists) //you have to check this in a way depending on your implementationReverse(listitem.next); //the function goes right onto the next elementprint(listitem.data); //or do anything that is needed}In a nutshell, this function first explores the whole linked list, and when it reaches the end, the individual function calls reach the data processing block, and then terminate, thus giving the control back to the previous listelement's function call.


How can you make out whether two files are copied or linked in unix?

Use the long listing function of 'ls'. You will see a link count > 1 and a reference to where the file is linked to if it is a link. Without a link it is a copy.


Are the Reverse Lights on 94' Tarus linked to the Transmission?

The reverse lights on a 94' Ford Taurus are linked to the transmission to indicate when the vehicle is moving backwards. This is done for safety reasons as cars are typically moving forward.


What is the time complexity of inserting an element into a linked list?

The time complexity of inserting an element into a linked list is O(1) or constant time.


Convert single linked list to double linked list?

You copy a singly linked list into a doubly linked list by iterating over the singly linked list and, for each element, calling the doubly linked list insert function.


What is the minimum number of additional pointers will be needed to reverse a singly linked list?

3 pointers...


What are the roles of N-linked and O-linked glycosylation in protein structure and function?

N-linked glycosylation helps with protein folding, stability, and recognition of the protein by other molecules. O-linked glycosylation can affect protein function by regulating protein activity, localization, and interactions with other molecules. Both types of glycosylation play important roles in modifying protein structure and function.


What term is used to describe when two functions are linked together by using output of the first function as input of second function?

function composition


What is required for an individual to have a sex-linked disorder?

A sex-linked disorder is when a mutation of genes overrides the normal function of a another gene. For example, male-pattern baldness is a sex-linked disorder.


What system is the digestive system linked to?

The digestive system is linked directly to the excretory system via the liver. This organ serves an important function in both systems.


What term describes two functions linked together by using output of the first function and input of second function?

Chained or nested functions.


Which function removes last element in a list?

If you are using the doubly-linked list from the STL library, then the function call:name_of_list.push_back();should delete the last element.