How to get the missing items of arrays.

Hi I have a questions .pls , help me out on this.Suppose i have a array of items say 1....to 100. and randomly i am accessing this values , and missing one value whatever that is , so how i will get that missing values.
[240 byte] By [Dilip_biswala] at [2007-11-27 9:07:57]
# 1

Have you got any code to show us how you are going through the array "randomly" ? I would suggest that you create an array of equal size of type boolean, set them all to false, and as you read a value from the first array you set the same element in the second array to true, which leaves you with some falses.

nippysaurusa at 2007-7-12 21:45:21 > top of Java-index,Java Essentials,Java Programming...
# 2
you can get the length of the array and loop by the offset as X[n] to access all elements.
Stone.lia at 2007-7-12 21:45:21 > top of Java-index,Java Essentials,Java Programming...
# 3
If you mean random as in random, you may want to put your items into an ArrayList instead and then use Collections.shuffle(). This will arrange your items in random order, so you can traverse them lienarly and not miss any when you reach the end.
OleVVa at 2007-7-12 21:45:21 > top of Java-index,Java Essentials,Java Programming...
# 4

One question that you need to clarify is how many values do you collect?

If you pick up all randomly, you just need to sort and check the length of the random array, after that to find exactly which values are missing you just compare the random value with index x with the value from the source array at index x. If the values are equal, move to the next value.

If you pick up less than 100 values, lets say n values, you keep track of the number of times you pick up values, you will be able to see if there missing values, but you won't be able to know which ones.

Best regards

skalstera at 2007-7-12 21:45:21 > top of Java-index,Java Essentials,Java Programming...