Algorithm Analysis (CSC 301 2015F) : EBoards

CSC301.01 2015F, Class 32: Pause for Breath


Overview

Preliminaries

Admin

Questions

Designing Code for Circuit Checking

Basic types for this problem

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