Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please code the following in C++! Create a Person class with two string attributes - name and bday, and one string pointer attribute - pkey.

Please code the following in C++!

  • Create a Person class with two string attributes - name and bday, and one string pointer attribute - pkey.
  • 'name' attribute is a two-word data in a single attribute.
  • 'bday' attribute is of the format 'yyyy-mm-dd'
  • 'pkey' attribute will point to either the name or bday attribute based on how the Person object is created.
  • Then implement a BSTNode ADT with a data attribute and two pointer attributes, one for the left child and the other for the right child. Implement the usual getters/setters for these attributes as well as a print method to output the object on a single 80-char line formatted to print name left aligned in 60-chars followed by birthday right aligned in 20-chars.
  • Finally, implement a BST as a link-based ADT whose data will be Person objects - the data will be inserted based on the pkey attribute.
  • For the BST, implement the four traversal methods as well as methods for the usual search, insert, delete, print, count, isEmpty, empty operations and any other needed.
  • Your pgm will have several Person objects created from data in an input text file as follows - one pair of name and birthday in two consecutive lines, name line before birthday line.
  • The data file can be anywhere on the machine, so prompt the user for the full path of the file.
  • Perform adequate data validation when reading data from the file - if any data item is invalid, ignore the data item but print a message to output (both screen and files as outlined later) to indicate which data items were ignored.
  • Read the data to create two BSTs for your Person database - one by name and one by birthday - remember two copies of the same Person objects will be needed for the two trees and the node insertions will be different depending on which tree the object is being inserted into.
  • Write out the listing of everyone in the Names tree to both the screen and a file called 'namesOutput.txt' using first by pre-order and then by post-order traversal mechanisms. Ensure that the output file contains names and birthdays on a single line separated by tabs. Make sure that each section is clearly identified by a header.
  • Write out the listing of everyone in the Birthdays tree to both the screen and a different file called 'birthdaysOutput.txt' using first an in-order followed by breadth-first traversal mechanisms. Again, ensure that the output file contains names and birthdays on a single line separated by tabs. Make sure that each section is clearly identified by a header.
  • Remember to ask the user where to save the two output files.
  • Include your entire VS solution, screenshots, input text file and the two output files in your zip upload. Only one file upload is allowed.
  • Ensure I can run the programs by using my own input file without having to fix your code for file locations - the file name and location is unknown to you.

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

More Books

Students also viewed these Databases questions

Question

2. Identify conflict triggers in yourself and others

Answered: 1 week ago