Explain the use of the binary heap as an effective implementation for a priority queue .
a. Describe the concept of a Binary heap and the heap order property.
1.Create a class to implement a queue using a circular array<o:p></o:p>
a. The class should contain functions to
i. Insert a new value
ii Delete a value.
iii. Change a value equal to X to a value equal to Y.
iv. Count all value equal to X in the queue.
For each function above perform an asymptotic analysis and state the worst case performance of the algorithm
Develop a program called National_lottery that determines the winning lottery numbers. The program must use the rand function to produce six(6) random numbers between 0 & 49 & number must not repeat. The numbers are generated by a user by clicking a button called Generate six(6) numbers.
-Then use an appropriate pointer operator to print the addresses of the numbers in memory & must be expressed in hexadecimals.
-use the derefencing operatorto point to values contained within the addresses. Use the function sort with begin() & end() function.
-Then assign the values into an array called winning_numbers. Use the for statement or the initialiser list to initialise the numbers into the array. Search the winning_numbers for any two(2) array elements(subscripts) that give the sum of >= 80 when added together, if the numbers >= 80 are more than one(1) set, consider the biggest set to be the one chosen for draw
3 Create a class called 'TIME' that has three integer data members for hours, minutes and seconds, a constructor to initialize the object to some constant
value, member function to add two TIME objects, member function to
display time in HH:MM:SS format. Write a main function to create two
TIME objects, add them and display the result in HH:MM:SS format.
Sample Run 1
Welcome to CS126 Mart!
Item Codes Description Price
100 Sweet ‘n Ripe Grapes 125.35
101 Crunchy Apples 52.20
109 Green Peas 25.75
Enter Code: 128
Invalid code. This program will exit.
Sample Run 2
Welcome to CS126 Mart!
Item Codes Description Price
100 Sweet ‘n Ripe Grapes 125.35
101 Crunchy Apples 52.20
109 Green Peas 25.75
Enter Code: 100
Sweet ‘n Ripe Grapes 125.35
Quantity -3
Invalid quantity
You are given a side of a square as input. Write a program to find the perimeter and area of the square.
The input is an integer representing the length of the side of the square.
The first line of the output should contain area of the square, and the second line of the output should contain the perimeter of the square as per the format shown in the sample output.
Given the length of the side is
2. As the area of square is
side*side and the perimeter of the square is 4*side.Then output should be