Question

a.

If the client requests the removal of a single node in a general tree (a tree with no limit on the number of children per nod

b.

This is a sum-the-data-in-the-tree question. It asks whether a method, sumAll0 is a well-written recursive method. You will s

c.

java.util Linked Lists have which of the following properties? (Check all that apply.) Their add) method requires us to pass

If the client requests the removal of a single node in a general tree (a tree with no limit on the number of children per node) as we have studied it, this might result in many more nodes than the one requested to be removed (from the client's perspective) While the answer will be the same for normal and lazy deletion, you can assume this tree does normal, not lazy, deletion, to avoid unnecessary thinking time. O True False
This is a sum-the-data-in-the-tree question. It asks whether a method, sumAll0 is a well-written recursive method. You will see three different versions of this question throughout the exam, but the opening assumptions, are identical for all such versions. The only difference between the various questions is the code that implements the method sumAll). Assumptions: The general tree in this problem is assumed to be physical, i.e., there is no lazy or soft deletion designed into this tree. While this is from a generic class with data type E, we assume that the client establishes E as Integer when instantiating the tree, so that the data can be added. We are considering a recursive work-horse method to sum all the (assumed) integer data of the sub-tree. The sub-tree is specified by the root pointer passed in. As usual, some client would pass a root to this method, then this recursive method would generate other (child or sibling) roots to pass to itself when recursing. The members sib and firstChild have the same meanings as in our modules. True of False: The method, as defined below, is a good recursive method for summing the data of the sub-tree, based at the root node passed in. To be true, it must satisfy all the following criteria. If it misses one, it is false: 1. It gives the right sum for the sub-tree, that is, it does not miss counting any data 2. it does no unnecessary work, micro-management or superfluous testing. 3. It covers all situations (empty trees, null roots, handles all the children, etc.). int sumAll(FHgTreeNode root) int sibSum, thisSum, childrenSum; if (root null) return ; = sumAllCroot.sib); childrenSum = sumAll(root. firstChild); this Sum (Integer)(root.data); sibSum sibSum thisSum; return childrenSum True O False
java.util Linked Lists have which of the following properties? (Check all that apply.) Their add) method requires us to pass a wrapper object, like Float, rather than a primitive, like float to them. They are supplied to us as a generic class, meaning we can declare, in one statement, a Linked List of user-defined class data just as easily as if we were to define a LinkedList of Float type. They do not require that any ordering relation (like an compareTo()) be defined for the underlying data type. They can be directly declared by passing a primitive data type, like float, to the type parameter, without using a wrapper class, Float. They have an associated generic class Listlterator, which can be used to iterate through Linked Lists.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

a. True

b. False

Explanation:

The order in which thr recursive calls are being made is incorrect.

c.

  • They are supplied as a generic class, meaning we can declare in one statement, a LinkedList of user-defined class data just as easily as if we were to define a LinkedList of Float type.
  • They do not require any ordering relation be defined for the underlying data type
  • They have an associated generic class ListIterator, which can be used to iterate through LinkedLists.
