Name _________________________

CS 60 Spring 1998

Information Structures Worksheet Number 2

This worksheet is keyed to the second part of Chapter 2 of the notes. This worksheet is worth 10 points if turned in by class time Monday 2/2/98.

Instructions: Write your answer on the line. Anything you write after the discussion in class is to be written below the line.

1. Enumerate the binary relation represented by the following tree:

________________________________________________________.

 

2. In the tree above, what is the target set of birds?

________________________________________________________.

 

3. In the tree above, what nodes are reachable from reptiles?

________________________________________________________.

 

4. Give the hierarchic list representation for the tree above.

________________________________________________________.

 

5. Using your answer to the previous questing, give the unlabeled tree representation of the list (your answer on the left, discussion on the right).

6. Give the binary tree representation of the same list.

7. Give three distinct types of list representation for the following directed graph.

a. ______________________________________________________.

b. ______________________________________________________.

c. ______________________________________________________.

8. Draw the transitive closure of the preceding graph.

9. Below is a directed graph with labels on its arrows. Describe a way to represent a labeled directed graph using lists. Use your method on the following labeled directed graph.

_______________________________________________________.

10. Show a list of lists which does not represent a matrix.

_______________________________________________________.

 

11. Describe a method for determining whether a graph is acyclic, given the graph's connection matrix.

 

 

 

12. Which is more general, a directed graph or an undirected one, and why?

_______________________________________________________.

 

13. The transitive closure of an undirected graph has an unusual form. What is it? Devise a more efficient way to represent such a transitive closure as a list based on its properties.

_______________________________________________________.

 

14. The time taken to index a list represented as a linked list is proportional to ___________________________________________.

 

15. The time taken to index a list represented as an array is proportional to ___________________________________________.

 

16. How can we represent the following lists more compactly, using information sharing?

[ [1, 3, 6], [2, 4], [1, 3, 6], [2, 5]]

___________________________________________.

[ [1, 3, 6], 2, 3, 6]

___________________________________________.

[[1, 2], [ [1, 2], 1, 2], 1, 2]

___________________________________________.

 

17. Convert the following binary representation to decimal: 1101101

___________________________________________.

 

18. Represent the number 42 in binary.

___________________________________________.

 

19. Give an S expression for the following list: [+, [*, 1, 2], [/, 3, 4]].

___________________________________________.