CS300 Module 6 Project One Pseudocode and Runtime Analysis

.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

12

Uploaded by CountIron10886

Report
1 Module 6-2: Project One Pseudocode and Analysis Ryan McFarland Department of Computer Science, Southern New Hampshire University CS 300: DSA: Analysis and Design Professor Andujar August 8, 2021
2 Vector //pseudocode for loading data into the vector data structure Ifstream myfile Myfile.open(“name.csv”) If file open fail Print error courseNames = second string of each line While(myfile.good() and not end of file) String line; Getline(myfile, line, ‘\n’) Course(line) //pseudocode for creating course objects and storing to vector Vector<Course> courses Course(line) String name Course *courseName = new Course For each string courseName-> num = first parsed string courseName-> name = second parsed string ///////ensures at least two parameters on each line///////////// If no num or name Error return For each remaining string /////////////ensures that any prerequisite exists as a course//////// If prerequisite name found in courseNames Prerequisites = remaining parsed string courseName->prerequisite = prerequisite Prerequisites ++ Courses.push_back(*courseName) //pseudocode for searching and printing a specific course and printing course information out Cin << search term For each course.at(i) with I less than course length If course name = search term Print course information print prerequisites course information //Pseudocode for menu //load data structure Ifstream myfile Myfile.open(“name.csv”) If file open fail Print error
3 courseNames = second string of each line While(myfile.good() and not end of file) String line; Getline(myfile, line, ‘\n’) Course(line) //print course list, prints alphanumerically ordered list of all courses selectionSort(courses){ unsigned int min for i<courses.size() ++i min = i for j=i+1 j<courses.size() ++j if courses.at j < courses.at I min = j if min isn’t I then swap bids at I and min } for i<courses.size() print all courses.at(i) //print course, prints course title and prerequisites for given course If course.at(i) == search term Cout<< course->title << course-> prerequisites //exit return //pseudocode for print list in alphanumeric order //sort the courses by course number from low to high selectionSort(courses) //print the sorted list to display Do Cout << sorted course.at(i) while i<courses.size()
4 Vector Line Cost # Times Executes Total Cost For each string 1 n n courseName-> num = first parsed string 1 1 1 courseName-> name = second parsed string 1 1 1 If no num or name Error return 1 1 1 For each remaining string 1 n n If prerequisite name found in courseNames 1 n n Prerequisites = remaining parsed string 1 n n courseName->prerequisite = prerequisite 1 n n Prerequisites ++ Courses.push_back(*courseName) 1 n n Total Cost 6n + 3 Runtime O(n)
5 Hashtable //pseudocode to define how the program opens the file, reads the data from the file, parses each line, and checks for file format errors Ifstream myfile Myfile.open(“name.csv”) If file open fail Print error courseNames = second string of each line While(myfile.good() and not end of file) String line; Getline(myfile, line, ‘\n’) Course(line) //pseudocode to show how to create course objects and store them in the appropriate data structure Struct Course Subject/number Title Class hashtable Struct node course key next node constructors vector<Node> nodes(numberOfBuckets) hash(key) return key mod numberOfBuckets Insert(course) Key = hash(course sub/name) Determine correct node position and place //pseudocode that will print out course information and prerequisites For I less than size of table Look at each bucket that isn’t empty If value isn’t default or null Print the course information for each course in the container //Pseudocode for menu //load data structure Ifstream myfile Myfile.open(“name.csv”) If file open fail
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