asked 163k views
1 vote
there is an extremely large array a such that the first n entries are positive integers, and all remaining entries are 0. find n.

asked
User Panatoni
by
8.3k points

1 Answer

1 vote
Without more information, it is not possible to determine the value of n. However, one possible interpretation of the problem is as follows:

Let's assume that the array a is of infinite size, and that the positive integers in the first n entries are consecutive, starting from 1. That is, a[1] = 1, a[2] = 2, a[3] = 3, and so on, up to a[n] = n.

In this case, the remaining entries of the array would be O, indicating that they are all zeros. Therefore, we can find n by looking for the last positive integer in the array. Since all remaining entries are zeros, this corresponds to the last non-zero entry in the array.

Thus, we can conclude that n is equal to the index of the last non-zero entry in the array. In this case, that index is n, since all entries after a[n] are zeros.

Therefore, the value of n is n, assuming that the array a is of infinite size, and that the positive integers in the first n entries are consecutive, starting from 1.
answered
User KeithP
by
8.3k points

No related questions found

Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.