Add a comment
Know the answer?
Add Answer to:
a. b. c. If the client requests the removal of a single node in a general...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Check if an array is a heap in Java. Complete the method isHeapTree Together, these methods...

    Check if an array is a heap in Java. Complete the method isHeapTree Together, these methods are meant to determine if an array of objects corresponds to a heap. The methods are generic, and they should work with an array of any type T that implement Comparable<T>. Implement the second method so that it uses recursion to process the complete tree/subtree whose root is at position i in the array arr. The method should return true if that tree/subtree is...

  • This is a reminder that this is not a C++ or Java course. It is a...

    This is a reminder that this is not a C++ or Java course. It is a Data Structures course. This means that you are to write your own code unless otherwise specified in the assignment. The use of built in data structures types like linked lists, stacks, queues, trees, maps, graphs etc. is prohibited and will result in a 60% reduction in your grade. Furthermore, the lecture material presents code that should be used to get you started. Any data...

  • Create a recursive method that takes as input the root Node of a tree and returns true if the N v...

    Create a recursive method that takes as input the root Node of a tree and returns true if the N variable of each node within that tree has the correct value (i.e., all nodes are labeled with the proper size of the subtree they define), and false otherwise.

  • C++ Data Structures and Algorithms Binary Trees: Implementation Answer the following question(s) concerning implementing recursive functions...

    C++ Data Structures and Algorithms Binary Trees: Implementation Answer the following question(s) concerning implementing recursive functions to perform operations on linked lists of nodes arranged as binary trees. For these questions, use the following struct definition for the nodes of the tree (we will not templatize the node here, so you do not have to write template functions for these questions, just assume trees of <int>values): struct BinaryTreeNode { int item; BinaryTreeNode* left; BinaryTreeNode* right; }; Write a recursive function...

  • Does not pass the testcase testDTreeAdvancedReRootchangesParent Java I'm trying to extend the implementation of a general...

    Does not pass the testcase testDTreeAdvancedReRootchangesParent Java I'm trying to extend the implementation of a general tree with new operations that change the structure of the tree. I've created 5 classes: Node.java, SimpleNode.java, Tree.java, RerootableTree.java and SimpleTree.java(which is the main java class that I need to change). The code does not pass ONE TESTCASE : testDTreeAdvancedReRootchangesParent The code passes all the other testcases except theone mentioned above. This is because in the SimpleTree.java the method "reRoot(Node newRoot)" is most likely...

  • 1. Write a recursive function that returns the sum of all even integers in a LinkedBinaryTree. Yo...

    please explain each line of code! ( in python ) 1. Write a recursive function that returns the sum of all even integers in a LinkedBinaryTree. Your function should take one parameter, root node. You may assume that the tree only contains integers. You may not call any methods from the LinkedBinaryTree class. Specifically, you should traverse the tree in your function def binary tree even sum (root): Returns the sum of al1 even integers in the binary tree 2....

  • Write a recursive function (C++) that searches a binary tree that is NOT ordered like a...

    Write a recursive function (C++) that searches a binary tree that is NOT ordered like a BST. In other words, there is no ordering relationship among the parent, child or sibling node values. Use the following prototype and data structure: struct node { node *left; node *right; int val; }; // First parameter: pointer to a node // Second parameter: the value to find bool searchValue(node *, int); The function searchValue() should return true if the integer value in the...

  • Instructions Create a class BettterTree that extends OurTree, to facilitate the following. Update: if extending the...

    Instructions Create a class BettterTree that extends OurTree, to facilitate the following. Update: if extending the class is too much, you can modify class OurTree. In our discussions about OurTree, we focused on nodes and their left and right children. For each node in the tree, is there another node of interest in addition to its children? If yes, how would you extend OurTree for that? How will the behavior of addNode method change? OurTree Code: public class OurTree {...

  • (true/false) All nodes in the right subtree of a node must be smaller in value than...

    (true/false) All nodes in the right subtree of a node must be smaller in value than their parent (true/false) Each node in a binary search tree may contain zero, one, or two children nodes. (true/false) It is possible to recursively process a binary search tree to print all the data in a binary search tree in sorted order. (true/false) The value of a parent must be less than all its children. (true/false) All nodes in the right subtree of a...

  • In Java. How would this method look? LinkedBinaryTree.java import java.util.Iterator; public class LinkedBinaryTree implements BinaryTreeADT {...

    In Java. How would this method look? LinkedBinaryTree.java import java.util.Iterator; public class LinkedBinaryTree implements BinaryTreeADT {    private BinaryTreeNode root;    /**    * Creates an empty binary tree.    */    public LinkedBinaryTree() {        root = null;    }    /**    * Creates a binary tree from an existing root.    */    public LinkedBinaryTree(BinaryTreeNode root) {        this.root = root;    }    /**    * Creates a binary tree with the specified element...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT