Preview

Cen 254 Data Structure

Powerful Essays
Open Document
Open Document
924 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Cen 254 Data Structure
CS113 Review Questions

July 18, 2009
This is a collection of some interesting problems, carefully collected to help you prepare better for the midterm and, which is more important, help you in understanding of the key concepts.
Try to solve them independently or with your friends.
Review problem 1 How many di®erent binary search trees can store the keys f1;2;3g? The same question for f1;2;3;4g.
Solution: For the ¯rst: 5. The second: there are 5 possibilities each when
1 and 4 are the root of tree. If 2 is the root of the tree, there are 2 di®erent
BSTs. The same when 3 is the root. In total, 14.
Review problem 2 Insert, into an empty binary search trees, entries with keys 30, 40, 24, 58, 48, 26, 11, 13 (in this order). Draw the tree after each insertion. Review problem 3 By giving an example, prove that the following claim is false: the order in which a ¯xed set of entries is inserted into a BST does not matter- the same tree results every time.
Review problem 4 In this problem you will design a linear-time algorithm that clones a binary tree T. This algorithm should construct an exact copy of
T. You are only allowed to use the methods of the Tree and Binary Tree ADTs
(i.e. isEmpty, root, parent, children, isInternal, isExternal, isRoot, size, elements, positions, swapElements, replaceElement, leftChild, rightChild, sibling, expandExternal, removeAboveExternal).
Describe (in pseudo-code) your algorithm.
1Hint: Do preorder traversal of the corresponding trees.
Review problem 5 Describe how to perform an operation removeAll(k), which removes all the entries whose keys equal k from a BST T.
Review problem 6 Give a recursive method for removing all the elements in a stack.
Solution: If the stack is empty return empty. Otherwise, pop() and recur.
Review problem 7 Describe the output of the following series of stack op- erations: push(5), push(3), pop(), push(2), push(8), pop(), pop(), push(9), push(1), pop(), push(7), push(6), pop(),

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Music Appreciation Test

    • 373 Words
    • 2 Pages

    Key of C is at the top with no flats or sharps. The circle goes around showing the ones most similar next to one another. On the right adds fifths, on the left goes down a fifth.…

    • 373 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

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

    • 850 Words
    • 3 Pages
    Good Essays
  • Good Essays

    ECET 370 Week 5 Lab 5

    • 650 Words
    • 3 Pages

    Exercise 2: Search Algorithms and Techniques Expand the project developed in the previous exercise to perform the following experiment: time the three search methods several times each and record the results. Compare the running times of the three search methods (sequential search, sorted search, and binary search) which are obtained during the experiment. What conclusions can be drawn?…

    • 650 Words
    • 3 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
  • Satisfactory Essays

    Blood and Edition Answer Key

    • 9679 Words
    • 39 Pages

    D 2. A 3. B 4. D 5. C 6.…

    • 9679 Words
    • 39 Pages
    Satisfactory Essays
  • Best Essays

    Cmn279 - Final Report

    • 2268 Words
    • 10 Pages

    3) The overall effectiveness of the organization’s programs/ span of influence in their respective areas.…

    • 2268 Words
    • 10 Pages
    Best Essays
  • Satisfactory Essays

    Comp 122 Week 1 Ilab

    • 662 Words
    • 3 Pages

    3. Design an algorithm in pseudocode to solve the problem. Make sure to include steps to get each input and to report each output.…

    • 662 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    MATH203 PHASE3

    • 268 Words
    • 1 Page

    The tree is not a binary tree because some nodes have more than two children. If a direct link…

    • 268 Words
    • 1 Page
    Satisfactory Essays
  • Satisfactory Essays

    DCN286 Notes

    • 1111 Words
    • 5 Pages

    Bits Per Second  Amount of data sent in a unit of time (per second)…

    • 1111 Words
    • 5 Pages
    Satisfactory Essays
  • Satisfactory Essays

    The Department of Transportation and Public Facilities submitted this position description for PCN 252764 and requested the update of an Airport Police and Fire Officer III. The position is vacant, located at Anchorage International Airport, and is supervised by PCN 252758 (Airport Police and Fire Officer V). Supervisory authority is assigned to the position.…

    • 186 Words
    • 1 Page
    Satisfactory Essays
  • Good Essays

    Cis 207 Information

    • 889 Words
    • 4 Pages

    There are numerous types of information that are used in daily life. We see information all the time, in different formats and configurations. In today’s society, information rules everything that we do. Information can be in a form of simple text message, to a complicated computer language in which information technology engineers use to write different software for different functions. Different companies use information in different ways, depending on the type of business they are in. Some companies might use an internal email, which is set up for office use only between each employee. Information flows in and through my company in many ways. The company that I work for is a reprographics company called Cyber Copy. Our company deals with large black and white to color format printing, to small black and white to color format printing. Information flows in and out of my company during all working hours. With that being said, everything runs on information in order to function in a fast paste society.…

    • 889 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    CECN506 - Chapter 2

    • 1841 Words
    • 8 Pages

    A contract that makes the owner of a security a part owner of the company that issued the security…

    • 1841 Words
    • 8 Pages
    Powerful Essays
  • Powerful Essays

    Part B (Do not write here) 1. 2. 3. Part C (Do not write here) 1.…

    • 2060 Words
    • 9 Pages
    Powerful Essays
  • Good Essays

    Lab1

    • 911 Words
    • 5 Pages

    a. Take a look at sample source files and read it carefully. There are three files:…

    • 911 Words
    • 5 Pages
    Good Essays