I am having trouble determining time complexity when it comes to finding the runtime of a method or function. I need to know what the runtime for the following methods are. Any further explanation would also be helpful. All of these methods are dealing with a binary search tree in java. 1. public String getAllValues() - return a String that contains the elements of the tree in ascending order. All elements are separated by a space. 2. public int numberNodes() - return the total number of nodes in the tree. 3. public void insertList(int[] list) - insert all of the values from list into the tree. Note: My Method just goes through an array calling working insert() method on all the values in the list[] array. 4. public int removeLessThan(int value) - this method removes all integers strictly less than value from the tree. It also returns the number of nodes it removed. Note: In this method I first call a method to count nodes less than I call another method to recursively remove by truncating the left tree of any node less than value 5. public int numberOfLeaves() - return the number of leaves in the tree. 6. public int numberOfFullParents() - return the number of nodes that have 2 children. 7. public int howManyAtLevel(int level) - this method returns the num- ber of nodes at a particular level. 8. public int removeAllLeaves() - this method removes all leaves from the original tree. It also returns the number of leaves it removed.   I only need the runtimes in terms of Big Theta. I DO NOT NEED THE METHODS as this is already done. I am assuming most of the runtimes are Big Theta of (n) but not completely sure. Thank you.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16PE: The implementation of a queue in an array, as given in this chapter, uses the variable count to...
icon
Related questions
Question

I am having trouble determining time complexity when it comes to finding the runtime of a method or function. I need to know what the runtime for the following methods are. Any further explanation would also be helpful.

All of these methods are dealing with a binary search tree in java.

1. public String getAllValues() - return a String that contains the elements
of the tree in ascending order. All elements are separated by a space.

2. public int numberNodes() - return the total number of nodes in the tree.

3. public void insertList(int[] list) - insert all of the values from list into
the tree.

Note: My Method just goes through an array calling working insert() method on all the values in the list[] array.

4. public int removeLessThan(int value) - this method removes all integers strictly less than value from the tree. It also returns the number of nodes it
removed.

Note: In this method I first call a method to count nodes less than I call another method to recursively remove by truncating the left tree of any node less than value

5. public int numberOfLeaves() - return the
number of leaves in the tree.

6. public int numberOfFullParents() - return the number of nodes that
have 2 children.

7. public int howManyAtLevel(int level) - this method returns the num-
ber of nodes at a particular level.

8. public int removeAllLeaves() - this method removes all leaves from the
original tree. It also returns the number of leaves it removed.

 

I only need the runtimes in terms of Big Theta. I DO NOT NEED THE METHODS as this is already done.

I am assuming most of the runtimes are Big Theta of (n) but not completely sure. Thank you.

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Types of trees
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning