CS367 Homework 8
Summer 2016
Due by 11:59 pm on Wednesday, August 3

Announcements

Check here periodically.

7/28/2016  Homework assigned. To ask questions about the homework and see questions posed by other students and their answers, go to: https://piazza.com/wisc/summer2016/cs367 and sign-in using your wisc.edu account.

Questions

Question 1:

  1. The ten most common words in English, along with their hash codes according to Java's String.hashCode method, are:

    OrderWordHash Code
    1the114801
    2of3543
    3to3707
    4and96727
    5a97
    6in3365
    7is3370
    8it3371
    9you119839
    10that3558823

    Part A: Suppose these strings are inserted into a 14-bucket hash table in the order shown above. Each string's bucket is its hash code modulo 14. If collisions occur, each bucket is implemented as a singly-linked list, with new items added to the head of the list. Show the contents of all buckets after these strings are inserted. Give each bucket as a bucket number followed by a list of strings, with the head of the list at the left.

    Part B: Suppose these strings are inserted into a 14-bucket hash table in the order shown. Each string's initial bucket is its hash code modulo 14. If collisions occur, use linear probing with a step size (or offset) of 1. Show the contents of all buckets after these strings are inserted. Give each bucket as a bucket number followed by the string in that bucket, if any.

  2. Question 2:

    1. Given the following graph with nodes having character labels and edges having non-negative integer weights:

      directed, weighted graph

      Trace Dijkstra's algorithm, starting at node A, by filling in the remaining rows in the table below. Each row in the table represents one iteration of the of the algorithm, so use as many or as few rows as needed for the algorithm to complete. If the priority queue ever contains more than one node with the same distance, break ties using alphabetical ordering of these nodes? names.

      visited nodes and their
      shortest distances from start
      priority queue's items
      (listed in increasing order)
      - (0,A)
      A:0 (1,D), (2,B)
      A:0, D:1 (2,B), (3,C), (3,E), (5,G), (9,F)
         
         
         
         
         
         
         

    2. Handing in

      Please include your name at the top your file.

      Put your answers to the questions into one file named Homework8 with the appropriate file extension, e.g., Homework8.pdf (see File Format for acceptable file formats).

      Electronically submit your work to the Homework 8 Dropbox on Learn@UW.

Last Updated: 7/31/2014     © 2014 Beck Hasti