Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 21, Problem 9MC
Program Description Answer
The number of comparisons made by this heapsort method is “O (n log n)” when it sorts the array with “n” values.
Hence, the correct answer is option “B”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Java program to return the third smallest element in the Binary Search Tree in O(n) time.
VERY IMPORTANT: The value of the third smallest element is ”3”. You may choose either a recursive or an iterative solution, but you are NOT allowed to maintain an extra array to store values of the tree elements for a linear scan later to return the required value. Also, you can’t just return 3 :)
Java language
NOTE THAT WE ARE USING **LINKED LISTS** SEE PICTURES FOR ALL INFORMATION
Solve method
public boolean inSort(double elt) {
//code goes here
}
please and thank you!!!!
JAVA
Write a Java method named FillTree that can fill a Binary Search Tree using 10 words that areread from the user via the keyboard. The first two words should be your first name and last name.The other 8 words can be anything of your choice. The Binary Search Tree should come from themain method. The main method calls FillTree and pass it a Tree to be filled;
Chapter 21 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Ch. 21.1 - Prob. 21.2CPCh. 21.1 - Prob. 21.3CPCh. 21 - Prob. 1MCCh. 21 - Prob. 2MCCh. 21 - Prob. 3MCCh. 21 - Prob. 4MCCh. 21 - Prob. 5MCCh. 21 - Prob. 6MCCh. 21 - Prob. 7MCCh. 21 - Prob. 8MC
Ch. 21 - Prob. 9MCCh. 21 - Prob. 10MCCh. 21 - Prob. 11TFCh. 21 - Prob. 12TFCh. 21 - Prob. 13TFCh. 21 - Prob. 14TFCh. 21 - Prob. 15TFCh. 21 - Prob. 16TFCh. 21 - Prob. 17TFCh. 21 - Prob. 18TFCh. 21 - Prob. 19TFCh. 21 - Prob. 20TFCh. 21 - Prob. 21TFCh. 21 - Prob. 1FTECh. 21 - Prob. 2FTECh. 21 - Prob. 3FTECh. 21 - Prob. 1SACh. 21 - Prob. 2SACh. 21 - Prob. 3SACh. 21 - Prob. 4SACh. 21 - What is a priority queue?Ch. 21 - Prob. 6SACh. 21 - Prob. 7SACh. 21 - Prob. 1AWCh. 21 - Prob. 2AWCh. 21 - Prob. 3AWCh. 21 - Prob. 4AWCh. 21 - Prob. 5AWCh. 21 - Prob. 6AWCh. 21 - Prob. 7AWCh. 21 - Prob. 4PCCh. 21 - Prob. 6PC
Knowledge Booster
Similar questions
- Python: Written without libraries method find_ansestors , that takes in an index i and returns all ancestors of node located at index i. What is the time complexity of your function? class ArrayBinaryTree: def __init__(self): self._heap = [] def find_ancestors(self, i: int): if(i==0): return;arrow_forwardJava - This project will allow you to compare & contrast different 4 sorting techniques, the last of which will be up to you to select. You will implement the following: Bubble Sort (pair-wise) Bubble Sort (list-wise) [This is the selection sort] Merge Sort Your choice (candidates are the heap, quick, shell, cocktail, bucket, or radix sorts) [These will require independent research) General rules: Structures can be static or dynamic You are not allowed to use built in methods that are direct or indirect requirements for this project – You cannot use ANY built in sorting functions - I/O (System.in/out *) are ok. All compare/swap/move methods must be your own. (You can use string compares) Your program will be sorting names – you need at least 100 unique names (you can use the 50 given in project #3) – read them into the program in a random fashion (i.e. not in any kind of alpha order). *The more names you have, the easier it is to see trends in speed. All sorts will be from…arrow_forwardThe implementation of a queue in an array, as given in this chapter, uses the variable count to determine whether the queue is empty or full. You can also use the variable count to return the number of elements in the queue. On the other hand, class linkedQueueType does not use such a variable to keep track of the number of elements in the queue. Redefine the class linkedQueueType by adding the variable count to keep track of the number of elements in the queue. Modify the definitions of the functions addQueue and deleteQueue as necessary. Add the function queueCount to return the number of elements in the queue. Also, write a program to test various operations of the class you defined.arrow_forward
- Heap sort is considered: Select one: a. in place and stable b. in place and most efficient c. in place d. stable and most efficient e. stablearrow_forwardCode: Number of Balanced BTsSend FeedbackGiven an integer h, find the possible number of balanced binary trees of height h. You just need to return the count of possible binary trees which are balanced.This number can be huge, so, return output modulus 10^9 + 7.Write a simple recursive solution.Input Format :The first and only line of input contains an integer, that denotes the value of h. Here, h is the height of the tree.Output Format :The first and only line of output contains the count of balanced binary trees modulus 10^9 + 7.Constraints :1 <= h <= 24Time Limit: 1 secSample Input 1:3Sample Output 1:15Sample Input 2:4Sample Output 2:315Solution:===========================================================================public class Solution {.arrow_forwardIN JAVA LANGUAGE FILL OUT THE FIND MAX FUNCTION public int findMax();/* Returns the largest element in the tree.* This method should call upon the recursive findMax_r() you write.** @return the largest element in the tree (an int value)* Example: findMax() will return 29 for the tree below** (28)* / \* (14) (29)* /* (1)*/ DO THIS BY CALLING A RECURSIVE FUNCTION SHOULD RETURN LARGEST ELEMENT IN A BST THANK YOU!!!!!arrow_forward
- python Given a list `1st`, please use list comprehension and recursion to create a list that contains only elements of the list `1st` which are both primes and Fibonacci numbers. Ex. [1,3,6,7,8,13] → [3,13]arrow_forwardCreate a Binary Search Tree Class with the following four Operations using a single C++ program: Operations: 1. Insert(int n) : Add a node the tree with value n. Its O(lgn) 2. Find(int n) : Find a node the tree with value n. Its O(lgn) 3. Delete (int n) : Delete a node the tree with value n. Its O(lgn) 4. Display(): Prints the entire tree in increasing order. O(n).arrow_forwardPythonarrow_forward
- Java: Write a program to find the number of comparison using sequentialSearch and binarySearch algorithms using an array of 1200 elements. Use a random number generator to fill list by using a sorting algorithm to sort list and search list for the binary search algorithm to search list. Use the sequential search algorithm to search list and print the number of comparisons. If the item is found in the list, print its position. public class SearchSortAlgorithms<T> implements SearchSortADT<T>{private int comparisons;public int noOfComparisons(){return comparisons;}public void initializeNoOfComparisons(){comparisons = 0; }public int seqSearch(T[] list, int start, int length, T searchItem){int loc;boolean found = false;for (loc = start; loc < length; loc++){if (list[loc].equals(searchItem)){found = true;break;}}if (found)return loc;elsereturn -1;}public int binarySearch(T[] list, int start, int length, T searchItem){int first = start;int last = length - 1;int mid = -1;boolean…arrow_forwardTrace insertion sort for list ={18,57,8,89,7}arrow_forward*Please using JAVA only*arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning