The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 2 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
A: A program sorts an arrayÂ’s elements into descending order. The array contains 5 elements. How many steps would sorting take (at most)?
B: Write a program that rolls a FOUR-sided die 20 times and stores results in int a[20].
C: What does the following program print? Why?
public class Program
{
public static void main (String [] args)
{
final int arraySize =5;
int a[] = { 1, 2, 3, 4, 5 };
int result = whatIsThis(a, arraySize);
System.out.printf(Result is : %d.\n, result);
}
public static int whatIsThis(int b[], int size)
{
if ( size == 1 )
return b[ 0 ];
else
return 2 * (b[ size - 1 ] )+ whatIsThis(b, size - 1 );
}
}
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll