20-CS-122-001 Computer Science II Spring 2012
Express Ideas In English

Virtual functions, classes, inheritance, lists, queues, stacks, applications

Prev      Next

Define what a cable object is
Open data file
Determine number of cables in file
Close the data file
Identify a set containing all given cables, and call it GIVEN
Identify a set of cables and call it SOLUTION
Re-open the data file and load GIVEN
Sort GIVEN cables by increasing order of cost
Repeat the following until no cables remain in GIVEN:
    Pull the lowest cost cable from GIVEN, call it CABLE
    Does adding CABLE to SOLUTION cause a cycle?
    If not, add CABLE to SOLUTION
Return SOLUTION

Demo of this algorithm is here.