Hash Table Data Structure Pseudocode

docx

School

Southern New Hampshire University *

*We aren’t endorsed by this school

Course

300

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

4

Uploaded by CountIron10886

Report
Johnny Canal Segura CS 300 Dr. Webb 11/19/2023 // Open file openFile(“CourseInformation.txt”) // Empty tree to store courses coursesTree = new Tree<Course>() // Read each line of file for each line // Split lines into tokens Tokens = split(line, “,”) // validate tokens if (tokens.length < 2) print(“Error: Not enough parameters.”)
continue // Validate the prerequisite course exists in tree if (tokens[2] != “” && !coursesTree.contains(tokens[2])) print(“Error: Prerequisite course not found in tree.”) continue // Create new course object and store in tree course = new Course(tokens[0], tokens[1], tokens[2]) coursesTree.add(course) // Functions to print the course information Void printCourseInformation(Tree<Course> courses, String courseNumber) { // Get course from tree course = courses.get(courseNumber) // Print the course information print(“Course Number: “ + course.courseNumber) print(“Course Title: “ + course.courseTitle) print(“Prerequisites: “ + course.prerequisites) // Print the prerequisite course information (if any) if (course.prerequisites != “”)
printCourseInformation(courses, course.prerequisites) // Functions to count number of prerequisites int numPrerequisitCourses(Tree<Course> courses, String courseNumber) { int count = 0 // Get the course from the tree course = course.get(courseNumber) // Print the course information print (“Course Number: “ + course.courseNumber) print(“Course Title: “ + course.courseTitle) print(“Prerequisites: “ + course.prerequisites) // Print the prerequisite course information (if available) if (course.prerequisites != “”) printCourseInformation(courses, course.prerequisites) // Function to print sample schedule void printSampleSchedule(Tree<Course> courses) { // Iterate though all the courses in the tree for course in courses.traverse() print(“Course Number: “ + course.courseNumber)
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
print(“Course Title: “ + course.courseTitle) print(“Prerequisites: “ + course.prerequisites) // Function to count number of prerequisites int numPrerequisiteCourses(Tree<Course> courses, String courseNumber) { int count = 0 // Get the course from tree course = courses.get(courseNumber) // if the course has prerequisites then increment the count and call function recursively if (course.prerequisites != “”) count++ count += numPrerequisiteCourses(courses, course.prerequisites) return count }