[SOLVED] print all words using iterator

I’m working on a Computer Science question and need guidance to help me study.

Struggling to find relevant content or pressed for time? – Don’t worry, we have a team of professionals to help you on
[SOLVED] print all words using iterator
Get a 15% Discount on this Paper
Order Now

In this lab, you will implement 3 functions that use iterators to answer questions about prefix trees. The functions you need to implement are as follows:

  • void print_all_words_with_iterator(const PrefixTree& pt): prints all of the words in the given prefix tree
  • int rank_word_with_iterator(string word, const PrefixTree& pt): returns the rank of the given word in the prefix tree (1 if it’s the first word, 2 if it’s the second, etc.); return -1 if word is not in the tree
  • void print_common_words_with_iterators(const PrefixTree& lhs, const PrefixTree& rhs): prints all of the words that are in both of the given trees

You have been provided with an implementation of a PrefixTree that features an iterator (but no printAllWords member function). You can create the iterator with the begin() and end() member functions of PrefixTree: begin() starts with the first word in the tree alphabetically, and end() is an empty string after the last word in the tree. This iterator is an output iterator: it can output a single string when dereferenced, and it will move to the next string in sorted order when incremented, but it cannot be used to modify the PrefixTree. The PrefixTreeIterator only supports the prefix increment operator (++it), not the postfix increment operator (it++).

You have also been provided with a driver file to help you get started. You should submit the driver file with implementations of the 3 functions above filled in. The new driver will call print_all_words_with_iterator when you type “list” at the prompt, rank_word_with_iterator when you type “rank [word]”, and print_common_words_with_iterator when you type “compare [tree]”. The tree should be typed either the same way that it gets printed by “print” or as a comma-separated list of words in parentheses (no spaces!). The driver also supports the command “input [tree]” which clears the words in the current tree and replaces it with the given tree.

Files:

Example test cases:

input (bE(D,E,sT),caT)

list

rank best

rank worst

compare (b(a(R,T),EsT),ca(RT,T),doG)

Expected output for list (print_all_words_with_iterator):

be

bed

bee

best

cat

Expected output for rank best (rank_word_with_iterator): best is rank 4 alphabetically

Expected output for rank worst: worst has been not added

Expected output for compare (print_common_words_with_iterators):

be

best

cat

<a href="https://usflearn.instructure.com/courses/1347249/modules/items/14743245" role="button" class="Button module-sequence-footer-button–previous" data-tooltip="right" data-html-tooltip-title=" Lecture 19: Introduction to the STL” aria-describedby=”msf1-previous-desc”>PreviousNext

Calculate the price
Make an order in advance and get the best price
Pages (550 words)
$0.00
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
Sign up, place your order, and leave the rest to our professional paper writers in less than 2 minutes.
step 1
Upload assignment instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
s
Get personalized services with MyCoursebay
One writer for all your papers
You can select one writer for all your papers. This option enhances the consistency in the quality of your assignments. Select your preferred writer from the list of writers who have handledf your previous assignments
Same paper from different writers
Are you ordering the same assignment for a friend? You can get the same paper from different writers. The goal is to produce 100% unique and original papers
Copy of sources used
Our homework writers will provide you with copies of sources used on your request. Just add the option when plaing your order
What our partners say about us
We appreciate every review and are always looking for ways to grow. See what other students think about our do my paper service.
Other
GREAT
Customer 452813, June 20th, 2022
Nursing
Thank you!
Customer 452707, June 29th, 2022
Other
NICE
Customer 452813, June 30th, 2022
Social Work and Human Services
Excellent Work
Customer 452587, November 22nd, 2021
History
thank you so much for the help, I really appreciate that.
Customer 452725, February 13th, 2022
Nursing
Thank you for a great paper!!
Customer 452707, November 28th, 2022
Nursing
Great work! Thank you so much.
Customer 452707, July 15th, 2022
Philosophy
The paper is great. Will definitely use again.
Customer 452773, May 24th, 2022
Other
GREAT
Customer 452813, June 25th, 2022
Other
GREAT
Customer 452813, June 25th, 2022
Social Work and Human Services
Perfect. Thank you.
Customer 452469, July 10th, 2021
Nursing
Great writer (Proske). I highly recommend
Customer 452531, July 10th, 2021
OUR GIFT TO YOU
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat

Get top-notch homework help now. 20% off first 10 orders!

NEW

Thank you for choosing MyCoursebay. Your presence is a motivation to us. All papers are written from scratch. Plagiarism is not tolerated. Order now for a 15% discount

Order Now