CS 300 Project 1 SH Pseudocode and Evaluation

.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

8

Uploaded by SargentSummerAntelope68

Report
Shyanne Helo SNHU CS 300 June 17, 2023 Professor Susalla Project 1 Pseudocode- Open file using fstream Generate void method loadCourses(string csvPath, data structure) Call to open file if the file not found than return value will be -1 Else if file is found While its not the end of file Read every line If > than 2 values in 1 line, than it returns error Else read the parameters If 3 or more parameters If 3 or more parameters are in 1 parameter elsewhere continue Else it returns an error Close file Hold course info: Generate struct course{} Generate identifier: course Id, course name, prereq Vector: Vector<course> loadCourses(string csvPath) For (int I = 0; I < file.rowcount(); i++){ Generate data structure & + to collection of courses: Course course; Course.courseId = file[i[][1];
Course.name = file[i][0]; While its not the end of file Course.prereq = file[i][8]; Courses.push_back(course); Hashtable: Generate hashtable Create Node struct Course course; Unnamed int key Vector<Node>nodes Describe tableSize Unnamed int(int key) Generate inset method void Hashtable::Insert(course course) Generate key for given course, search node with key value If no data found for key Set node to key position Else if node used Set prev node key = UNIT_MAX, set key, set prev node to course & prev node next Null indicator Else find next open node + new newNode to end void loadCourses(string csvPath, HashTable* hashTable) loop to read rows of a CSV file for (unnamed int i = 0; i < file.rowCount(); i++) { generate a data structure & + to collection of courses Course course; course.courseId = file[i][1]; course.name = file[i][0]; while not end of line course.prereq. = file[i][8];
hashTable->Insert(course); Binary Trees: name binary search tree to hold all the courses and course information BinarySearchTree * BST; BST = new BinarySearchTree; Course course; Generate + node method void BinarySearchTree::addNode(Node* node, Course course) If root = null, + root if node is > root, + to left if no left node this node becomes left if node is < root, + right if no right node this node becomes right void loadCourses(string csvPath, BinarySearchTree* bst) loop to read rows of a CSV file for (unnamed int i = 0; i < file.rowCount(); i++) { Generate a data structure & + to collection of courses Course course; course.courseId = file[i][1]; course.name = file[i][0]; while not end of line course.prereq. = file[i][8]; BST->Insert(course); Print course info & prereqs : Vector : Generate method void printCourseInfo(Vector<Course> courses, String courseId) Obtain input for courseId While vector is not empty if the input = courseId output course.courseId << output course.name while (prereq = true) output course.prereq Hashtable: Generate method void printCourseInfo(Hashtable<Course> courses, String courseId) Obtain input for courseId Set key = courseId Set node to the node.at(key) if current node = key
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