On Monday 05 February 2007 16:51, you wrote:
Kamaraju Kusumanchi wrote:
[snip]
2. In the worst case, your algorithm scales as O(N^2). If I am not wrong,
you can do this in O(N log(N)) steps. If your N is large (say 1000)
this has a huge benefit. The algorithm would be
One can do that
On Mon, Jan 22, 2007 at 11:36:18PM -0500, Mike Polyakov wrote:
Michael,
Why not just use a std::setint here? Repeated inserts of the same
value will be ignored.
True, but that will use extra memory. Since pointers are iterators,
this can be done on ordinary array in place without extra
Hi.
On Tue, Jan 23, 2007 at 06:01:34AM -0500, Roberto C. Sanchez wrote:
On Mon, Jan 22, 2007 at 11:36:18PM -0500, Mike Polyakov wrote:
Michael,
Why not just use a std::setint here? Repeated inserts of the same
value will be ignored.
True, but that will use extra memory. Since
On 1/22/07, Ron Johnson [EMAIL PROTECTED] wrote:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 01/22/07 08:12, Roberto C. Sanchez wrote:
On Mon, Jan 22, 2007 at 10:30:29AM +, Jon Dowland wrote:
On Sun, Jan 21, 2007 at 09:17:08PM -0500, Roberto C. Sanchez wrote:
On Sun, Jan 21, 2007 at
this is really a reply to Mike:
On Tue, Jan 23, 2007 at 06:01:34AM -0500, Roberto C. Sanchez wrote:
On Mon, Jan 22, 2007 at 11:36:18PM -0500, Mike Polyakov wrote:
Michael,
Why not just use a std::setint here? Repeated inserts of the same
value will be ignored.
True, but that will
On Tue, Jan 23, 2007 at 12:22:14PM -0700, Paul E Condon wrote:
Nicolai M. Josuttis, The C++ Standard Library, covers all this and much
more. It is expensive, but perhaps you can find a copy at a nearby
university library.
This is an awesome book. A couple of years ago, I broke down, and
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 01/23/07 13:38, Roberto C. Sanchez wrote:
On Tue, Jan 23, 2007 at 12:22:14PM -0700, Paul E Condon wrote:
[snip]
If you program in C++ at all, these three books are a must have. Even
if you don't program in C++, if you program at all Code
std::setint does _not_ waste memory.
Paul,
Yes, but I didn't say it wasted memory. I said it would use extra
memory, since the original problem was posed as finding unique values
in an array, I assume you are given an array of values up front with
which to work with. In this case, inserting
On Tue, Jan 23, 2007 at 01:58:06PM -0600, Ron Johnson wrote:
On 01/23/07 13:38, Roberto C. Sanchez wrote:
On Tue, Jan 23, 2007 at 12:22:14PM -0700, Paul E Condon wrote:
[snip]
If you program in C++ at all, these three books are a must have. Even
if you don't program in C++, if you program
On Sun, Jan 21, 2007 at 09:17:08PM -0500, Roberto C. Sanchez wrote:
On Sun, Jan 21, 2007 at 06:54:44PM -0600, Ron Johnson wrote:
This smells like CompSci homework.
g
I was thinking the same thing.
I think it's our duty to provide the most cunning/evil solution possible
then :)
--
On Mon, Jan 22, 2007 at 10:30:29AM +, Jon Dowland wrote:
On Sun, Jan 21, 2007 at 09:17:08PM -0500, Roberto C. Sanchez wrote:
On Sun, Jan 21, 2007 at 06:54:44PM -0600, Ron Johnson wrote:
This smells like CompSci homework.
g
I was thinking the same thing.
I think it's our
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 01/22/07 08:12, Roberto C. Sanchez wrote:
On Mon, Jan 22, 2007 at 10:30:29AM +, Jon Dowland wrote:
On Sun, Jan 21, 2007 at 09:17:08PM -0500, Roberto C. Sanchez wrote:
On Sun, Jan 21, 2007 at 06:54:44PM -0600, Ron Johnson wrote:
This smells
On Monday 22 January 2007 05:30, Jon Dowland wrote:
On Sun, Jan 21, 2007 at 09:17:08PM -0500, Roberto C. Sanchez wrote:
On Sun, Jan 21, 2007 at 06:54:44PM -0600, Ron Johnson wrote:
This smells like CompSci homework.
g
I was thinking the same thing.
I think it's our duty to provide
On Mon, Jan 22, 2007 at 11:36:11AM -0500, Kamaraju Kusumanchi wrote:
Hey guys
Lighten up! Give him the benefit of doubt and help him if you can. May be
the OP belongs to some other field and is trying to get a sense of algorithm
implementation for a related problem.
Except that:
*
On Mon, Jan 22, 2007 at 10:30:29AM +, Jon Dowland wrote:
I think it's our duty to provide the most cunning/evil
solution possible then :)
Probably not all that evil or cunning by most people's
standards, but here's my solution. I tried to do a
continuation-passing-style tail recursive
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 01/22/07 11:22, Jon Dowland wrote:
On Mon, Jan 22, 2007 at 10:30:29AM +, Jon Dowland wrote:
[snip]
/* populate the unique list */
for(i = 1; i argc; ++i) {
int val = atoi(argv[i]);
if(!in_list(val, list)) {
В Вск, 21/01/2007 в 19:13 -0500, Kamaraju Kusumanchi пишет:
2. In the worst case, your algorithm scales as O(N^2). If I am not wrong, you
can do this in O(N log(N)) steps. If your N is large (say 1000) this has a
huge benefit. The algorithm would be
a. use a quicksort technique to sort
On Mon, Jan 22, 2007 at 11:42:32AM -0600, Ron Johnson wrote:
On 01/22/07 11:22, Jon Dowland wrote:
On Mon, Jan 22, 2007 at 10:30:29AM +, Jon Dowland wrote:
[snip]
/* populate the unique list */
for(i = 1; i argc; ++i) {
int val = atoi(argv[i]);
No you're quite right, not least since my insertion routine
traverses the whole list on each call. I didn't write this
for speed of execution, merely speed of writing it :)
For speed of writing, here's the whole thing in C++ using STL:
#include vector
#include algorithm
#include iostream
On 1/22/07, Mike Polyakov [EMAIL PROTECTED] wrote:
For speed of writing, here's the whole thing in C++ using STL:
#include vector
#include algorithm
#include iostream
#include cstdlib
#include ctime
using namespace std;
int main()
{
srand(time(NULL));
vectorint array;
Michael,
Why not just use a std::setint here? Repeated inserts of the same
value will be ignored.
True, but that will use extra memory. Since pointers are iterators,
this can be done on ordinary array in place without extra memory. Only
thing is that unique() function modifies the original
Good evening to all,...
i wrote a small algorythm (in C ) to find how many uniqe value are in an
array ..
then change the size of the array to store all the unique values ..
code you please look at the code and make changes to it (to)
/*
This program Should find the true length of an array
On Sunday 21 January 2007 18:18, Jabka atu wrote:
Good evening to all,...
i wrote a small algorythm (in C ) to find how many uniqe value are in an
array ..
then change the size of the array to store all the unique values ..
Couple of comments:
1. Your code is working fine for me. Though the
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 01/21/07 17:18, Jabka atu wrote:
Good evening to all,...
i wrote a small algorythm (in C ) to find how many uniqe value are in an
array ..
then change the size of the array to store all the unique values ..
code you please look at the code
On Sun, Jan 21, 2007 at 06:54:44PM -0600, Ron Johnson wrote:
On 01/21/07 17:18, Jabka atu wrote:
Good evening to all,...
i wrote a small algorythm (in C ) to find how many uniqe value are in an
array ..
then change the size of the array to store all the unique values ..
code you
25 matches
Mail list logo