i am not able to understand what a monotonic boolean array means? i know that monontonic means something that neither increases or decreases.. :S
plus.. i am supposed to make a monotonic "ascending" boolean array A (A0,..., An-1)...?
how can i put zeros and ones in ascending or desecnding order?
i am given the following conditions :
∃ i : (∀ j<i : Aj = 0) ∧ (∀ k≥i : Ak = 1)
how will i initiallize the "i"
is the following what i am supposed to do:
bool A[];
for(j=??;j<i)
for(k=??;k>=i)
this is what i am supposed to further when m done aith bool A :
The split of a monotonic-ascending-boolean array is defined as the index of the first 1 (or n if there are
no 1s.)
int findSplit (int [])
Returns the split of the array
For example,
findSplit (new int[] {0, 0, 0, 1, 1, 1, 1}) yields 3.
i have understood that the findsplit function will return the index no of the array A where my first 1 occurs or if it occurs more than once..
According to the mathematical definition given above, the array is organized such that the first i elements are all false and the remaining are true.
So given an array of size S and an integer i, i <= S, run two for loops. The first loop will initialize elements 0 through i - 1 to false and the second will initialize elements i through SIZE - 1 to true.
You have a good many compile errors in the code and it isn't quite right. I suggest running the code through the compiler and fixing the compile errors, as they will point you directly to many of the problems you have.
the problem is that i don't have VB installed on this system.. so can't check.. made this on ms word.. i know there are a lot of errors in it.. i dont know how to correct them.. :s
Because I'm feeling generous today, I will write some pseudo-code for you. You translate my pseudo-code to real code and post it, and I'll work with you for a short time to get it close. But I won't compile it/test it.
// declare findSplit function here
____ findSplit( ______ ) {
// Run a for loop from index 0 through the last element in the array
// (call this variable idx)
// if the idxth element in the array is true, return the correct
// value from the function, otherwise just let the loop continue
}
int main() {
// Declare a bool array of size SIZE elements. You've already done this.
// for( indices 0 through i, inclusive ) [call this variable idx]
// set array[ idx ] to false
// for( indices i + 1 to the end of the array ) [ call this variable idx]
// set array[ idx ] to true
// call findSplit() passing in the array. findSplit returns an int, so you
// want to store the result in a variable
// print out the variable
}