1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Svetradugi [14.3K]
3 years ago
12

After class a student asked why you would ever use a heap instead of a binary search tree. Provide a good explanation for why an

d when you would.
Computers and Technology
1 answer:
sertanlavr [38]3 years ago
5 0

Answer:

Heap is useful when you want to find max/min element in the given list

BinarySearchTree is used if you need sorted elements of the list

Explanation:

Heap is Good at finding Min/Max and it's time complexity is  (O(1)), while BST is good at all finds (O(logN)). Insert is O(logN) for Heap and BSTstructures..

Max Heap ensures that elements on higher levels are greater than elements at lower level

MinHeap ensures that elements on higher levels are lesser than elements at lower level

BST gives sorted elements by following order (left,root,right).If we want sorted elements we can go with BST

You might be interested in
Non-Discretionary Items will increase or decrease without any action by Congress or the President. Which of the following is NOT
Alex_Xolod [135]
<span>A. Military Spending</span>
7 0
4 years ago
Create a program named Auction that allows a user to enter an amount bid on an online auction item. Include three overloaded met
Olin [163]

Answer:

Explanation:

The following code is written in Java and creates the overloaded methods as requested. It has been tested and is working without bugs. The test cases are shown in the first red square within the main method and the output results are shown in the bottom red square...

class Auction {

   public static void main(String[] args) {

       bid(10);

       bid(10.00);

       bid("10 dollars");

       bid("$10");

       bid("150 bills");

   }

   public static void bid(int bid) {

       if(bid >= 10) {

           System.out.println("Bid Accepted");

       } else {

           System.out.println("Bid not high enough");

       }

   }

   public static void bid(double bid) {

       if(bid >= 10) {

           System.out.println("Bid Accepted");

       } else {

           System.out.println("Bid not high enough");

       }

   }

   public static void bid(String bid) {

       if (bid.charAt(0) == '$') {

           if (Integer.parseInt(bid.substring(1, bid.length())) > 0) {

               System.out.println("Bid Accepted");

               return;

           } else {

               System.out.println("Bid not in correct Format");

               return;

           }

       }

       int dollarStartingPoint = 0;

       for (int x = 0; x < bid.length(); x++) {

           if (bid.charAt(x) == 'd') {

               if (bid.substring(x, x + 7).equals("dollars")) {

                   dollarStartingPoint = x;

               } else {

                   break;

               }

           }

       }

       if (dollarStartingPoint > 1) {

           if (Integer.parseInt(bid.substring(0, dollarStartingPoint-1)) > 0) {

               System.out.println("Bid Accepted");

               return;

           } else {

               System.out.println("Bid not in correct format");

               return;

           }

       } else {

           System.out.println("Bid not in correct format");

           return;

       }

   }

}

3 0
3 years ago
What is the age group for the silent genration
Maurinko [17]
21 years old. If you take 1944-1923 you get 21 because that would be ho wold they are
7 0
3 years ago
Ano ang ibig sa bihin ng birtud sa tagalog?​
Norma-Jean [14]

Answer:

hixiysk. cuxhuzig u gufx6cugx6rzutze5zx7fh ug. guxt u ghost I s u gzuz6rc7fc7x6rx

6 0
3 years ago
Solve the expression 4*3/ (5+2) 7%4
oksian1 [2.3K]

Answer:

36/7

Explanation:

First, multiply 4 and 3 then add 5 and 2 the answer you will get is 12/7, and then calculate 7%4 answers you will get is 3 now multiply 12/7 and 3 your answer will be 36/7

3 0
2 years ago
Other questions:
  • Is it possible to increase watch hours for a channel by making a playlist out of your videos for people to watch? Will it boost
    13·1 answer
  • Which feature of a browser will you select to block pop-ups? view help tools file
    15·2 answers
  • Write an if/else statement that compares the variable age with 65, adds 1 to the variable seniorCitizens if age is greater than
    14·1 answer
  • Are there any human lanaguages with context free grammar
    11·1 answer
  • What device connects your computer to a wireless network?
    11·2 answers
  • In 1–2 sentences describe how you would insert a row in a spreadsheet.
    11·1 answer
  • When reading words with a scanner object, a word is defined as ____?
    15·1 answer
  • Describe computer as a source of communication.​
    5·1 answer
  • What is the only way to remove a password encryption on an Excel file?
    6·2 answers
  • What is it called when u want 2 or more cells into 1
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!