Explore BrainMass
Share

Explore BrainMass

    Three questions about binary tree and heap

    This content was COPIED 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]
    .elements
    [0]"introspective"
    [1 ]"intelligent"
    [2]"intellectual"
    [3]"intimate"
    [4]"intensive"
    [5]"interesting"
    [6]"internal"
    [7]"into"
    [8]"in"
    [9]"intro"
    a. What feature of these strings is used to determine their priority in the priority
    queue?
    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 10, 2019, 7:22 am ad1c9bdddf
    https://brainmass.com/computer-science/cpp/578690

    Attachments

    Solution Preview

    1
    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

    2
    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.

    $2.19