1 / 13

Programming Assignment #4 Binary Trees

Programming Assignment #4 Binary Trees. CS-2303 System Programming Concepts (Slides include materials from The C Programming Language , 2 nd edition, by Kernighan and Ritchie and from C: How to Program , 5 th and 6 th editions, by Deitel and Deitel). Assignment. Write a C++ program to

muniya
Download Presentation

Programming Assignment #4 Binary Trees

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Assignment #4Binary Trees CS-2303System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition, by Kernighan and Ritchie and from C: How to Program, 5th and 6th editions, by Deitel and Deitel) Programming Assignment #4

  2. Assignment • Write a C++ program to • Read one or more text files • Build up a binary tree of words in those text files • Print out alphabetical list of words and number of occurrences of each word • Also total number of words • In Visual Studio 2008 Programming Assignment #4

  3. Reading • Deitel & Deitel, Chapter 19 • Especially §19.7–19.9 • Review Binary Trees • Previous courses • K&R §6.5 • D&D §12.7 Programming Assignment #4

  4. This Assignment • Command line program ./PA4 outputFile inputFile1 inputFile2 ... • Open and read each input file in turn • Scan for words • Store each word in binary tree • Increment count of words previously seen • Open and write to output • List of words • Count for each word • Total number of distinct words Programming Assignment #4

  5. Example Output 166 a 25 and 11 as 3 command 15 each 2 file 4 files 109 in 4 input 98 it 99 of 3 open 6 program 18 read 152 the 41 this 3 under 30 would------------- 17 Total number of different words Programming Assignment #4

  6. Notes • Upper and lower case words are the same • “This” and “this” • Related words that are spelled differently are different • “Car” vs. “cars” Programming Assignment #4

  7. Guidance • Think through this problem in Java • Use as inspiration and guideline for C++ implementation • One or more class interface files (.h) • A corresponding class implementation file (.cpp) for each class interface • One or more .cpp files for main() and other non-class functions Don’t use templates from StandardTemplate Library! You must build your own classes! Programming Assignment #4

  8. Suggestion • class treenode • Members:– • Pointers to left and right subtrees • int count • string word • Constructor, destructor • Add to or access left and right subtrees Programming Assignment #4

  9. Suggestion (continued) • class binaryTree • Members:– • root • Constructor, destructor • Methods to traverse tree, insert into tree, etc. Programming Assignment #4

  10. Test Files • Provided in project assignment Programming Assignment #4

  11. Submission • Build in Visual Studio • If working on Mac or other system, port to VS at least one day prior to due date • Make clean before submitting • Zip files together so grader can unzip and build • Project name:–PA4 • Submit zip file, README, output from test cases Programming Assignment #4

  12. Additional Notes • See notes at the end of Programming Assignment document • Command line arguments (same as in C) • Input and Output streams • Not in Deitel and Deitel! • Formatted output Programming Assignment #4

  13. Questions? Programming Assignment #4

More Related