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

Logic, to calculate the amount to be paid by a customer buying yummy cupcak...

to calculate the amount to be paid by a customer buying yummy cupcakes for his birth day party

Minimum shelf, At a shop of marbles, packs of marbles are prepared. Packets...

At 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 with thes

Create a program of several prototypes for functions, In this assignment th...

In this assignment the main has been written for you in the file phone_book_main.cpp. You will also notice that a class called Person has been declared as having several prototypes

Program to ask date & days added to produce -c++ program, THIS PROGRAM IS T...

THIS PROGRAM IS TO ASK A DATE & ALSO ASK FOR DAYS TO BE ADDED TO PRODUCE #include #include struct date  {   int dd;   int yy;   int mm;  }; void main()  {  clrscr();  in

C program for bank account, Aim: To implement a program for bank account u...

Aim: To implement a program for bank account using static data type. Code: class bank {             static int acc_no;             int acc;             float b

C program to demonstrate pointer to array, C program to demonstrate Pointer...

C program to demonstrate Pointer to array: void p2a(int *); void main() {                 int x=10, *a,**b;                 int arr[5];                 a=&x;//po

Can i drop the [] while deleteing array of some built-in , Can I drop the [...

Can I drop the [] while deleteing array of some built-in type (char, int, etc)? A: No. you can't Sometimes programmers think that the [] in the delete[] p only present so the

What are the debugging methods you employ while came across , What are the ...

What are the debugging methods you employ while came across a problem? A: Debugging with tools such as: 1.      DBG, GDB ,Forte, Visual Studio. 2.      Using tusc to trace

Explain encapsulation and data hiding, Encapsulation and Data Hiding Th...

Encapsulation and Data Hiding The property of being a self-contained unit is known as encapsulation. The idea that the encapsulated unit can be used without knowing how it work

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