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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education