23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Write a program that can <strong>in</strong>put <strong>and</strong> display a person's family tree.<br />

P-7.6<br />

Implement the tree ADT us<strong>in</strong>g the b<strong>in</strong>ary tree representation described <strong>in</strong><br />

Exercise C-7.12. You may reuse the L<strong>in</strong>kedB<strong>in</strong>aryTree implementation of<br />

a b<strong>in</strong>ary tree.<br />

P-7.7<br />

A slic<strong>in</strong>g floorplan divides a rectangle with horizontal <strong>and</strong> vertical sides us<strong>in</strong>g<br />

horizontal <strong>and</strong> vertical cuts. (See Figure 7.23a.) A slic<strong>in</strong>g floorplan can be<br />

represented by a proper b<strong>in</strong>ary tree, called a slic<strong>in</strong>g tree, whose <strong>in</strong>ternal nodes<br />

represent the cuts, <strong>and</strong> whose external nodes represent the basic rectangles <strong>in</strong>to<br />

which the floorplan is decomposed by the cuts. (See Figure 7.23b.) The<br />

compaction problem for a slic<strong>in</strong>g floorplan is def<strong>in</strong>ed as follows. Assume that<br />

each basic rectangle of a slic<strong>in</strong>g floorplan is assigned a m<strong>in</strong>imum width w <strong>and</strong> a<br />

m<strong>in</strong>imum height h. The compaction problem is to f<strong>in</strong>d the smallest possible<br />

height <strong>and</strong> width for each rectangle of the slic<strong>in</strong>g floorplan that is compatible<br />

with the m<strong>in</strong>imum dimensions of the basic rectangles. Namely, this problem<br />

requires the assignment of values h(v) <strong>and</strong> w(v) to each node v of the slic<strong>in</strong>g tree<br />

such that:<br />

Design a data structure for slic<strong>in</strong>g floorplans that supports the operations:<br />

• Create a floorplan consist<strong>in</strong>g of a s<strong>in</strong>gle basic rectangle.<br />

• Decompose a basic rectangle by means of a horizontal cut.<br />

• Decompose a basic rectangle by means of a vertical cut.<br />

• Assign m<strong>in</strong>imum height <strong>and</strong> width to a basic rectangle.<br />

• Draw the slic<strong>in</strong>g tree associated with the floorplan.<br />

• Compact <strong>and</strong> draw the floorplan.<br />

Figure 7.23: (a) Slic<strong>in</strong>g floorplan; (b) slic<strong>in</strong>g tree<br />

associated with the floorplan.<br />

444

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!