Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 Write a function to sort a list of numbers in place, meaning given an array of numbers as input, it sorts them in the

1

Write a function to sort a list of numbers in place, meaning given an array of numbers as input, it sorts them in the same array. After a call to this function, this list of numbers should be sorted. The function header should look like this:

static void SortList(int[] list)

Once you write the function, test it by generating an array of 10 random numbers between 0 and 99, and pass the array to the function to sort it. Then display the array of numbers again.

You are welcome to use any algorithm you wish to sort the numbers, provided that you actually implement the algorithm, and not simply call a library sort function. We recommend you use Insertion Sort as it is both easy to understand and efficient for an iterative sort. Bubble Sort is even easier to understand, though not as efficient.

2

Do the same lab as above, except this time use strings. Create an array of strings (or perhaps read words from the user), and then pass that array to a function to sort it. Note that you can use the exact same sorting algorithm as above, except for the fact that you are comparing strings instead of numbers. You can compare strings with the String.Compare() function, and the return value is one of three values, representing if the first string is either greater than, equal to, or less than the second string.

3

Create a function to calculate the volume of a sphere. First, use input validation to ask the user for the radius of a sphere using a floating-point (decimal) number, ensuring the user does not enter a negative value or non-numeric text. After the input validation, pass the radius to a function and calculate the volume of the sphere using the formula 4r3/3, returning the volume. Then display the volume. Use Google to find the value of up to 4 decimal places, or use the Math.PI constant. Dont worry if the output has too many decimal places. You can always call volume.ToString(0.00) if you want to limit the number of decimal places to two.

4

Make a program that produces a stack-overflow exception

HINT: Use recursion.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago