Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I just need the algorithm (how you would solve the problem in words). Pseudocode

ID: 3916596 • Letter: I

Question

I just need the algorithm (how you would solve the problem in words). Pseudocode, non language specific. I pretty much did the first question, but I need help with the other two.

Thanks!

Generate 1000 random numbers from 1-100 max min avg

initialize num = 1000

algorithm

srand(time(NULL));

int arr[num], max, min, avg;

for every int i less than num,

arr[i] = rand() % 100 + 1;

end

if i is less than the next i, that is the new min

if i is more than the next i, that is the new max

for every int i less than num,

total += arr[i];

avg = total/num;

cout avg;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Generate 100 random numbers from 500 - 700, How many numbers are in the 500s? 600s?

How many numbers repeat? How many times? (show repeats and numbers of repeats). Try for 100 numbers, 10000 numbers, and 1 million numbers.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Enter 3 words (user input). How many shared letters in 2 words? 3 words? Sort the words A->Z. *Bonus: ensure that you can sort words that have the same starting letter.

Explanation / Answer

If you post more than 1 question, as per chegg guidelines I have to solve only first question.

Ques 1.

initialize num = 100

algorithm

srand(time(NULL));

int arr[num], max, min, avg;

for every int i less than num,

// generate random number in range 500-700

end

count_500 = 0;

count_600 = 0;

for i = 1 to arr.length()

    // if current number is in 500s

    if arr[i] >= 500 && arr[i] < 600

         count_500++;

    // if current number is in 600s

    else if arr[i] >= 600 && arr[i] < 700

         count_700++;

    end

end

// the key is no and the value is the number of times

// it appears

map<int , int> x;

for i = 1 to arr.length()

    // if current number is in map

    if x.contains( arr[i] )

         // increase the number of times current element

// appears in x

         x.get(arr[i]) += 1;

    // if current number is not in map

    else

         x.add( arr[i] , 1 )

    end

end

for i = 1 to x.length()

    // if current number appears more than once

    if x.get( arr[i] > 1 )

   

         print(arr[i] + “ appears ” + x.get(arr[i]) + “ times.”);

    end

end