• Nie Znaleziono Wyników

CIS610, Homework 4 (Due: May 3, 2004 )

N/A
N/A
Protected

Academic year: 2021

Share "CIS610, Homework 4 (Due: May 3, 2004 )"

Copied!
1
0
0

Pełen tekst

(1)

CIS610, Homework 4 (Due: May 3, 2004 )

Solve ALL the problems. Collaboration is prohibited 8 points total

Problem 1. (3 points)

What is the minimum cost of a Huffman code for 13 items with weights:

2, 4, 3, 5, 7, 11, 1, 1, 3, 6, 2, 6, 8 Draw a corresponding optimal Huffman tree.

Problem 2. (Red-black trees) (3 points)

Draw red-black tree which results after inserting elements

14, 13, 12, 11, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 15

(in this order) into initially empty red-black tree using algorithm from the class.

Indicate which vertices are black (square nodes) and which are red (round nodes).

Problem 3. (Towers of Hanoi) (2 points)

Write the configuration of the Tower of Hanoi problem for 5 elements after 20 moves.

All elements 1, 2, 3, 4, 5 are to be moved from the tower (stack) 1 to the tower 3 using minimal number of moves. Additionaly the tower 2 is used. It is not allowed to place larger element above a smaller one. One move consits in shifting top element from one tower to another tower, as its top element. The configuration specifies which elements are on tower 1, tower 2 and tower 3. Elements on one tower are listed in the order top-down, written horizontally with the top on the left.

For example the initial configuration is ( < 12345 >, < ∅ >, < ∅ > ), the final one is ( <∅ >, < ∅ >, < 12345 > ).

The empty set is denoted here by∅. The problem is also described in ”Additional informal lecture notes”, see the web page of the course.

Cytaty

Powiązane dokumenty

Przyjrzyj się uważnie kulom śniegowym, a następnie uporządkuj od najmniejszej do największej wpisując w okienka odpowiednie cyfry rozpoczynając

Informujemy uczniów, że będziemy zajmować się ubezpieczeniami społecznymi, których celem jest zapewnienie bezpieczeństwa socjalnego, oraz poznamy zasady działania instytucji,

[r]

Szczególne sytuacje życiowe to przede wszystkim okoliczności wymienione w ustawie o po- mocy społecznej: ubóstwo, sieroctwo, bezdomność, bezrobocie, niepełnosprawność,

Skoro wszyscy tworzymy pewną wspólnotę ryzyka, to naturalnym zachowaniem jest po- dejmowanie wspólnych działań, aby przeciwdziałać prawdopodobieństwu spełnienia się tego

Podstawę wymiaru składki na ubezpieczenie zdrowotne dla tych osób stanowi kwota zade- klarowana, nie niższa niż 75% przeciętnego miesięcznego wynagrodzenia w sektorze

przejście od modelu zdefi niowanego świadczenia do modelu zdefi niowanej składki od zwaloryzowanych składek na ubezpieczenie emerytalne i zwaloryzowanego kapitału

Find the area of the smaller section of land ABC, given the additional information shown below... A recreation park has