Explore BrainMass
Share

Writing a Function that Revises a List

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

Imagine a circular linked list of integers that are sorted into ascending order as shown in the attached file.

The external pointer list points to the last node, which contains the largest integer.

Write a function that revises the list so that its data are sorted into descending order as shown in the attached file.

Do not allocate or deallocate nodes.

See attached file for diagrams.

© BrainMass Inc. brainmass.com March 21, 2019, 10:37 pm ad1c9bdddf
https://brainmass.com/computer-science/cpp/writing-function-that-revises-list-424710

Attachments

Solution Preview

Problem: Imagine a circular linked list of integers that are sorted into ascending order as shown in the attached file. The external pointer list points to the last node, which contains the largest integer. Write a function that revises the list so that its data are sorted into descending order as shown in the attached file. Do not allocate or deallocate nodes.

Solution:

Suppose for each node of the linked list, I have the following definition.
class Node {
int value; ...

Solution Summary

This solution helps write a function that revises an external pointer list (of a circular list of integers sorted in ascending order) so that its data is sorted into descending order.

$2.19