write a program using heaps in c++ oop too?
`Hey,
Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
#include <iostream> using namespace std; void max_heap(int *a, int m, int n) { int j, t; t = a[m]; j = 2 * m; while (j <= n) { if (j < n && a[j+1] > a[j]) j = j + 1; if (t > a[j]) break; else if (t <= a[j]) { a[j / 2] = a[j]; j = 2 * j; } } a[j/2] = t; return; } void build_maxheap(int *a,int n) { int k; for(k = n/2; k >= 1; k--) { max_heap(a,k,n); } } int main() { int n, i; cout<<"enter no of elements of array\n"; cin>>n; int a[30]; for (i = 1; i <= n; i++) { cout<<"enter elements"<<" "<<(i)<<endl; cin>>a[i]; } build_maxheap(a,n); cout<<"Max Heap\n"; for (i = 1; i <= n; i++) { cout<<a[i]<<endl; } }
Kindly revert for any queries
Thanks.
Write a program using OOP to contain the following methods. Use proper constructor and instantine different object to use the specified ,methods. The program must be interactive. A method called “displayCourse” which displays the name of CS courses offered in Loudoun. (CS200..) Set Coursename() Display Course time() Display Course name()\ HInt: Course info a=new courseInfo() a.displayCourseTime(name, …) Course name - CSC 200 , time 9;30 am CSC 201 time : 9:30 am
Write a C+OOP program that simulates a vending machine. The program should define at least two classes. Less than two classes will result in 20 points deduction. (30 points) One must be general vending machine (50 points) The other can be either vending machine of soda, or vending machine of snack. It must be a subclass of above general machine These vending machines should have following components and functions e Coin slot o Allow adding coins o Display total coin...
i need this to be in OOP using C++
25. Savings Account Balance Write a program that calculates the balance of a savings account at the end of a three-month feried. It should ask the user for the starting balance and the annual interest rate. A loop abculd then iterate once for every month in the period, performing the following steps: B) A) Ask the user for the total amount deposited into the account during that month and add it...
write code to demonstrate the features of oop use C# programming.
PlLEASE HELP !! Python II final project. Object Oriented Programming python.Make a program using OOP concepts. Anything will work as long as it runs in idle.
To be done in Java OOP Write a program that teaches arithmetic to a young child. The program tests addition and subtraction. In Level 1, it tests only addition of whole numbers less than ten whose sum is less than ten. In level 2, it tests addition of arbitrary single digit whole numbers. In level 3, it tests subtraction of single digit whole numbers with a non-negative difference. Generate random problems and get the players' input. The player gets up...
Define a problem utilizing an efficient sorting algorithm please write code in c++ oop thnx?
In Java Write a program the takes in a number and converts it to binary. Use an OOP class approach using class and objects
Write a C program that generates a random number between 0 and 50. Then, the program prompts for guesses until the user is correct, or has made 10 wrong guesses. After each guess, the program indicates whether the guess was too high, too low, or correct. Once the round has ended, either by a correct guess or by using up the 10 guesses, the program displays the current status.
program Java oop
The project description As a programmer; you have been asked to write a program for a Hospital with the following The Hospital has several employees and each one of them has an ID, name, address, mobile number, email and salary. . The employees are divided into Administration staff: who have in addition to the previous information their position. Nurse: who have their rank and specialty stored in addition to the previous o o Doctor: who have the...