Preview

Mister

Good Essays
Open Document
Open Document
5355 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Mister
COMP 3804
Assignment 2

HOWARD NEEDHAM
October 15, 2014

Presented To : Amin Gheibi

Question 1 a: Prove that, with the array representation for storing an n-element heap, the leaves are the nodes indexed by |n/2|floor + 1, |n/2|floor + 2, … , n
Defn:

A heap is a specialized tree base data structure that satisfies the following properties

1:

If A is a parent node of B the key (A) is ordered with respect to the key (B) with the same ordering applying across the heap.

2:

The keys of the parent nodes are either greater than or equal to (Max Heap) or less than or equal to (Min Heap) of their children. Either the highest key (Max Heap) or lowest key (Min
Heap) are the root node – depending on the type of heap (Min or Max Heap)

3:

A heap tree is loaded from left to right, starting at the node and working down in row form. The tree is completely filled on all levels except possibly the lowest, where it is loaded from left to right, up to a point.

Proof: We know from (3) that the indexes of all non-leaf (parent) nodes are stored before leaf (child) nodes. If the number of non-leaf (child) nodes is more than |n/2|floor then the right child of the last non-leaf (parent) node would lie outside of the boundary of the heap; its array index would be greater than n = 2*|n/2|floor + 1, which is greater than ‘n’, which is a contradiction.
From this we can claim that the index of the non-leaf (parent) nodes is at most |n/2|floor. This implies that all parent nodes are indexed from 1 to |n/2|floor. So by our previous statement, the parent node of ‘n’ is |n/2|floor, and since parent nodes cannot be leaf (child) nodes, then
|n/2|floor cannot be a leaf node. Hence, as in the above statement there are exactly |n/2|floor non-leaf (parent) nodes indexed from left to right, 1 to |n/2|floor. Ergo, this implies that all nonleaf (childe) nodes are indexed from |n/2|floor + 1 to ‘n’.

Question 1 b: Is the array with values {23, 17, 14, 6, 13,

You May Also Find These Documents Helpful

  • Good Essays

    Between two nodes in a network there can be many connecting paths but usually shortest path is considered best. It means any information exchange between two nodes also go through all nodes appearing in shortest path. By this reason any node involved in shortest paths can have…

    • 596 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Cse 373 Final Note

    • 955 Words
    • 4 Pages

    For every non-root node x, the value in the parent of x is less than or equal to the value in x.…

    • 955 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Nt1310 Unit 1 Test Paper

    • 381 Words
    • 2 Pages

    1. Create an insert function that will take nodes and add them up in the binary tree.…

    • 381 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    CS 220 – Programming w/ Data Structures: You have missed one assignment and one quiz. Your instructor has extended your assignment due date to this Sunday, April 10. Your instructor has also let you to take your Quiz # 2 during his office hours during this week. Let me know if you need additional support to study for this quiz. Your grade to date in this class is 30.2/37 81.62% B.…

    • 354 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    | |Note that, in general, an organism name appears ONCE on your tree—at the point it was eliminated as a choice. The path to your identified organism should be |…

    • 629 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    Ks3 Math Test Mark Scheme

    • 5361 Words
    • 22 Pages

    Correct response 1m Writes the leaves in the correct order for area, ie Willow smallest area Oak Beech largest area Additional guidance Unambiguous indication eg, for part (a) W smallest area O B largest…

    • 5361 Words
    • 22 Pages
    Powerful Essays
  • Good Essays

    Horses of the Night Notes

    • 834 Words
    • 4 Pages

    "The trees were still growing, and the leaves were firmly and greenly on them. The branches has been coaxed into formations of towers and high-up nests where you could look out and see for a hundred miles or more." - IMAGERY…

    • 834 Words
    • 4 Pages
    Good Essays
  • Good Essays

    2-Vincent Rossi Symbolism

    • 985 Words
    • 4 Pages

    In St. Francis’ praise to God for His creation in “The Canticle of Brother Sun”, what levels of Rossi’s categories of meaning (natural, metaphoric, symbolic, iconic) do you think Francis achieves?…

    • 985 Words
    • 4 Pages
    Good Essays
  • Better Essays

    The narrator confesses straight away that it “seemed” like the most “wondrous tree,” therefore even though the tree looked aesthetically pleasing that is not its true self. The following lines support this theory:…

    • 920 Words
    • 4 Pages
    Better Essays
  • Powerful Essays

    Cen 254 Data Structure

    • 924 Words
    • 4 Pages

    keys 30, 40, 24, 58, 48, 26, 11, 13 (in this order). Draw the tree after each…

    • 924 Words
    • 4 Pages
    Powerful Essays
  • Powerful Essays

    Anil Short Story

    • 2987 Words
    • 12 Pages

    he had once seen the tree wrap it vines around little kids who ventured unknowingly…

    • 2987 Words
    • 12 Pages
    Powerful Essays
  • Good Essays

    A tree cannot grow new leaves unless the dead leaves are gone first, and in the first stanza as the “gentle gardener” shakes the tree “with a strange passion,” the gardener’s act seems threatening and violent, but in reality, he does this out of strong affection for it. From there on, the tree is left empty, and Chang links this independent growth of a tree to a time in his own life when he felt alone, described in the second stanza as “the lost river of my existence.” He feels “lost” because he has been abandoned, but one has to hit rock bottom before being able to grow from the experience and move on. In the end, the tree “glowed again with golden leaves,” showing the success of the tree to thrive again on its own, just as the gardener intended from the start. Like the tree, the speaker realizes that he is able to move on as well.…

    • 1180 Words
    • 5 Pages
    Good Essays
  • Good Essays

    Parallel Arrays

    • 427 Words
    • 2 Pages

    Key in saving wasted memory. The nodes of a linked data structure can also be moved individually to different locations without affecting the logical connections between them, unlike arrays. With due care, a process can add or delete nodes to one part of a data structure even while other processes are working on other parts. On the other hand, access to any particular node in a linked data structure requires following a chain of references that stored in it. If the structure has n nodes, and each node contains at most b links, there will be some nodes that cannot be reached in less than log b n steps. For many structures, some nodes may require worst case up to n -1 steps.…

    • 427 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Secondly, the reading suggests to plant trees in a totally new place. However, the lecturer says that planting the tree in a new place might unpredicted results. She elaborates on this by stating…

    • 230 Words
    • 1 Page
    Satisfactory Essays
  • Good Essays

    The Windows operating systems use a tree form of data structure rather the linked list. Each node of the tree is known as Virtual Address Descriptors (VAD) having a range of memory addresses. It is the responsibility of the VAD to mark each and every node as reserved for thread’s stack, free or committed.…

    • 670 Words
    • 3 Pages
    Good Essays