trees and heaps

All the questions will be found in the PDFYou cannot copy any solution form any other websites!You cannot look up to any information on the internet at all!For this assignment you can directly copy the tree from the provided file. if you cannot copy just tell me and I will provide another one. If you already worked on this assignment, please do not reply at all. And the due date is within 1 day!
hw5.pdf

Unformatted Attachment Preview

Don't use plagiarized sources. Get Your Custom Essay on
trees and heaps
Just from $13/Page
Order Essay

Trees and Heaps
Instructions
You should submit answers to the following questions as either a text document or
PDF format file. (Submitting any other format, MS Word, for example, will be
grounds for receiving a 0.) The file must be named “hw5.txt” or “hw5.pdf”. Copy the
file into the hw5 directory of your shared submission directories to submit.
Where the question asks for you to draw a tree or heap, you can use any drawing app,
or even draw freehand and scan/take a snapshot/screenshot. If you do that, it would
be easiest to generate a PDF file with the pictures inserted inline.
The following tree diagram template (directly cut-and-pasteable, available for
download in the file hw5-tree-template.txt, and also copyable from the submission
folder directory “00Hw5” on the GL systems), contains an ASCII art skeleton for a
binary tree. You can cut-and-paste that into your file and edit it to diagram your
tree/heap. Be sure to replace the ‘X’ node names with appropriate values as required
by the question.
X
/
___________/
___________
/

/

X
X
/
/
___/
___
/
___/

/
___
/

/

X
X
X
X
_/ _
_/ _
_/ _
_/ _
/

/

/

/

X
X
X
X
X
X
X
X
/
/
/
/
/
/
/
/
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
/ / / / / / / / / / / / / / / /
X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
Question 1
An AVL tree uses the simple recursive structural constraint that the heights of the
left and right subtrees of any node can differ by at most 1. However, this does not put
a fixed constraint on the maximum difference in depth between any two given leaves
of the AVL tree. In fact, the difference in depth between the shallowest and deepest
leaves can be arbitrarily large given a large enough tree–but there are relative limits.
a) Determine the minimim possible depth of other leaves as a function of dmax, the
depth of the deepest leaf. (I.e., state a claim like “the depth of the shallowest leaf can
be no less than the depth of the deepest leaf minus 2 (dmax – 2))
b) Draw an AVL tree where there is at least a 3-level difference between some pair of
leaves. Make sure that what you drew is a legal AVL tree!
Question 2
[If you are using the tree template, trim unnecessary branches, and replace all of the
‘X’s with either ‘B’ or ‘r’ (don’t use uppercase ‘R’–too similar to ‘B’)]
For this question, assume we are talking about the version of red-black trees with
dummy leaf nodes, i.e., all leaf nodes are black, and leaf nodes do not contain data.
Also, we here define the black depth of a leaf to be the number of black nodes in the
path from the root to the leaf, including the root but not counting the leaf node itself.
Recall that in a red-black tree, all leaves in our tree must have the same black depth.
a) What is the maximum true height, i.e., counting both red and black nodes, of a
red-black tree with a black depth of 3? (Recall that the height of a tree is the number
of edges between the root and the deepest leaf.) Another way of stating the question
would be: what is the depth of the deepest possible leaf in a reg-black tree of black
depth 3
b) What is the absolute mimimum number of internal nodes (i.e., not counting the
dummy leaves) needed to construct a tree as described in (a) above?
c) Draw a diagram of your red-black tree from part (b). You do not have to draw the
dummy leaf nodes.
Question 3
Using the keys 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 and 12, draw a binary max heap that
stores these keys in some legal heap order, and has the keys 3, 2 and 1 in left-to-right
order in the last three positions (i.e., the rightmost 3 nodes at the bottom-most
level), such that after 2 consecutive calls to deleteMax(), the bottom-most level
consists of the keys 1, 2 and 3, in that left-to-right order.
Question 4
[If you are using the tree template for either part (a) or (b) below, make sure to trim
unnecessary branches, and replace all of the ‘X’s with real numerical values]
a) Using the keys 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 and 12, draw a binary min heap that
stores these keys in some legal heap order, where deleting the key 6 would cause the
replacement item to bubble up.
b) Using the keys 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 and 12, draw a binary min heap that
stores these keys in some legal heap order, where deleting the key 8 would cause the
replacement item to tricke down.
c) Is it possible to construct a single min heap where deleting a 6 would cause the
replacement node to bubble up, but where instead deleting an 8 would cause
trickling down? (The question is assuming we would delete either one or the other,
but not both.) Explain why/why not.

Purchase answer to see full
attachment

GradeAcers
Calculate your paper price
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

Order your essay today and save 15% with the discount code DISCOUNT15