ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

Ëã·¨±ÊÊÔÌâ
2014-11-24 01:01:24 ¡¾´ó ÖРС¡¿ ä¯ÀÀ:6087´Î
Tags£ºËã·¨ ÊÔÌâ

1. [25 points] A binary tree is full if all of its vertices have either zero or two children. Let Bn
denote the number of full binary trees with n vertices.
(a) By drawing out all full binary trees with 3, 5, and 7 vertices, determine the exact values
of B3 , B5 , and B7 .
(b) Why have we left out full binary trees with even number of vertices, like B4, in part (a)
(c) For general n, derive a recurrence relation for Bn .
(d) Show by induction (substitution) that Bn is 2
(n) .
2. [25 points] Consider the problem of merging two sorted arrays A and B of n elements each
into one sorted array C of 2n elements. This problem asks you to prove that the minimum
number of comparisons to perform this task is 2n 1. The problem is split into two parts:
a) Show that if two elements x ¡Ê A and y ¡Ê B are consecutive in C, then they must be
compared.
b) Given the result from part (a), show that the lower bound on the number of comparisons
for merging A and B is 2n 1.


¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
ÉÏһƪ£ºÒ»ÍøÓÑ×Ô¼ºÉè¼ÆµÄÃæÊÔÌâ ÏÂһƪ£ººþÄÏ¿Æ´´ÃæÊÔÌâ

×îÐÂÎÄÕÂ

ÈÈÃÅÎÄÕÂ

Hot ÎÄÕÂ

Python

C ÓïÑÔ

C++»ù´¡

´óÊý¾Ý»ù´¡

linux±à³Ì»ù´¡

C/C++ÃæÊÔÌâÄ¿