Face an interview with basics
Some days before came across an interview, where in I have to face the basics for Team Leader.
so my friends beware hope you will find this functions useful. Although there are short ways but still some people want to take the same long ways.
Here are the functions :
//Max element of an array
function max_array($array){
$max = $array[0];
for($i=0;$i < count($array);$i++){
if($array[$i] > $max){
$max = $array[$i];
}
}
return $max;
}
//min of an array
function min_array($array){
$min = $array[0];
for($i=0;$i < count($array);$i++){
if($array[$i] < $min){
$min = $array[$i];
}
}
return $min;
}
//sort an array using bubble sort
function array_sort($array){
for($i=0; $i < count($array); $i++){
for($j=0; $j < count($array)-1; $j++){
if($array[$j] > $array[$j+1]){
$temp = $array[$j+1];
- Kiran's blog
- 3 comments
- Read more
- 245 reads













