Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Is it NP-complex ?
Hi,

I have to solve one problem, but at first I try to find appropriate
algorithm and
I think that this problem may be NP complex.
There is a some sequence of integers numebrs.
The task is to find the maximum sum but you can take only two consecutive
numbers -
so it's not allowed to take x,x+1,x+2 number where x is the position in the
sequence.
Any ideas ?

Regards



Report this thread to moderator Post Follow-up to this message
Old Post
Mateusz
10-03-04 01:56 AM


Re: Is it NP-complex ?
Hint: Nlog(N).

Walter Wilson
Symplicity Business Logic

"Mateusz" <takiegoniema@op.pl> wrote in message
news:cjn0s1$1a7$1@atlantis.news.tpi.pl...
> Hi,
>
> I have to solve one problem, but at first I try to find appropriate
> algorithm and
> I think that this problem may be NP complex.
> There is a some sequence of integers numebrs.
> The task is to find the maximum sum but you can take only two consecutive
> numbers -
> so it's not allowed to take x,x+1,x+2 number where x is the position in
the
> sequence.
> Any ideas ?
>
> Regards
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
W
10-08-04 08:57 PM


Re: Is it NP-complex ?
as long as I understand the problem correctly, it is possible to do in
O(N)-time. Even doing it for arbitrary long sequences of sums. Finding
the maximum can be done in time O(N) with a sweep-like algorithm. Doing
it in O(N) is the optimum (as is trivial to see), so we can be very happy :)

--
Matthias

W wrote:
> Hint: Nlog(N).
>
> Walter Wilson
> Symplicity Business Logic
>
> "Mateusz" <takiegoniema@op.pl> wrote in message
> news:cjn0s1$1a7$1@atlantis.news.tpi.pl...
> 
>
> the
> 

Report this thread to moderator Post Follow-up to this message
Old Post
Matthias Kretschmer
10-08-04 08:57 PM


Re: Is it NP-complex ?
After rereading the problem statement, I agree (assuming "maximum sum" means
sum of 2 numbers in the list).
Certainly not NP complete.
Walter

"Matthias Kretschmer" <mccratch@gmx.net> wrote in message
news:ck6b4m$t2g$04$1@news.t-online.com...
> as long as I understand the problem correctly, it is possible to do in
> O(N)-time. Even doing it for arbitrary long sequences of sums. Finding
> the maximum can be done in time O(N) with a sweep-like algorithm. Doing
> it in O(N) is the optimum (as is trivial to see), so we can be very happy
:)
>
> --
> Matthias
>
> W wrote: 
consecutive 



Report this thread to moderator Post Follow-up to this message
Old Post
W
10-08-04 08:57 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Prolog archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:51 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.