Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So I have a linked list with each node containing a word, letter count of the word, and how many times that word has been

So I have a linked list with each node containing a word, letter count of the word, and how many times that word has been used. I sorted it by letter count on insertion already, but now I need to sort it by times used within each individual letter count section and I am having trouble. I got it to traverse to the part of the list that needs to be sorted, but I have no clue how to actually sort this subsection

here is the relevant code to it:

class Node{ public: string word; Node* next; short int letterCount; short int timesUsed=1; };

class LinkedList{ public: Node* head; LinkedList(); void insert(string word); void sort(); string search(int lettersUsed, int timesUsed); void printList(); };

void LinkedList:: sort(){ Node *temp=head; bool wentin; while (temp->next!=NULL) { wentin=false; while (temp->letterCount==temp->next->letterCount) { //sort by times used here temp=temp->next; if (temp->next==NULL) { wentin=true; break; } } if (wentin==true) { break; } temp=temp->next; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxxviii Special Issue On Database And Expert Systems Applications Lncs 11250

Authors: Abdelkader Hameurlain ,Roland Wagner ,Sven Hartmann ,Hui Ma

1st Edition

3662583836, 978-3662583838

More Books

Students also viewed these Databases questions

Question

i need 6 7 7 .

Answered: 1 week ago