Two problems with algorithms

Hi, i can't figure algorithm for these two problems can you help me? :

1. Write a program that reads a number - n and a sequence of n numbers and finds the longest are of adjacent equal elements. Example :

n = 14

sequence = { 7, 3, 3, 3, 7, 7, 7, 7, 3, 3, 2, 3, 7, 2}

result = {7, 7, 7, 7}

2. Write a program that reads from the console a sequence of numbers and finds the the longest subsequence of growing numbers. Example:

sequence = {3,1,2, 4, 6, 2,3, 5,4,5}

result = {1, 2, 3, 4, 5}

I'll be very thankful if you write me an algorithm :) (I was thinking for recursion but I couldn't figure it out.. I'm still a newbie :) )

[725 byte] By [n3m0a] at [2007-11-27 1:21:27]
# 1

> I'll be very thankful if you write me an algorithm

Hahahaha, in your dreams.

However, I'll get you started:

public class Homework {

public static void main(String[] args) {

// ... insert your code here

}

}

rkippena at 2007-7-11 23:59:16 > top of Java-index,Other Topics,Algorithms...
# 2

well thanks but I already figured out where was my mistake.. 'cuz hum I'm a little bit smarter than you :) and I help when others are at dead-end ...oh or maybe you don't know what to do and you think you're very good at this and now you're wondering "How I couldn't decide this simple problem?!!!! Oh I know why I couldn't because I'm stupid and swollen" :) Have a nice day my friend andwhen you want to ask about java after a couple of months ('cause I'm learning it from a couple of days) call me I'll be glad to help you bye :)

Message was edited by:

n3m0

n3m0a at 2007-7-11 23:59:16 > top of Java-index,Other Topics,Algorithms...
# 3

problem #1

a single character is a sequence of length 1

the next character either increased that sequence to being a sequence of two, or it broke the sequence and is thus the start of a new sequence.

Every time you break a sequence you can check and see if the sequence you had (just before you broke it) was the best one you have ever seen.

problem #2 hummm.... That's a hard one. Or is it? Look at the solution to problem 1 again.

marlin314a at 2007-7-11 23:59:16 > top of Java-index,Other Topics,Algorithms...
# 4

> well thanks but I already figured out where was my

> mistake.. 'cuz hum I'm a little bit smarter than you

> :) and I help when others are at dead-end ...oh or

> maybe you don't know what to do and you think you're

> very good at this and now you're wondering "How I

> couldn't decide this simple problem?!!!! Oh I know

> why I couldn't because I'm stupid and swollen" :)

> Have a nice day my friend andwhen you want to ask

> about java after a couple of months ('cause I'm

> learning it from a couple of days) call me I'll be

> glad to help you bye :)

>

> Message was edited by:

> n3m0

Too funny. I'm sad I missed the unedited version.

rkippena at 2007-7-11 23:59:16 > top of Java-index,Other Topics,Algorithms...
# 5

> well thanks but I already figured out where was my

> mistake..

Well, how did you do it? Or do you think sabre150 will really make your homework as he said he would in your cross posted thread?

> 'cuz hum I'm a little bit smarter than you :)

I highly doubt that.

> and I help when others are at dead-end ...oh or

> maybe you don't know what to do and you think you're

> very good at this and now you're wondering "How I

> couldn't decide this simple problem?!!!! Oh I know

> why I couldn't because I'm stupid and swollen" :)

> Have a nice day my friend andwhen you want to ask

> about java after a couple of months ('cause I'm

> learning it from a couple of days) call me I'll be

> glad to help you bye :)

Well, help me by posting (pseudo) code of your algorithms please.

prometheuzza at 2007-7-11 23:59:16 > top of Java-index,Other Topics,Algorithms...