code to do a brute force algorithm?

T

tony

Are there any vb source code that implements a brute force algorithm?
Any help is appreciated.
Thanks.
 
H

Howard Kaikow

Each algorithm requires different code unique to the algorithm and to the
particular method of implementing the algorithm.
 
J

Jay Freedman

Tony,

Howard has shown admirable restraint, but I suspect he hasn't made
himself completely clear. Your question simply raises another
question: "a brute force algorithm to do *what*?" There are zillions
of algorithms for searching, sorting, merging, formatting, all sorts
of tasks.

The term "algorithm" means simply "a sequence of steps". The term
"brute force" means "the slow, stupid way" as opposed to "the fast,
(maybe) smart way". Neither of these terms uniquely specifies what you
want to do.

If you're just looking for an example, try comparing the many ways of
sorting a list of items. The "bubble sort" is a classic brute force
algorithm for sorting, compared to algorithms such as "quicksort" and
"shell sort". The graph at
http://linux.wku.edu/~lamonml/algor/sort/sort.html illustrates how
much more work the brute force requires. VB code for these sorting
algorithms can be found in many places, such as
http://www.google.com/url?sa=U&start=1&q=http://www.vb-helper.com/tut1.htm&e=7370
and http://www.devx.com/vb2themax/Article/19900.

If you're looking for code for other kinds of algorithms, Google is
your friend. I found the articles I cited by searching for
"sorting algorithms" +vb
and looking at the first half-dozen of over 1900 hits.
 
H

Howard Kaikow

My restraint is due to my being on painkillers.

In addition to looking at examples of sorting code, the poster could look at
the Sort Performance Comparison Program at
http://www.standards.com/Sorting/SortPerformanceComparison-Description.html.

IMHO, there's nothing wrong with use a "brute force" algorithm the first
time around. It takes time to earn how to improve algorithms or to find
better prepublished algorithms. In many cases, algorithms published in
VB/VBA books are not so desirable.

In addition the particular coding techniques can make an enormous
difference. For example, looking to the future, using the Stringbuilder
class in VB .NET is more than 800 times faster than do the typical string
concatenation of, say, x = x +"A". One example I ran was 852 times faster.

Oh well, I'm overdue for another painkiller!
 
J

Jonathan West

Howard Kaikow said:
My restraint is due to my being on painkillers.

In addition to looking at examples of sorting code, the poster could look at
the Sort Performance Comparison Program at
http://www.standards.com/Sorting/SortPerformanceComparison-Description.html.

IMHO, there's nothing wrong with use a "brute force" algorithm the first
time around. It takes time to earn how to improve algorithms or to find
better prepublished algorithms. In many cases, algorithms published in
VB/VBA books are not so desirable.

In addition the particular coding techniques can make an enormous
difference. For example, looking to the future, using the Stringbuilder
class in VB .NET is more than 800 times faster than do the typical string
concatenation of, say, x = x +"A". One example I ran was 852 times faster.

Karl Peterson has done an equivalent of the VB.NET stringbuilder class in
VB6. It can be imported into VBA with no modification (I have used it in my
own projects). It has a performance comparable to the VB.NET stringbuilder.
Go to http://www.mvps.org/vb/samples.htm and scroll down until you get to
the StrBldr.zip sample.
 

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

Top