Algorithm Analysis (CSC 301 2015F) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning]
Current: [Outline] [EBoard] [Reading] [Lab] [Assignment]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Readings]
Reference: [Algorist]
Related Courses: [Walker (2014F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker]
Overview
Basic types for this problem
Points
struct Point
{
int x;
int y;
};
typedef struct Point Point;
Edges (e.g., in MST)
struct Edge
{
int source;
int sink;
double weight;
}
typedef struct Edge Edge;
e of type Edge, we can write e.source. If we
have ep of type Edge *, we can write, ep->weight or
(*ep).weight.Paths
Values for this problem
Point points[npoints]; // Allows us to refer to points by integer
Naive algorithm
Sort the points from left to right
Plant one arm at the far left
Move the other arm to each of the remaining points from left
to right
Main Method
// Determine the number of points and the number of trials
// For each trial
// Set up the array of points.
for (i = 0; i < npoints; i++)
{
} // for
// Run the algorithms on that array
total_distance_naive += naive(...);
total_distance_smart += smart(...);
// Report results
printf ("Average naive: %lf\n", total_distance_naive / ntrials);
printf ("Average smart: %lf\n", total_distance_smart / ntrials);
Skiena's Algorithm
// Split the graph up into nearby segments
// Make an MST using Prim's algorithm (copy from Skiena)
// Break into clusters using some heuristic
// All edges of length > ___
// Split at non-leaves
// Remove the top n% of the edges
// Traverse each cluster, perhaps using naive algorithm