Question



2. (30 pts) You are to choose between two procedures, both of which compute the minimum value in an array of integers. One pr
0 0
Add a comment Improve this question Transcribed image text
Answer #1

I would choose the procedure which requires a nonempty array. The first procedure returns the smallest integer even tough the array argument is empty. There cannot be a minimum element in an empty array. Therefore, this procedure works good only if the array is non empty but if the array is empty, it will return the minimum element of an empty array which is of no meaning.

on the other hand, the second procedure which requires a non empty array, will return the smallest element of the array if the array is non empty. This works fine for an empty array also because an empty array cannot have a smallest element.

Thus I would choose the procedure which requires a nonempty array.

Add a comment
Know the answer?
Add Answer to:
2. (30 pts) You are to choose between two procedures, both of which compute the minimum...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (+30) Provide a python program which will Populate an array(list) of size 25 with integers in...

    (+30) Provide a python program which will Populate an array(list) of size 25 with integers in the range -100 (negative 100)   to +100 inclusive Display the array and its length (use the len function) Display the average of all the integers in the array Display the number of even integers (how many) Display the number of odd integers (how many) Display the number of integers > 0   (how many) Display the number of integers < 0   (how many) Display the...

  • Write a C++ program that accepts one command line argument which is an integer n between 2 and 4 inclusive. Generate 60...

    Write a C++ program that accepts one command line argument which is an integer n between 2 and 4 inclusive. Generate 60 random integers between 1 and 49 inclusive and store them in a 5 by 12 two dimensional integer array (e.g.,int a[5][12];). Use pthread to create n threads to square all 60 array elements. You should divide this update task among the n threads as evenly as possible. Print the array both before and after the update separately as...

  • Need to write a MIPS assembly program that finds the minimum and maximum and sum of...

    Need to write a MIPS assembly program that finds the minimum and maximum and sum of a stored array. It also finds the locations of the minimum and maximum. The interaction between the main program and the function is solely through the stack. The function stores $ra immediately after being called and restores $ra before returning to main. The main program reserves a static C like array (index starts from 0) of 10 elements and initializes it. The maximum should...

  • Define a class DoubleStack which implements two stacks of objects of type Object using a single...

    Define a class DoubleStack which implements two stacks of objects of type Object using a single shared array, so that the push and pop operations specify which of the two stacks is involved in the operation (as described below). (a) Specify necessary instance variables and write a constructor “DoubleStack(int n)” that takes integer n and creates an empty DoubleStack object with the shared array with room for n elements (2 pt); b) Write methods "boolean push(int i, Object o)" and...

  • You are trying to choose between two accounts. Both have the same interest rate, but one...

    You are trying to choose between two accounts. Both have the same interest rate, but one is a simple interest account and the other is a compound interest account. Which of the following is FALSE? If you are investing for one period, you are indifferent between the two accounts. If you are investing for more than one period, you should choose the compound interest account. You should always choose compound interest accounts.

  • need question 3 assap using cin and cout outputs please Ctrl CSC 270 Final Exam-Spring2 1) [10 pts] Create anarray x which includes integers fron ltos obtain the array y which, even formula. Displ...

    need question 3 assap using cin and cout outputs please Ctrl CSC 270 Final Exam-Spring2 1) [10 pts] Create anarray x which includes integers fron ltos obtain the array y which, even formula. Display both arrays x and y in a table with labeled column headings. 0 y- 2x+1 2) 120 pts] Consider the following 2D array. 01 2 -1 X-3 5 0 6 -3 7 -15 Use the standard notation and obtain the following (a) Create and display array...

  • for this assignment you will be creating a series of functions for manipulating an array of...

    for this assignment you will be creating a series of functions for manipulating an array of data. The data will consist of randomly generated doubles. You should make the following functions: generate() - This function fills an array with random doubles in a specified range. This function takes four inputs: an array of doubles, an integer representing the size of the array, and two doubles representing the lower an upper bounds of the range random values. For example, the function...

  • 1. Write a complete program based on public static int lastIndexOf (int[] array, int value) {...

    1. Write a complete program based on public static int lastIndexOf (int[] array, int value) { for (int i = array.length - 1; i >= 0; i--) { if (array [i] == value) { return i; } } return -1; write a method called lastindexof that accepts an array of integers and an integer value as its parameters and returns the last index at which the value occurs in the array. the method should return -1 if the value is...

  • need the raptor flowchart with extra credit part made with procedures/ parameters. will give thumbs up...

    need the raptor flowchart with extra credit part made with procedures/ parameters. will give thumbs up Quiz Statistics For this assignment, you will write a program that requests the quiz scores for 6 students Identified by ID numbers. The program computes the average score and determines the ID number of the student with the highest score. Not an input, should be in The ID numbers for the students in this class are: 1234 2333 4432 3323 2143 3425 (program This...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT