for i in displayList:
print(i[0])
#loop through displayList
for i in range(0,len(displayList)):
#Test if the fist item in the current sub-list contains the text "Price Level
#Tip: Remeber that each sub-list is a (displayList). So you have
# to access its items via displayList followed by TWO indexes.
......
#Extract the second item from the currnet sub-list into variable called priceLevel
priceLevel = ...
#Test if priceLevel is between previousPrice and currentPrice OR
# priceLevel == previousPrice OR
# priceLevel == currentPrice
if....
:
#Sound the alarm. Pass in the frequency and duration.
if self.__currentPrice > self.__previousPrice:
frequency = 800
duration = 700
else:
frequency = 400
duration = 700
winsound.Beep(frequency, duration)
#Print the text 'Alarm' with a green background color, so that the user
#can go back and check when the alarm was sounded.
...a. Describe the concept of a Binary heap and the heap order property. [10 marks]
b. Explain the use of the binary heap as an effective implementation for a priority queue [10 MARKS]
Simulate the fragment of codes below and trace the output.
int *p1, *p2;
p1 = new int;
p2 = new int;
*p1 = 10;
*p2 = 20;
cout << *p1 << “ ” << *p2 << endl;
p1 = p2;
cout << *p1 << “ ” << *p2 << endl;
*p2 = 30;
cout << *p1 << “ ” << *p2 << endl;
Write a program that will prompt the user to input the following:
1. The number of dice to be rolled.
2. How many times the dice should be rolled?
Since the values above will vary, you must use pointer arrays and dynamically allocate memory.
The program will store the total of faces per roll and the values will be later used to plot a graph. The graph should look like the output shown below
3:
4:
5:
6:
7:
8: *
9:
10:
11:
12: *
13:
14:
15:
16:
17:
18:
The asterisk (*) tallies the number of times that total has occurred. 3 and 18 are the minimum and maximum totals, respectively, for rolling 3 dice.
The declaration and implementation sections of the class have been defined for you. Use it to complete your program.