answersLogoWhite

0


Best Answer

1. Determine the sum of 1..n = (n(n+1))/2 2. Subtract all the elements in the given array (n-1 elements) from the expected sum. 3. The missing number is the value remaining. /* Implementation in "C" */

int MissingNumber(int values[], int n)

{

int total = (n * (n+1))/2;

while (n>1)

{

total -= values[n-2];

n--;

}

return total;

}

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: The integers from 1 to n are stored in an array in random fashion. One of the numbers is missing. What is an example of a program that will find the missing number?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How are integers and national numbers the same?

There are no national numbers. Some integers are natural numbers but not all - for example, negative integers.


What is an example of subtraction of integers?

Integers are whole numbers as for example 28 minus 17 = 11


Are all real numbers integers?

No, all integers are real numbers, but not all real numbers are integers. For example, 1.25 is a real number and a non-integer.No.


How can you classify different numbers?

Obviously, there are an infinite number of ways you can classify numbers.For example, you can classify positive and negative numbers; integers and non-integers; rational and irratinoal numbers; real numbers and complex numbers.Obviously, there are an infinite number of ways you can classify numbers.For example, you can classify positive and negative numbers; integers and non-integers; rational and irratinoal numbers; real numbers and complex numbers.Obviously, there are an infinite number of ways you can classify numbers.For example, you can classify positive and negative numbers; integers and non-integers; rational and irratinoal numbers; real numbers and complex numbers.Obviously, there are an infinite number of ways you can classify numbers.For example, you can classify positive and negative numbers; integers and non-integers; rational and irratinoal numbers; real numbers and complex numbers.


Are some integers not rational numbers?

All integers are rational numbers. There are integers with an i behind them that are imaginary numbers. They are not real numbers but they are rational. The square root of 2 is irrational. It is real but irrational.


What is the missing numbers in this pattern 65 56 38?

All of the integers from 64 down to 57, and from 55 down to 39, are missing.


Whole numbers and their opposites are called what?

Whole numbers are called integers. There are positive integers, for example, 3, and its opposite, a negative integer, -3.


What are the numbers 2 5 8 11 an example of?

Integers.


What are some example of real numbers in addition?

Since integers are also real numbers, 2 + 3 = 5 is an example.


Is the complement of the set of odd integers is the set of even integers?

It is if we only consider integers. If we consider all real numbers, for example, it would not be.


When are rational numbers not natural?

Most of the time. For example, when they are negative integers.


Can non-integers be negative numbers?

Yes. Example: -403.27 you bet!