CS 300 Assignment 3 Due Friday Dec. 8 by 11:59 pm Name: Email: Instructions: Fill in your name and email. Use webct to submit your worksheet. There are four questions, each worth 25 points. Assignments must be done individually; however, if you have questions or do not understand how to do something, you should ask or send your question to the class mailing list. Overview: The purpose of this assignment is to utilize Maple and the combstruct package to further investigate properties of trees. There is also a question on Taylor series to make sure that everyone can use Taylor's theorem. Probability
<Text-field style="Heading 1" layout="Heading 1">Question 1 (Binary Trees and Forrests)</Text-field> In the lecture on combstruct, we saw that the number of ordered trees of size LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYkLUkjbWlHRiQ2JVEibkYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNjBRIn5GJy9GM1Enbm9ybWFsRicvJSZmZW5jZUdRJmZhbHNlRicvJSpzZXBhcmF0b3JHRj0vJSlzdHJldGNoeUdGPS8lKnN5bW1ldHJpY0dGPS8lKGxhcmdlb3BHRj0vJS5tb3ZhYmxlbGltaXRzR0Y9LyUnYWNjZW50R0Y9LyUlZm9ybUdRIUYnLyUnbHNwYWNlR1EkMGVtRicvJSdyc3BhY2VHRk8vJShtaW5zaXplR1EiMUYnLyUobWF4c2l6ZUdRKWluZmluaXR5Ric=is equal to the number of binary trees of size LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYlLUkjbWlHRiQ2JVEibkYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNjBRKiZ1bWludXMwO0YnL0YzUSdub3JtYWxGJy8lJmZlbmNlR1EmZmFsc2VGJy8lKnNlcGFyYXRvckdGPS8lKXN0cmV0Y2h5R0Y9LyUqc3ltbWV0cmljR0Y9LyUobGFyZ2VvcEdGPS8lLm1vdmFibGVsaW1pdHNHRj0vJSdhY2NlbnRHRj0vJSVmb3JtR1EmaW5maXhGJy8lJ2xzcGFjZUdRMG1lZGl1bW1hdGhzcGFjZUYnLyUncnNwYWNlR0ZPLyUobWluc2l6ZUdRIjFGJy8lKG1heHNpemVHUSlpbmZpbml0eUYnLUkjbW5HRiQ2JFEjMS5GJ0Y5 (review this fact in the combstruct lecture). This suggests that there is a one-one map between arbitrary ordered trees and binary trees. Indeed there is! Take an arbitrary ordered tree and produce a forest from the sequence of children of the root of the given tree. There is a 1-1 map between forrests and binary trees obtained by taking the root of the first tree in the forrest and assigning its left child to the binary tree obtained from the forrest obtained from the children of the left tree of the that tree and assigning to the right child the binary tree obtained from the remaining trees in the forrest. This procedure can be reversed to obtain a unique forrest from a given binary tree. Implement a Maple procedure that carries this map out.
<Text-field style="Heading 1" layout="Heading 1">Question 2 (Taylor's Theorem)</Text-field> In this question you will use Taylor series and Taylor's theorem to compute log(1+x), where 0 <= x < 1 and log is the natural logarithm, to a specified accuracy. Compute the Taylor series of log(1+x) Use plot to compare log(1+x) and the truncated Taylor series with 5 and 10 terms. Empirically investigate how many terms are required in the Taylor series to compute log(3/2) to 10 decimal places. You may compare to evalf(log(3/2)). What is the kth derivative of log(1+x) with respect to x? Obtain a bound using Taylor's theorem on the error when using n terms in the Taylor series of log(1+x). Use this to write a Maple procedure mylog(a,B), 0 <= a < 1, which estimates log(1+a) with an error guaranteed to be less than B. Taylor's theorem states that if we truncate the Taylor series after n terms the error is equal to NiMqKC0tJSNAQEc2JCUiREclIm5HNiMtJSJmRzYjJSN4aUciIiIpJSJ4R0YpRi8tJSpmYWN0b3JpYWxHNiNGKSEiIg==, where NiMxIiIhJSN4aUc= and NiMxJSN4aUclInhH. mylog := proc(a,B) end; NiM+JSZteWxvZ0dmKjYkJSJhRyUiQkc2IkYpRilGKUYpRilGKQ== mylog(1/2,1/2*10^(-11));
<Text-field style="Heading 1" layout="Heading 1">Question 3 (Variance of Quicksort)</Text-field> Use Maple to calculate the variance in the number of comparisons used by quicksort to sort an array of size LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYkLUkjbWlHRiQ2JVEibkYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNjBRIi5GJy9GM1Enbm9ybWFsRicvJSZmZW5jZUdRJmZhbHNlRicvJSpzZXBhcmF0b3JHRj0vJSlzdHJldGNoeUdGPS8lKnN5bW1ldHJpY0dGPS8lKGxhcmdlb3BHRj0vJS5tb3ZhYmxlbGltaXRzR0Y9LyUnYWNjZW50R0Y9LyUlZm9ybUdRJmluZml4RicvJSdsc3BhY2VHUSQwZW1GJy8lJ3JzcGFjZUdGTy8lKG1pbnNpemVHUSIxRicvJShtYXhzaXplR1EpaW5maW5pdHlGJw==
<Text-field style="Heading 1" layout="Heading 1">Question 4 (Expected Number of Leaves in Trees)</Text-field> Use the combstruct package and attributes to investigate the expected number of leaves in binary, tertiary (1, 2, or 3 children), and quaternary trees (1, 2, 3, or 4 children). You should first investigate the number of tertiary and quaternary trees. Also investigate the number of leaves in arbitrary ordered trees. restart;