Popular Posts

7 Jul 2014

Graphical representation of First fit and Best fit algorithms


This is a mini Project on:
*GRAPHICAL SIMULATION OF MEMORY ALLOCATION ALGORITHMS
*(FIRST FIT AND BEST FIT ALGORITHMS)
*Using C++ graphics (turboc3 DosBOX version 3.5)
-------------------------------------------------------------------------------------------------------
                                             
                                            https://www.youtube.com/watch?v=w1tx6d8-pmw

MEAN SQUARE DEVIATION


# Statistics With C++


//Program to calculate MEAN SQUARE DEVIATION for DISCRETE FREQUENCY DISTRIBUTION.

#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
const S=30;
class MSqdev
{
  public: float X[S],F[S],XM[S],SXM[S];
 float n,sqXM[S],FSXM[S],XF[S];
 float MQDe;
  public: void Getdata();
 void MeanSQdevi();
 void show();
};

void MSqdev :: Getdata()
{
  cout<<"\nEnter total number of your data : ";
  cin>>n;
  cout<<"\nEnter your data  : \n\n";
  for(int i=0;i<n;i++)
  {
    cout<<" X "<<i+1<<" : ";
    cin>>X[i];
  }
  cout<<"\nEnter frequencies for above data : \n\n";

  for(int j=0;j<n;j++)
  {
    cout<<"Frequency for "<<X[j]<<" : ";
    cin>>F[j];
  }
}


void MSqdev :: MeanSQdevi()
{
  float SXF = 0;
  float SF = 0,Sfxm=0;
  float Mean;

  for(int i=0;i<n;i++)
  {
    SF += F[i];
    XF[i] = (F[i]*X[i]);
    SXF += XF[i];
  }

  Mean= SXF/SF;

    for( i=0;i<n;i++)
  {

     XM[i]= (X[i]-Mean);
     SXM[i]=(XM[i]*XM[i]);
     FSXM[i]=(F[i]*SXM[i]);
    Sfxm+=FSXM[i];
  }

 MQDe= Sfxm/SF;

}

void MSqdev :: show()
{
  cout<<"\n\n*** YOUR DATA IS AS FOLLOWS: ***\n\n";
  cout<<"\nX \t F \t FX \t |X-A| \t (X-A)2 \t F* (X-A)2\t\n";
  cout<<"\n\n-------------------------------------------------\n";
 for(int i=0;i<n;i++)
  {
      cout<<" "<<X[i]<<"\t"<<F[i]<<"\t"<<XF[i]<<"\t"<<setprecision(3)<<XM[i]<<"\t"<<setprecision(3)<<SXM[i]<<"\t"<<setprecision(3)<<FSXM[i]<<"\n";
  }
  cout<<"\n\n---------------------------------------------------\n";
  cout<<"\n\nMEAN SQUARE DEVIATION FOR YOUR DATA = "<<setprecision(3) <<MQDe;
}

void main()
{
  MSqdev M;
  clrscr();
  M.Getdata();
  M.MeanSQdevi();
  clrscr();
  M.show();
  getch();
}

-------------------------------------------------------------------------------------------------

Out Put :



------------------------------------------------------------------------------------------------------