Question
Please evaluate based on information provided. Pseudocode needing evaluated is complete and included, as well as a runtime analysis example. // Vector pseudocode Open file
Please evaluate based on information provided. Pseudocode needing evaluated is complete and included, as well as a runtime analysis example.
// Vector pseudocode
Open file containing course information
Create empty vector to store course objects
Read each line
WHILE file has a next line
Parse each line
Verify at least two parameters on each line
IF (parameters.size()
Display ERROR message
END
Check if prerequisite exists as a course in the file
for p in prerequisites:
found = false
for c in courses:
if (c.courseNumber == p):
found = true
break
IF not found
Display ERROR
END
Create course object
Store course object in vector
CLOSE FILE
Function for searching for a specific course and Display information
Search for the course in the vector
for c in courses:
IF (c.courseNumber == courseNumber)
Print course information
Print prerequisite course information
Verify at least two parameters on each line
IF (parameters.size()
Display ERROR
END
Check if prerequisite exists as a course in the file
for p in prerequisites:
found = false
for c in courses:
IF (c.courseNumber == p):
found = true
BREAK
IF not found
Display ERROR
END
Create a course object
Store course object in vector
CLOSE FILE
Function for searching for a specific course and printing its information and prerequisites
void printCourseInformation(vector
Search for the course in the vector
for c in courses:
if (c.courseNumber == courseNumber)
Display course information
Display prerequisite course information
// Hashtable pseudocode
open file "courseInformation.csv" for reading
IF file does not exist
Display ERROR and exit
ELSE
create empty hash table "courses"
WHILE a line exists in file
read line
split line into tokens
IF number of tokens is
display ERROR
continue to next line
END IF
IF first token not a number
display ERROR
continue to next line
END IF
IF a third token exists
IF third token not a number
Display ERROR
continue to next line
END IF
check if third token is a key in "courses"
IF not
Display ERROR
continue to next line
END IF
END IF
create new course object with first token as course number, second token as course title, and third as prerequisite
insert course object into "courses" with course number as key
END WHILE
END IF
CLOSE FILE
Create course objects and store in Hash Table
class Course
courseNumber
courseTitle
prerequisite
constructor(courseNumber, courseTitle, prerequisite)
this.courseNumber = courseNumber
this.courseTitle = courseTitle
this.prerequisite = prerequisite
END constructor
END class
Create empty hash table named "courses"
FOR each line
create new course object with line tokens as arguments
insert course object into "courses" with course number as key
END FOR
FOR each key in "courses" hash table
retrieve course object from "courses" hash table
Display courseNumber, courseTitle, and prerequisite
END FOR
Define function to display course info and prerequisites
loop through hash table
FOR (int i = 0; i
IF current index not empty
Create pointer to head of linked list at current index
loop through linked list at current index
Display the course number, title, and prerequisites
loop through prerequisites of the current course
Display prerequisite course number
END WHILE
move to next course in linked list
END IF
END FOR
END
// Tree pseudocode
open file "courseInformation.csv" for reading
IF file does not exist
Display ERROR and exit
ELSE
create empty tree data structure "courses"
WHILE a line exists in file
read line
split line into tokens
IF number of tokens is
display ERROR
continue to next line
END IF
IF first token not a number
display ERROR
continue to next line
END IF
IF a third token exists
IF third token not a number
Display ERROR
continue to next line
END IF
Check if third token exists as a node in "courses"
IF not
Display ERROR
continue to next line
END IF
END IF
create new course object with first token as course number, second token as course title, and third as prerequisite
insert course object as a node in "courses" with the prerequisite as its parent node
END WHILE
END IF
CLOSE FILE
Create course objects and store in Tree Data Structure
class Course
courseNumber
courseTitle
prerequisite
constructor
this.courseNumber = courseNumber
this.courseTitle = courseTitle
this.prerequisite = prerequisite
END constructor
END class
Define function to traverse and display course info
function displayCourses(node)
display courseNumber, courseTitle, and prerequisite of current node
IF node has children
FOR each child of node
call displayCourses function with child as argument
END FOR
END IF
END
call displayCourses function with root node of "courses" tree data structure as argument
// Menu pseudocode
// Load Data Structure
FUNCTION load_data_structure()
// Load the file data into structure
LOAD data from "courses.txt" into vector
END
// Print Course List
FUNCTION print_course_list()
// Sort the course information by alphanumeric
SORT courses in ascending order
// Print the sorted list to a display
PRINT courses in ascending order
END
// Print Course
FUNCTION print_course(course_code)
// Find the course with code
FOR c in courses
IF c.code == course_code
PRINT c.title + " " + c.prerequisites
END
END
END
// Main function
// Display menu options
DISPLAY "1. Load Data Structure"
DISPLAY "2. Print Course List"
DISPLAY "3. Print Course"
DISPLAY "4. Exit"
GET user_choice
SWITCH user_choice
CASE 1:
load_data_structure()
BREAK
CASE 2:
print_course_list()
BREAK
CASE 3:
PRINT "Enter course code:"
GET course_code
print_course(course_code)
BREAK
CASE 4:
EXIT
END
4. Evaluate the run-time and memory of data structures that could be used to address the requirements. In a previous assignment, you created pseudocode to do the following: a. Define how the program opens the file, reads the data from the file, parses each line, and checks for formatting errors. b. Show how to create course objects, so that one course object holds data from a single line from the input file. Using this pseudocode written for the previous assignments, analyze the worst-case running time of each, reading the file and creating course objects, which will be the Big O value. This should not include the pseudocode written for the menu or the sample schedule above. To do this, do the following: c. Specify the cost per line of code and the number of times the line will execute. Assume there are n courses stored in the data structure. d. Assume the cost for a line to execute is 1 unless it is calling a function, in which case the cost will be the running time of that function. 5. Based on the advisor's requirements, analyze each data structure (vector, hash table, and tree). Explain the advantages and disadvantages of each structure in your evaluation. 6. Now that you have analyzed all three data structures, make a recommendation for which data structure you will plan to use in your code. Provide justification for your recommendation, based on the Big O analysis results and your analysis of the three data structures. Example Runtime Analysis When you are ready to begin analyzing the runtime for the data structures that you have created pseudocode for, use the chart below to support your work. This example is for printing course information when using the vector data structure. As a reminder, this is the same pairing that was bolded in the pseudocode from the first part of this document
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started