CS 415, Section 001 Sonoma State University Fall, 2022
 
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 Optimal Binary Search Trees and Classes P and NP

Optimal Binary Search Trees

  1. Determine the cost and structure of an optimal binary search tree with the following frequencies:

    Boxer Doberman Lab Spaniel Terrier
    3 2 4 6 1

  2. Problems from the Levitin text (Third edition), Section 8.3

    1. Exercise 2 (both parts a and b)
    2. Exercise 5

Classes P and NP

  1. Consider the terms, "Class P", "Class NP", tractable, intractable, decidable, and undecidable.
    Give careful definitions of each of these terms.

  2. One approach for sorting an array of n elements is to generate all n! permutations of the elements and then each is examined to determine which permutation is ordered.

    1. Explain why this algorithm, called a Permutation Sort, has Θ(n * n!).
    2. Since n * n! is not a polynomial, must we conclude that sorting is not in Class P? Explain briefly.
    3. Does this or another analysis prove that sorting is in Class NP? Explain.
  3. Consider a breadth-first or a depth-first traversal of a directed graph with n vertices.

    1. Does either of these algorithms demonstrate that the problem of traversing a graph is in Class P? Explain.
    2. Does either of these algorithms demonstrate that the problem of traversing a graph is in Class NP? Explain.
  4. Identify 3 problems in Class P, and explain why each is in Class P.

  5. Use the definition of Class NP to explain why each of the following problems are in Class NP.

    1. The Hamiltonian Path problem.
    2. The Satisfiability Problem, which asks whether there is an assignment of True or False to each of the n variables in a Boolean expression, so that the resulting expression is True.
created April 25, 2022
revised April 25, 2022
revised July 25, 2022
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.