sol10 - COP3530 Solution 10 1. a) 14(3) / \ 12(2) 10(2) /\...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
COP3530 Solution 10 1. a) 14(3) / \ 12(2) 10(2) / \ / \ 8(1) 4(1) 9(2) 6(1) / / \ 2(1) 5(1) 7(1) b) Remember the definition of the height-biased min leftist tree. \\ - has min-heap property - swap only if needed Meld right subtree with smaller root and the other entire tree. meld [4, 10 ] meld [9, 4 ] 9 / / \ ===> / / ===> / \ 2 6 9 5 2 5 4 / / 5 2 10 swap 10 ===> / \ ===> / \ 6 9 9 6 / \ / \ 5 4 5 4 / / 2 2 12 12 / \ swap / \ ===> 8 10 =====> 10 8 / \ / \ 9 6 9 6 / \ / \ 5 4 5 4 / / 2 2 2. To merge two k-tournament trees T1 and T2, we proceed as follows: mergetree(T1, T2) (returns a tree T) create (T) (creates T) size[T] = size[T1]+1 left[T] = T1 (or root[T1]) right[T]= T2 (or root[T2]) if value[T1] > value[T2] then value[T] = value[T1] else value[T] = value[T2] return T The merge operation can be done in O(1), or constant time.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
3. /** worst fit bin packing */ /** worst fit bin packing */ package applications; import dataStructures.*; import utilities.*; public class WorstFit { // top-level nested class
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/15/2010 for the course COP 3530 taught by Professor Davis during the Fall '08 term at University of Florida.

Page1 / 5

sol10 - COP3530 Solution 10 1. a) 14(3) / \ 12(2) 10(2) /\...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online