Question: I ' m trying to determine if my runtime analysis chart is correct. Project guidelines: Show how to create course objects, so that one course
Im trying to determine if my runtime analysis chart is correct.
Project guidelines:
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 worstcase 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:
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.
Assume the cost for a line to execute is unless it is calling a function, in which case the cost will be the running time of that function.
Here is the pseudocode that the chart is based on:
Vector Data Structure Pseudocode:
Define course object
DEFINE Course:
SET variable courseID to data type String
SET variable courseTitle to data type String
SET variable prerequisites to data type Vector of String
Function to open file, view data, parse lines, and verify formatting
FUNCTION readFilefilename
OPEN file using filename
IF file is successfully opened
INITIALIZE vector courseDetails for storing course data
INITIALIZE vector courseIDs
WHILE file lines are open
INITIALIZE String courseData
READ line from file
IF line contains two or more parameters
PARSE line to gather course data
SET courseID to first parameter
ADD courseID to vector courseIDs
IF line contains prerequisites
DELCARE prerequisites as rest of parameters
FOR each prerequisite in prerequisites
IF prerequisites do not exist in courseIDs vector
PRINT Error: Prerequisite not found.
BREAK
ENDFOR
ENDIF
DELCARE newCourse as Course object with courseID, courseTitle, and prerequisites
ADD newCourse to vector courseDetails
ELSE
PRINT Error: Invalid course information.
ENDIF
ENDWHILE
CLOSE file
FOR each course ID in vector courseIDs
IF courseID not in vector courseDetails
PRINT Error: Course without details: courseID
ENDIF
ENDFOR
ELSE
PRINT Error: Could not open file.
ENDIF
END FUNCTION
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
