Question
Discrete Math

Max Heap After you build your heap, you then compare the values of the vertices, in the following way: If a child of a parent
0 0
Add a comment Improve this question Transcribed image text
Answer #1

In worst case, the swapping operation will occur for full height of heap i.e the root element can become the leaf node. Thus, running time will be O(h) = O(lgn). In best case. the swap will not happen, thus constant time O(1)

Add a comment
Know the answer?
Add Answer to:
Discrete Math Max Heap After you build your heap, you then compare the values of the vertices, in the following way: If a child of a parent node is larger than the parent node, switch their posit...
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
  • Discrete Mathematics Repeat Maximizing the Heap The process of maximizing the heap and removing vertices continues until the heap has one vertex. The following results of the remaining steps for...

    Discrete Mathematics Repeat Maximizing the Heap The process of maximizing the heap and removing vertices continues until the heap has one vertex. The following results of the remaining steps for this example are: 1 swaps positions with 6. 1 swaps positions with 4. Then 1 swaps positions with 6 and 6 is removed L=[1, 4, 2, 6, 8] 1. 4 2. 1 swaps positions with 4. 4 swaps positions with 2. Then 4 is removed from the heap. に[1, 2,...

  • Discrete Mathematics Time Complexity Analysis Due: May 9th, 2019 Math 4 6026 Heap Sort Another algorithm for sorting uses a specialized tree structure called a "heap." Specifically, we wi...

    Discrete Mathematics Time Complexity Analysis Due: May 9th, 2019 Math 4 6026 Heap Sort Another algorithm for sorting uses a specialized tree structure called a "heap." Specifically, we will use a binary heap, which is like a binary tree with hierarchy. Here is an example of a binary heap structure 1. 2. There is a top vertex, called the parent vertex (aka node). The top parent vertex connects to two vertices a level below. These vertices are the "left child"...

  • Write a Java program, In this project, you are going to build a max-heap using array...

    Write a Java program, In this project, you are going to build a max-heap using array representation. In particular, your program should: • Implement two methods of building a max-heap. o Using sequential insertions (its time complexity: ?(?????), by successively applying the regular add method). o Using the optimal method (its time complexity: ?(?), the “smart” way we learned in class). For both methods, your implementations need to keep track of how many swaps (swapping parent and child) are required...

  • Need help with the trickle down This is the maxheap.h #ifndef MAXHEAP_H_INCLUDED #define MAXHEAP_H_INCLUDED #include <vector>...

    Need help with the trickle down This is the maxheap.h #ifndef MAXHEAP_H_INCLUDED #define MAXHEAP_H_INCLUDED #include <vector> #include <sstream> #include <string> #include <queue> #include <cmath> // pow() using namespace std; #define PARENT(i) ((i-1) / 2) #define LINE_WIDTH 60.0 template<class T> class MaxHeap{ // private: vector<T> heap; void bubbleUp(int id);    void Heapify() { int length = heap.size(); for(int i=length / 2 -1; i>=0; --i) trickleDown(i); }; public: MaxHeap( vector<T> &vector ) : heap(vector) { Heapify(); } ; MaxHeap() {}; void trickleDown(int...

  • I've posted 3 classes after the instruction that were given at start You will implement and...

    I've posted 3 classes after the instruction that were given at start You will implement and test a PriorityQueue class, where the items of the priority queue are stored on a linked list. The material from Ch1 ~ 8 of the textbook can help you tremendously. You can get a lot of good information about implementing this assignment from chapter 8. There are couple notes about this assignment. 1. Using structure Node with a pointer point to Node structure to...

  • Need this in C The starter code is long, if you know how to do it...

    Need this in C The starter code is long, if you know how to do it in other way please do. Do the best you can please. Here's the starter code: // ----------------------------------------------------------------------- // monsterdb.c // ----------------------------------------------------------------------- #include #include #include // ----------------------------------------------------------------------- // Some defines #define NAME_MAX 64 #define BUFFER_MAX 256 // ----------------------------------------------------------------------- // Structs typedef struct { char name[NAME_MAX]; int hp; int attackPower; int armor; } Character; typedef struct { int size; Character *list; } CharacterContainer; // ----------------------------------------------------------------------- //...

  • Evaluate the arical writ the response in which you state your agreement or disagreement with writer...

    Evaluate the arical writ the response in which you state your agreement or disagreement with writer up un these questions guidelines 1) can empathy lead us astrary? how 2) our heart will always go out to the baby in the well, its a measure of our humanity. but empathy will have to yield to reason if humanity is to have a future can empathy yield to reason? how? thank you The Baby in the Well: The Case against Empathy* -Paul...

  • Complete the following assignment with the tester class included. *If the text is too small in...

    Complete the following assignment with the tester class included. *If the text is too small in the pictures to read, open a new window and copy and paste the address below into the search bar, and go to that page for the same instructions in the pictures below: This is the address for the same instructions in the pictures below: https://www.chegg.com/homework-help/questions-and-answers/purpose-purpose-lab-design-write-many-complex-methods-working-arrays-array-list-objects-ma-q37244441?trackid=6abm6xXV Tester Class: public class Tester { /** * main() method */ public static void main(String[] args) { // No...

  • Amazon to Competition: We Will Crush You! Amazon to Employees: We Will Churn You! Globally, Amazon...

    Amazon to Competition: We Will Crush You! Amazon to Employees: We Will Churn You! Globally, Amazon is one of the largest and most successful companies in any industry. Technological innovation has contributed to its success, as has its employee acquisition practices, which are exceptionally high. The question is what has allowed this company to thrive and maintain its success? This activity is important because it shows how companies like Amazon hire based on personality and individual differences. Such companies place...

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
ADVERTISEMENT