Preview

Data Structures Final Exam Review

Good Essays
Open Document
Open Document
1611 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Data Structures Final Exam Review
Ch. 4 Trees

• Depth: length of the unique path from root to node
• Height: length of the longest path from the node to a leaf
• Keep children in a linked list
• Preorder traversal: work at the node is done before its children are processed
• Postorder traversal: work at a node is performed after its children are evaluated
• Binary tree: no node can have more than two children o Average depth is O(rootN), O(logN) for binary search tree o Can maintain references to children cuz there’s only 2
• Example of a binary tree: expression tree o Leaves are operands, other nodes contain operators o Inorder traversal: recursively print left child, then parent, then right
• O(N) o Postorder traversal: recursively print left subtree, right subtree, then operator → O(N) o Preorder traversal: print operator, then recursively print the left and right subtrees o Constructing an expression tree from a postfix expression: read one symbol at a time; if operand, create a one-node tree and push it onto a stack. If operator, pop two trees T1, T2 from stack, and form a new tree whose root is the operator, and whose left and right children are T2 and T1; push new tree onto stack
• Binary search tree: binary tree with the property that for every node X, the value of all items in its left subtree are < X and the value of all items in the right subtree are > X o Contains: Uses O(logN) stack space o findMin, findMax: traverse all the way left or right from the root o insert: traverse down tree as would with contains, stick it at the end o remove: easy if leaf or has one child; if two children; replace data in node with smallest data of right subtree, and recursively delete that node o Lazy deletion: if expected number of deletions is small, just mark the node as deleted but don’t actually do anything; small time penalty as depth doesn’t really increase o Running time of all operations on a node is O(depth), and the average depth is O(logN) o If input is presorted,

You May Also Find These Documents Helpful

  • 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
  • Good Essays

    Reduce: Reduce step processes the data from the slave nodes and outputs from the map task serves as the input to reduce task and to form the final and ultimate output.…

    • 496 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    QUESTION 1: Which three states had the largest (positive) change in average weekly earnings over this time period (remember to use the correct units in your answer)?…

    • 484 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Searching and Sorting Streams and Files Graphics GUI Components and Events Mouse, Keyboard, Sounds, and Images Big-O Analysis of Algorithms The Java Collections Framework Lists and Iterators Stacks and Queues Recursion Revisited Binary Trees Lookup Tables and Hashing Heaps and Priority Queues Design Patterns…

    • 3908 Words
    • 16 Pages
    Powerful Essays
  • Good Essays

    Math Midterm

    • 1005 Words
    • 5 Pages

    A decision tree is a diagram consisting of circles decision nodes, square probability nodes and branches.…

    • 1005 Words
    • 5 Pages
    Good Essays
  • Good Essays

    This is the tree I was talking about. I'm not sure, Zweli. There was no tree there.…

    • 2529 Words
    • 11 Pages
    Good Essays
  • Satisfactory Essays

    Design a modular program that asks the user to enter a distance in kilometers, and the converts that distance to miles. The conversion formula is as follows:…

    • 620 Words
    • 5 Pages
    Satisfactory Essays
  • Good Essays

    AMH 2010 exam 1 notes

    • 2006 Words
    • 8 Pages

    As the next generation of colonists moved westward to find new, fertile land, they encountered plentiful acreage at cheap prices. Frontier families lived with the bare necessities acquired through subsistence farming, created a widely dispersed society of equals, and were subjected to a disorganized existence without organized law and order, community institutions, or organized churches. Thus, frontier communities became volatile and violent places where deep divisions festered between its residents and those of the eastern seaboard.…

    • 2006 Words
    • 8 Pages
    Good Essays
  • Powerful Essays

    MDM4U – Grade 12 Data Management – Exam Unit 1: One Variable Analysis Types of Data Numerical Data Discrete: consists of whole numbers Ie. Number of trucks. Continuous: measured using real numbers Ie, Measuring temperature.…

    • 2372 Words
    • 10 Pages
    Powerful 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
  • Good Essays

    Assuming that data mining techniques are to be used in the following cases, identify whether the task required is supervised or unsupervised learning.…

    • 362 Words
    • 2 Pages
    Good Essays
  • Powerful Essays

    1. What is the ability of the world's populace to volunteer and collaborate on large projects called?…

    • 1964 Words
    • 8 Pages
    Powerful Essays
  • Good Essays

    In the first half of the 19th century, even though a few women such as Susan B. Anthony started social reform activities, majority of women were restricted by a strict female virtue consensus. Most of them were recognized as domestic workers with their legal rights largely incorporated into the men’s in their families. Before the 1860s, many middle-class white women received education, but mostly were only enough for child nurturing. Rarely would a woman attain equal education as men; however, she would still be considered as intellectually inferior to men in the society. In the early 1800s, most women’s primary concerns were family affairs. Girls and women’s primary education were to learn to manage new domestic devices such as stoves and…

    • 281 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    IIS Smooth Streaming Management REST Services authorization is performed by checking user access rights to the publishing point (.isml) file. GET operations require read access to the publishing point file. PUT or DELETE operations require write access for the files. Creating a new publishing point using the POST operation…

    • 390 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Rainforest

    • 1284 Words
    • 6 Pages

    The Mt Keira rainforest is located in Wollongong, New South Wales in Australia. The Mt Keira rainforest is what we call a subtropical rainforest. There are four types of rainforest: Tropical, subtropical, warm-temperate and cool-temperate. Tropical rainforests have generally have a warmer climate than subtropical rainforests. Warm-temperate rainforest are slightly cooler than subtropical rainforests, and cool-temperate rainforests have very cool climates, i.e. Canada.…

    • 1284 Words
    • 6 Pages
    Good Essays

Related Topics