array

hey!

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..

help??!!

how do i go about "i"
and the the for loops :s
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.

thank you ever so much for your help..

i shall get on this monotonic case and end it for good.. :p

int main( )

{

int i;
Const SIZE = S;
bool A [SIZE];

for ( i = 0; i < = S; i++)

i-1 = false;

for ( i = 0; i > = S; i++)

SIZE-1 = true;

cout << findslpit( A [SIZE]) << endl;


} //end main

int findslpit ( new int [SIZE] )

{
Count = 0;

While ( SIZE != true);

Count ++ ;
else

{

Cout << count << endl ;

} //end else

} // end while







so, how far will i be going with this code? :S im still confused though...
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
i meant VS.. visual studio.net
It's kinda hard to write entire programs from scratch and have them compile and work the first time.

How do you intend to run your program once written if you don't have compiler?
i know..

it is extremely irritating to not to be able compile my program..

but i don't really have a choice.. the submission for coding this statement is due today.. :(

BUT,thank-you so much for helping me understand and how to go about it with the loops...

i'll submit it like this.. better to get something than nothing..

Can you just download and install VS 2008 Express (free) from Microsoft's website on the machine, or is it a school computer?
its a school computer.. :(
Ok.

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

// 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
}
Now be very careful with Word's auto caps feature. C++ keywords are all lowercase only.

waaaaooow!!

thank-u-ever-so much!!

Not to rush you, but I don't have too long...
im really sorry... i wouldn't wanna bother you with this any further...

i think i'd be able to take it from here...

please do ur usual...i'd feel bad to keep u waiting.. u've been more than help already..

thank-you sooo much.
Topic archived. No new replies allowed.