Explore BrainMass

Three questions about binary tree and heap

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

I need help with the following in order to study for my test. The last time you were able to explain the lists so that I did well so I hope to be able to get the same results.

1.Show the order in which the nodes in the tree, which I included in the attachment are processed by
a. an inorder traversal of the tree.
b. a postorder traversal of the tree.
c. a preorder traversal of the tree.

2.A priority queue of strings is implemented using a heap. The heap contains the
following elements:
numElements [10]
[1 ]"intelligent"
a. What feature of these strings is used to determine their priority in the priority
b. Show how this priority queue is affected by adding the string "interviewing."

3.This is the specification of the directed graph
ZooGraph = (V, E)
V(ZooGraph) = {dog, cat, animal, vertebrate, oyster, shellfish, invertebrate, crab,
poodle, monkey, banana, dalmatian, dachshund}
E(ZooGraph) = {(vertebrate, animal), (invertebrate, animal), (dog, vertebrate),
(cat, vertebrate), (monkey, vertebrate), (shellfish, invertebrate),
(crab, shellfish), (oyster, shellfish), (poodle, dog), (dalmatian,
dog), (dachshund, dog)}
To tell if one element in ZooGraph has relation X to another element, you look
for a path between them. Show whether the following statements are true, using
the picture or adjacency matrix.
a. dalmatian X dog
b. dalmatian X vertebrate
c. dalmatian X poodle
d. banana X invertebrate
e. oyster X invertebrate
f. monkey X invertebrate

© BrainMass Inc. brainmass.com October 25, 2018, 9:34 am ad1c9bdddf


Solution Preview

A. inorder traversal (we start from left then root then right)
11 22 23 29 30 47 49 56 59 61 62 64 69

B. postorder traversal (we start from left then right then root)
11 23 30 29 22 49 47 61 64 62 59 69 56

C. pre order traversal (we start from root then left then right)
56 47 22 11 29 23 30 49 69 59 62 61 64

A. The feature is that length of the string is used to determine their priority in the priority ...

Solution Summary

The solution gives detailed steps on answering 3 questions regarding binary tree and heap.

See Also This Related BrainMass Solution

Heaps, Binary Files and Bit Sets

Draw the complete tree corresponding to each of the following vectors:

(a). int a[8] = (15, 9, 3, 6, 2, 1, 4, 7)
int aSize = sizeof(a)/sizeof(int);
vector<int> v(a, a + aSize);

(b). string b = "array-based tree";
Vector<char> w(b.c_str(), b.c_str()+b.length());

View Full Posting Details