SAM
BAN USER
public static boolean detectcycle(int array[]){
int startindex= 0;
int count=1;
for(int i=1;i<=array.length/2;i++){
//detect cycle
if(array[i]==array[startindex]){
//store lastIndex or one cycle
int lastIndex=i-1;
//System.out.println(lastIndex);
while(startindex<=lastIndex&&i<array.length){
if(array[i]==array[startindex]){
i++;
startindex++;
}
else {
System.out.println("no cycle found");
return false;
}
}
System.out.println("cycle length is : "+count);
}
else{
count++;
}
}
return true;
}
if(row%2!=0&&col%2!=0){// if odd number of element
int midRow= row/2;
int midCol=col/2;
System.out.println("median is : "+matrix[midRow][midCol]);
}
else //if even number of elements
{
int midrow1=0,midrow2=0,midcol1=0,midcol2=0;
if(row%2==0){
midrow1=row/2;
midrow2=midrow1-1;
}
if(row%2!=0){
midrow1=row/2;
midrow2=midrow1;
}
if(col%2==0){
midcol1=col/2;
midcol2=midcol1-1;
}
if(col%2!=0){
midcol1=col/2;
midcol2=midcol1;
}
int median = matrix[midrow1][midcol1]+matrix[midrow2][midcol2];
System.out.println("median is elseloop :"+median/2);
}
A bad application is one which does not take proper care of :
- SAM February 12, 20141)memmory usage,
2)allocation and deallocation of resourse,
3)and where a non UI thread tries to access a UI toolkit.
also for example if we are desging a android based application and we try to call a "implicit intent" without checking getPackageManager().