[algogeeks] Re: Testing if 3 points form a triangle

2007-05-29 Thread BiGYaN

Just test whether they are collinear or not  i.e. get the slopes,

m1 from 1st and 2nd point
m2 from 2nd and 3rd point

if m1==m2 then they do not form a triangle
else they do

Computing the area of the triangle and testing for 0 might also
work  but I feel that the computation will be bigger 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---



[algogeeks] Re: help me with finding the time complexcity

2007-05-29 Thread BiGYaN

On May 28, 6:21 pm, sl7fat [EMAIL PROTECTED] wrote:
 hi i have an algorthim code and i have to find the time complixcity of
 the code so can you plz help me ASAP the code is written done ,,
 # include iostream.h

 void main()
 {

 int a[10][4]=
 {{ 16,17,19,13},
 {18,14,15,19},
 {18,20,20,19},
 {13,14,15,10},
 {20,17,19,19},
 {18,13,18,19},
 {18,10,15,12},
 {12,14,15,11},
 {12,16,17,18},
 {18,11,15,10}} ;

 int i,j,max,min;
 float avg,sum;

 for(i=0;i10;i++)
 {

 for(j=0;j4;j++)
 {

 cout  a[i][j] ;
 }
 cout  \n;
 }

 for(i=0;i4;i++)
 {
 max= a[0][i];
 min= a[0][i];
 sum=0;

 for(j=1;j10;j++)
 {

 sum= sum+a[j][i];
 if(a[j][i]max)
 max=a[j][i];

 if(a[j][i]min)
 min=a[j][i];
 }

 avg= sum/10;

 cout  The average Grade for Exam i+1  is:   
 avg\n;
 cout   The minimum Grade for Exam i+1  is:   
 min\n;
 cout  The maximum Grade for Exam i+1  is:   
 max\n\n;

 }

 for(i=0;i10;i++)
 {
 min= a[i][0];
 sum=0;
 for(j=0;j4;j++)
 {
 sum= sum+a[i][j];
 if ( mina[i][j])
 min= a[i][j];

 }
 sum= sum-min;

 cout   The summation of the best 3 grades for student No 
  i
 +1  is:   sum\n;
 }

 }

 thanx alot :D

O(n^2)  there is no variable here  so what exactly were u
asking?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~--~~~~--~~--~--~---