Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Note that the sort_ascending() function must be implemented using the recursive Merge Sort algorithm . sort_descending() can utilize Merge Sort or a different algorithm class
Note that the sort_ascending() function must be implemented using the recursive Merge Sort algorithm . sort_descending() can utilize Merge Sort or a different algorithm
class Node { public: }; int val; // the value that this node stores Node *next; // a pointer to the next node in the list // you can add constructors or other functionality if you find it useful or necessary Note: Node is being used akin to a struct (with public member variables). This is intentional so that you can easily modify the member variables from within the Linked_List class. class Linked_List { private: unsigned int length; // the number of nodes contained in the list Node *head; // a pointer to the first node in the list // anything else you need... public: int get_length(); // note: there is no set_length (unsigned int) (the reasoning should be intuitive) void print(); // output a list of all integers contained within the list void clear(); // delete the entire list (remove all nodes and reset length to 0) void push_front(int); // insert a new value at the front of the list void push_back(int); // insert a new value at the back of the list void insert(int val, unsigned int index); // insert a new value in the list at the specif ied index void sort_ascending(); // sort the nodes in ascending order. You must implement the recur sive Merge Sort algorithm // Note: it's okay if sort_ascending() calls a recursive private function to perform the sorting. }; void sort descending(); // sort the nodes in descending order // you can add extra member variables or functions as desired int count prime (const Linked_List&); // count and return the number of prime numbers within the list
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started