BSTforApp

docx

School

Southern New Hampshire University *

*We aren’t endorsed by this school

Course

350

Subject

Computer Science

Date

Feb 20, 2024

Type

docx

Pages

2

Uploaded by SargentSnake1088

Report
Caio Mauro 11/26/23 CS300 Read File: Utilize fstream to open the file Call the file open function, check if the return value is "-1"; if so, the file is not found, otherwise, the file is found While not at the End Of File, read each line Close the file Check Line for Validity: If there are fewer than two values in a line, return an ERROR Else, read parameters If there is a third or more parameter: If the third or more parameters are found in the first parameter, continue; otherwise, return an Error Create Course Objects Structure: Initialize a Course Structure using a struct named Course Loop through the file while not at the End Of File For each line in the file: For the 1st and 2nd values, add Course ID and Course Name If a 3rd value exists, add prerequisites until a newline is found
Create Tree and Add Nodes: Define a Binary Tree Class Create a root variable pointing to null Implement an Insert method: If the root is null, the current Course becomes the root Else, if the course number is less than the root, add it to the left If the left is null, add the course number Else, if the course number is less than the leaf, add it to the left; if it's greater, add it to the right Else, if the course number is greater than the root, add it to the right If the right is null, add the course number Else, if the course number is less than the leaf, add it to the left; if it's greater, add it to the right Search and Print from Tree: Ask for user input Create a Print Method If the root is not null, Traverse to the left and output if found Traverse to the right and output if found
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help