You have two puzzles with parameters as follows: Puzzle A: One sub-puzzles. k = 7. Puzzle B: Four sub-puzzles. k = 5. You should provide, for both cases other than part (b), the following: (a) The distribution of the number of cases that require each number of hashes. (b) Explain the method you used to obtain your distributions. Don’t go into too many details or show working, it’s more \I wrote a C++ program to ... and then using ... I ...". (c) A graph of the distribution of the data above. 0.5 Mark (d) The average number of hashes needed. (e) The standard deviation for the distribution of the number of hashes needed. You should assume that if there are N possible solutions you check the Nth by hashing even if all others have failed and there has to be a solution.
Given,
Two puzzles with parameters. One sub-puzzles.k = 7.Four sub-puzzles. k = 5.
#include<iostream>
#include<cmath>
using namespace std;
float calculateSD( float data[ ] );
int main( )
{
int i;
float data [ 10 ];
cout << " Enter 10 elements :" ;
for ( i= 0; i <1 ; ++i )
cin >> data [ i ];
cout << endl << "Standard Deviation =" << calculateSD( data )
return 0;
}
float calculateSD( float data [ ] )
{
float sum = 0.0, mean, standardDeviation = 0.0 ;
int i;
for ( i=0 ; i <10 ; ++i)
{
sum += data [ i ];
}
mean = sum/10 ;
for ( i=0; i<10; ++i )
standardDeviation += pow( data[ i ] - mean , 2 );
return sqrt ( standardDeviation / 10 );
}
Get Answers For Free
Most questions answered within 1 hours.