CS 415, Section 001 Sonoma State University Spring, 2023
 
Algorithm Analysis
Instructor: Henry M. Walker

Lecturer, Sonoma State University
Professor Emeritus of Computer Science and Mathematics, Grinnell College

Although much of this course is well developed, some details can be expected to evolve as the semester progresses.
Any changes in course details will be announced promptly during class.

Worksheet on Greedy Algorithms

Huffman Trees and Codes

Steps 1 and 2 require that you obtain a count of characters within a text, so that you can construct a Huffman code based on the text. Although you can count characters any way you wish, you may use program count-characters.c if you find that program to be helpful.

  1. Huffman Algorithm
    1. Construct a Huffman code and tree, based on the text

        a computer science major can support a great career!
      
    2. Using your tree/code in Part a, encode the text given above.

  2. Construct a Huffman code and tree to optimize the storage of the message

           computing can help address important problems in today's world!!!
    

    In this problem, consider upper and lower case letters to be equivalent (perhaps converting upper case letters to lower case in your counting and coding.)

  3. Decode the front of the AP Computer Science t-shirt for 2002.

Minimum Cost Spanning Trees

  1. Consider the following undirected graph:

    undirected graph 7
    1. Find the shortest paths from vertex C to all other vertices.

    2. Find the minimum cost spanning tree, showing the main steps in applying the algorithm.

  2. Repeat the previous problem for the following graph.

    undirected graph 6
  3. Given an undirected graph, a minimum cost spanning trees need not be unique. Given an example of a graph with two different minimum cost spanning trees, where the graph has the fewest number of vertices and the fewest number of edges. In addition to displaying the graph and the two different minimum cost spanning trees, provide an explanation as to why this graph is the smallest possible with two different such trees.

created April 25, 2022
revised April 25, 2022
revised July 24, 2022
revised December 31, 2022
revised Summer 2023
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.
ccbyncsa.png

Copyright © 2011-2022 by Henry M. Walker.
Selected materials copyright by Marge Coahran, Samuel A. Rebelsky, John David Stone, and Henry Walker and used by permission.
This page and other materials developed for this course are under development.
This and all laboratory exercises for this course are licensed under a Creative Commons Attribution-NonCommercial-Share Alike 4.0 International License.