Prompt
For this milestone, you will be creating pseudocode for loading
data into the tree data structure. There will be no programming
work in this milestone; you will be developing pseudocode that will
help you implement your design in a future milestone. Also note
that throughout this milestone we are going to use the word
“course” to refer to the courses in the curriculum versus “class,”
which has another meaning in object-oriented programming.
For this milestone, you will:
Function Signatures
Below are the function signatures that you can fill in to
address each of the three program requirements using each of the
data structures. The pseudocode for printing course information, if
a vector is the data structure, is also given to you below
(depicted in bold).
// Vector pseudocode
int numPrerequisiteCourses(Vector<Course> courses, Course
c) {
totalPrerequisites = prerequisites of
course c
for each prerequisite p in
totalPrerequisites
add
prerequisites of p to totalPrerequisites
print number of totalPrerequisites
}
void printSampleSchedule(Vector<Course> courses) {
}
void printCourseInformation(Vector<Course> courses, String
courseNumber) {
for all courses
if the course is the same as courseNumber
print out the course information
for each prerequisite of the course
print the prerequisite course information
}
// Hashtable pseudocode
int numPrerequisiteCourses(Hashtable<Course> courses)
{
}
void printSampleSchedule(Hashtable<Course> courses) {
}
void printCourseInformation(Hashtable<Course> courses,
String courseNumber) {
}
// Tree pseudocode
int numPrerequisiteCourses(Tree<Course> courses) {
}
void printSampleSchedule(Tree<Course> courses) {
}
void printCourseInformation(Tree<Course> courses, String
courseNumber) {
}
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.
Code
Line Cost
# Times Executes
Total Cost
for all courses
1
n
n
if the course is the same as
courseNumber
1
n
n
print
out the course information
1
1
1
for
each prerequisite of the course
1
n
n
print the prerequisite course information
1
n
n
Total Cost
4n + 1
Runtime
O(n)
Prompt For this milestone, you will be creating pseudocode for loading data into the tree data structure. There will be
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am