|
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:
- The ten
most
common words in English, along with their hash codes according
to Java's String.hashCode method, are:
Order | Word | Hash Code |
1 | the | 114801 |
2 | of | 3543 |
3 | to | 3707 |
4 | and | 96727 |
5 | a | 97 |
6 | in | 3365 |
7 | is | 3370 |
8 | it | 3371 |
9 | you | 119839 |
10 | that | 3558823 |
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.
Question 2:
Given the following graph with nodes having character labels and edges
having non-negative integer weights:
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) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |