By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,991 Members | 1,888 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,991 IT Pros & Developers. It's quick & easy.

Conceptual and speed question

P: n/a
Hi,

My program seems to slow down drastically because as I fill my array and
table with many values, the program suffers tremendously. The first thing my
program does is to search the jagged array to try to find an element in that
array. If it does not find that element in that array, then it adds another
element and that is the problem. Once I have many elements in that array, it
takes a long time to do a search. Furthermore, not only do I add an element
to that array if it does not find it, but I also add it to my table and as
my table gets bigger, it also slows everything down drastically.

What I thought may be possible is to create many arrays instead of only 1
array and that would speed up the search. The problem is that I do not know
what the size of each array will be at the beginning as some of the arrays
might be much larger than others. Is there a way to declare arrays and then
to dynamically increase their size when needed, and if it is possible would
this hamper the performance because my arrays will be quite large. I also
thought of maybe sorting the array, but that would take too long. Is there a
way to index an array to speed up the search?

As for my table in the database, I was wandering if I created many tables
would that also help speed up the process or will it not make a difference
because it is in the same database. And if that is the case that it does not
make a difference in speed because it is in the same database, then can I
save it to a different database? Another possibility I thought of is to save
the rows to another database and delete the rows in original database after
a certain number of rows have been added.



TIA

Roy
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Roy,

Why not use ArrayLists or List<T> for the dynamic arrays? They will
allocate the space for you as needed (doubling the current capacity every
time more memory is needed).

Also, have you considered a hashtable for your lookup? It would
probably be MUCH quicker than cycling through all of the elements of the
array. You would probably have to create a custom hash code provider and
comparer (.NET 2.0 has something for this, I'm not sure if .NET 1.1 has
something, or it might be in two separate interfaces).

Personally, I'd use the hashtable/dictionary approach.

Either that, or, you could create a tree out of your jagged array, and
search through that.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Roy Gourgi" <ro***@videotron.ca> wrote in message
news:iL********************@wagner.videotron.net.. .
Hi,

My program seems to slow down drastically because as I fill my array and
table with many values, the program suffers tremendously. The first thing
my program does is to search the jagged array to try to find an element in
that array. If it does not find that element in that array, then it adds
another element and that is the problem. Once I have many elements in that
array, it takes a long time to do a search. Furthermore, not only do I add
an element to that array if it does not find it, but I also add it to my
table and as my table gets bigger, it also slows everything down
drastically.

What I thought may be possible is to create many arrays instead of only 1
array and that would speed up the search. The problem is that I do not
know what the size of each array will be at the beginning as some of the
arrays might be much larger than others. Is there a way to declare arrays
and then to dynamically increase their size when needed, and if it is
possible would this hamper the performance because my arrays will be quite
large. I also thought of maybe sorting the array, but that would take too
long. Is there a way to index an array to speed up the search?

As for my table in the database, I was wandering if I created many tables
would that also help speed up the process or will it not make a difference
because it is in the same database. And if that is the case that it does
not make a difference in speed because it is in the same database, then
can I save it to a different database? Another possibility I thought of is
to save the rows to another database and delete the rows in original
database after a certain number of rows have been added.



TIA

Roy

Nov 18 '05 #2

P: n/a
Hi Roy,

Another option : Can you sort your elements ? Searching elements in a
sorted list goes much faster. An overview :
http://en.wikipedia.org/wiki/Search_algorithm

succes,
Bart

http://www.xenopz.com/blog/bartdeboeck/

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.