answersLogoWhite

0

var largest : integer

largest = array[0]

for n : integer in array

if n > largest

largest = n

endif

endfor

return largest

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Why do you have a monitor and what are the uses?

A monitor is the "gateway" to your computer. It is the output of your computer. E.g. a mathematical formula has an input, an output and an algorithm. The keyboard & mouse is the input, the computer is the algorithm, and the monitor is the output.


Is input and output always equal?

No, input and output are not always equal. The output is the result of processing the input data based on a specific operation or algorithm. Depending on the operation or algorithm, the output may differ from the input.


What are the functions of algorithm?

A function is any relationship between inputs and outputs in which each input leads to exactly one output. It is possible for a function to have more than one input that yields the same output.


What is distribution sort?

Any sort algorithm where data is distributed from its input to multiple intermediate structures which are then gathered and placed on the output.


Which cache algorithm will optimize a storage arrays Input and Output response time if sequential access is detected?

Read Ahead


How do you write a program to print the first n multiples of 7?

Algorithm: multiples input: two positive integers, m and n output: print first n multiples of m i = m; for j = 1 to n print i i = i + m; next j


What is the input and output of kalman filter?

The Kalman filter is an algorithm to eliminate noise from statistical observations. The inputs and outputs are dependent on what you are applying it to.


How do you explain characteristics of algorithm?

Characteristics of algorithms are: Finiteness: terminates after a finite number of steps Definiteness: rigorously and unambiguously specified Input: valid inputs are clearly specified Output: can be proved to produce the correct output given a valid input Effectiveness: steps are sufficiently simple and basic.


How can you demonstrate the correctness of an algorithm?

One way to demonstrate the correctness of an algorithm is through a process called proof of correctness. This involves providing a formal mathematical proof that the algorithm will always produce the correct output for any given input. This can be done by showing that the algorithm satisfies certain properties or invariants at each step of its execution. Additionally, testing the algorithm with a variety of input cases can also help to validate its correctness.


Is an OMR an input or output?

is an omr and input or output device?


Is interactive whiteboard an input or output device?

both input r output


What a C function that will compute the K in largest and K in smallest element along with their positions in an array of N signed integers. Assume the following 5 N 50 and 1K?

To compute the largest value in an array, assume that the first element is the largest and store the value. Then traverse the remainder of the array. Each time a larger value is encountered, update the stored value. Once all values are traversed, return the stored value. In pseudocode, this algorithm would be implemented as follows: Algorithm: largest Input: array A of length N Output: largest value in A let largest = A[0] // store first value for index = 1 to N-1 // traverse remaining elements if A[index] > largest then largest = A[index] // update stored value if current value is larger next index return largest To determine the position of the largest value, we alter the algorithm as follows: Algorithm: largest_by_index Input: array A of length N Output: index of the largest value in A let largest = 0; // store index 0 for index = 1 to N-1 // traverse remaining elements if A[index] > A[largest] then largest = index // update stored index next index return largest We can do the same to find the position of the smallest element: Algorithm: smallest_by_index Input: array A of length N Output: index of the smallest value in A let smallest = 0; // store index 0 for index = 1 to N-1 // traverse remaining elements if A[index] < A[smallest] then smallest = index // update stored index next index return smallest To perform both algorithms simultaneously, we need to return two values. To achieve this we can use a simple data structure known as a pair: struct pair { int smallest; int largest; }; Algorithm: range_by_index Input: array A of length N Output: a pair indicating the position of the smallest and largest values in A pair result = {0, 0} // initialise the pair for index = 1 to N-1 // traverse remaining elements if A[index] < A[result.smallest] then result.smallest = index // update stored index else if A[index] > A[result.largest] then result.largest = index // update stored index next index return result