Lecture Notes for CS 509, Advanced Programming II

16 March 2004, Assignment 2 Code Review


Outline


Ouroborous Compression


Generating Arrangements

maximal-ouroboros-compression(strings)
  best, key = compress_string(strings)

  foreach p = generate-permutations(strings)
    s, k = compress-string(p)
    if s.len() < best.len()
      best = s
      key = k

  return best, key


Generating Permutations


Permutation code

permutations(strings)

  if strings.size == 1
    return strings

  s = pick strings
  perms = { }
  for each p in permutations(strings)
    for each gap between words in p
      stick s in the gap and add the result to perms

  return perms


Tests

  1. Empty test.

  2. Kissing-singer-gerbil test.

  3. Error test.

  4. aaa-aa-a permutation tests.

  5. aaa-aaa-aaa test.

  6. aaa-bbb-ccc test.


Test Results


Get IO Right


To Name Something is to Create a World


Use typedefs


Control Complexity


Comment Well


Write it Once


Factor Common Code


Points to Remember


This page last modified on 18 March 2004.