CS 106B Lecture Notes - Lecture 5: Lord Voldemort, Associative Array, Binary Search Tree

36 views4 pages

Document Summary

After put breakpoint, hit the other run button (qt creator) Go to view - local and expressions to check variable values. Hit the buttons for going into loop and executing one line at a time. Collection of elements with no duplicates, fast for searching. Key and value pairs, uses keys to find associated values. Problem 1: count number of unique words in moby dick. Loop over file reading word by word - while(input>>word) If word not included in vector previously, then let vector add the word. Then return the length of the vector for unique words. But looping and searching vector by index require a separate method (contains method not included on purpose) If the set doesn"t contain the word, add the word. The add function of set already checks for duplicates. Set uniquewords; ifstream input; openfile(input, mobydick. txt ); string word; while(input>>word){ uniquewords. add(word); It will not compile because there is no index in set.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers