Help with count

  • Thread starter nrgstarinteractive
  • Start date
N

nrgstarinteractive

Hello,

I need some help programming. what I am expected to do is as follows:
I need to write a method: "int SeqCount (int[], arr, int n)
That counts sequences of the same type of length (n) in an array of
ints that form a rising or falling sequences with difference of 1
between them. for example

if n=3 then from the array : "1 2 3 6 9 9 8 3 2 1" the result will be 2
(1,2,3 and 3 2 1)
 
L

Lasse Reichstein Nielsen

I need some help programming. what I am expected to do is as follows:
I need to write a method: "int SeqCount (int[], arr, int n)
That counts sequences of the same type of length (n) in an array of
ints that form a rising or falling sequences with difference of 1
between them. for example

if n=3 then from the array : "1 2 3 6 9 9 8 3 2 1" the result will be 2
(1,2,3 and 3 2 1)

Is this homework? What have you done so far?

Should overlapping sequences count, or only distinct? (i.e., if n=2
is [1,2,3] one or two sequences?)

I believe you can do this with one sweep of the array, remembering the
length of the sequence up to the current position, the direction and
the previous number.

Good luck
/L
 
R

Rhino

Hello,

I need some help programming. what I am expected to do is as follows:
I need to write a method: "int SeqCount (int[], arr, int n)
That counts sequences of the same type of length (n) in an array of
ints that form a rising or falling sequences with difference of 1
between them. for example

if n=3 then from the array : "1 2 3 6 9 9 8 3 2 1" the result will be 2
(1,2,3 and 3 2 1)
This sounds like a homework question to me. We usually handle those at
comp.lang.java.help. However, we don't normally give people complete
solutions to homework questions there either: _if_ we see the student's own
code and it shows a genuine effort to solve the problem, we will give
_hints_ to help them get past whatever difficulties they are having. The
comp.lang.java.help newsgroup is _not_ a homework completion service where
you drop off your questions and then come back to collect complete programs
a few hours later.
 
M

Monique Y. Mudama

Hello,

I need some help programming. what I am expected to do is as
follows: I need to write a method: "int SeqCount (int[], arr, int n)
That counts sequences of the same type of length (n) in an array of
ints that form a rising or falling sequences with difference of 1
between them. for example

if n=3 then from the array : "1 2 3 6 9 9 8 3 2 1" the result will
be 2 (1,2,3 and 3 2 1)

Post whatever code you've come up with and ask a specific question
about it.
 
A

Alex Hunsley

Hello,

I need some help programming. what I am expected to do is as follows:

Yes, exactly: what _you_ are expected to do. We are not you.
We can help with specifiec problems, but at least look like you've made
an attempt to start the thing.
This ain't a homework delegation service.
 
R

Roedy Green

I need some help programming. what I am expected to do is as follows:
I need to write a method: "int SeqCount (int[], arr, int n)
That counts sequences of the same type of length (n) in an array of
ints that form a rising or falling sequences with difference of 1
between them. for example

if n=3 then from the array : "1 2 3 6 9 9 8 3 2 1" the result will be 2
(1,2,3 and 3 2 1)

try giving yourself a graded series of problems to solve. After you
have solved each one , the next will be easier.

e.g.
0. compare to umbers and decide is we are going up or down or flat.

1. find the length of the first sequence, even if it is just 1.

2. find the length of the first sequence longer than 3.

3. find the length of all the sequences and print them out.

4. count how many sequences there were altogether.

5. count how many sequences there were of each possible length.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top