Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have a C++ dictionary red-black tree program that has 5 options which are 1. search, 2. edit, 3. add, 4. view, and 5. sort.

I have a C++ dictionary red-black tree program that has 5 options which are 1. search, 2. edit, 3. add, 4. view, and 5. sort. Can you please modify my view option and edit option. For "view" option, the program should ask the user "Words that start with letter: ___". When the user enters 'A', it should only display all the words starting with letter A including their meanings. For example:

user input: 4 (since view option is case 4) program output: "Words that start with letter: ____" user input: A program output:

  1. Abacus - an instrument for performing calculations by sliding counters along rods or in grooves

  2. Abandon - to give up to the control or influence of another person or agent

  3. Ability - the power or skill to do something

For edit option, the program should ask the user "Do you want to edit the word or edit the meaning?" If the user enters "word", the program will ask for the word then the user can enter the new spelling of the word. If the user enters "meaning", the program will ask for the word then the user can enter the new meaning.

user input: 2 (since edit option is case 2)

program output: Do you want to edit the word or edit the meaning? user input: word

program: enter the word user input: Abacus

program output: enter the new spelling of the word

user input: Abacuss

program output: successfully edited! Here is my code:

/* this is the whole code please run in any c++ compiler which supports c++14 */

/* i use map STL which is use red-black tree and elements are inserted are sorted by default*/

#include using namespace std;

int main() { mapword_dict; word_dict["Abacus"] = "an instrument for performing calculations by sliding counters along rods or in grooves"; word_dict["Abandon"] = "to give up to the control or influence of another person or agent"; word_dict["Baboon"] = "any of a genus (Papio) of large gregarious primates of Africa and southwestern Asia having a long square naked muzzle"; word_dict["Babble"] = "to talk enthusiastically or excessively"; word_dict["Cabaret"] = "a shop selling wines and liquors"; word_dict["Cache"] = "a hiding place especially for concealing and preserving provisions or implements"; map::iterator it; bool flag=true; while(flag) { cout<<"1. Search "; cout<<"2. Edit "; cout<<"3. Add "; cout<<"4. view "; cout<<"5. sort "; cout<<"6. Exit "; int ch; cin>>ch; string key,meaning; switch(ch) { case 1: cout<<"enter the word to be searched "; cin>>key; if(word_dict.find(key)!=word_dict.end()) { cout<<"found !! "; cout< "<>key; cout<<"enter the new meaning "; cin>>meaning; word_dict[key] = meaning; cout<<"changed sucessfully "; break; case 3: cout<<"enter the word to be added "; cin>>key; cout<<"enter the meaning "; cin>>meaning; word_dict[key] = meaning; cout<<"add sucessfully "; break; case 4: cout<<"dictonary elements are "; for(auto s:word_dict) cout<"<

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_2

Step: 3

blur-text-image_3

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

How To Make A Database In Historical Studies

Authors: Tiago Luis Gil

1st Edition

3030782409, 978-3030782405

More Books

Students also viewed these Databases questions