Constructors and methods program, C/C++ Programming

Assignment Help:

To complete this assignment, edit the following constructors and methods:

1. public MaxPQ(Key[] keys) - change the following loop

for (int k = N/2; k >= 1; k--)

sink(k);

2. private void swim(int k)

3. private void sink(int k)

It may also help to write the following helper methods:

4. private int findParent(k) - returns the parent of element k

5. private int findLargestChild(k) - returns the child of k with the largest key.

Math 140 Project 2 Due Date is anytime on Nov 1, 2012  

Output for SIZE = 4:

Array values for the heap created with MaxPQ(Keys[] keys)

3, 1, 2, 0

Array values for the heap created with MaxPQ(int capacity)

3, 0, 1, 2

Output for SIZE = 12:

Array values for the heap created with MaxPQ(Keys[] keys)

11, 6, 9, 10, 4, 5, 1, 7, 8, 2, 0, 3

Array values for the heap created with MaxPQ(int capacity)

11, 5, 8, 10, 0, 3, 4, 1, 6, 7, 2, 9

Output for SIZE = 20:

Array values for the heap created with MaxPQ(Keys[] keys)

19, 18, 9, 12, 15, 17, 6, 7, 8, 2, 10, 11, 3, 13, 14, 4, 16, 0, 5, 1

Array values for the heap created with MaxPQ(int capacity)

19, 18, 8, 11, 13, 16, 17, 1, 6, 7, 2, 9, 10, 0, 5, 12, 3, 14, 15, 4


Related Discussions:- Constructors and methods program

Lennie, Lennie McPherson, proprietor of Lennie''''s Bail Bonds, needs to ca...

Lennie McPherson, proprietor of Lennie''''s Bail Bonds, needs to calculate the amount due for setting the bail. Lennie requires something of value as collateral, and his fee is 10%

Saha, find the minimum total number of shelves

find the minimum total number of shelves

Explain public derivation, Public derivation Public derivations are muc...

Public derivation Public derivations are much more common than private derivations. In this situation: The private members inherited from the base class are inaccessible

Influence on Social media - for Geek''s, Recently social media has been flo...

Recently social media has been flooded by fb posts, tweets, news articles about only thing demonetization.A great debate is ongoing over it. Most of the people discussing in social

Implementing functions, An employee’s total weekly pay equals the hourly wa...

An employee’s total weekly pay equals the hourly wage multiplied by the total number of regular hours plus any overtime pay. Overtime pay equals the total overtime hours multiplied

C program to replace every occurrence of in a string, Program is to replace...

Program is to replace every occurrence of in a string: Program is to replace every occurrence of c1 in string with c2 and have function return the no. of replacement int re

''c'' programme, Write a ''C'' program to accept any 3 digit integer number...

Write a ''C'' program to accept any 3 digit integer number from the keyboard and display the word equivalent representation of the given number.

Minimum shelf, #questionAt a shop of marbles, packs of marbles are prepared...

#questionAt a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets

Convert coordinate - c++ program, Convert coordinate: class rect{  ...

Convert coordinate: class rect{                 private :                 float  x,y;                   public :                 void  input()

Write program.., # Dear I want help to programmer that write C++ code for...

# Dear I want help to programmer that write C++ code for my small project as soon as posible If we can help me?..

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd