You're quite correct, Dhyaesh, I am just a hobby programmer. I only
took 2 courses in college programming, and neither had anything to do
specifically, with databases. They were just "touched upon".

But at work, I set up and managed two databases, for a large
corporation. My programs intereacted with data from those databases, on
a weekly basis, to detect inconsistencies, and if possible, to
automatically correct them.

I've also coded up my own "flat-file" database program. Although it is
a simple program, it still uses indicies, just not in the very
intelligent and thorough manner a good relational database program
would.

Since the OP specifically mentioned querying a database, how can you
say this problem is not a database problem?
Of course, it's a database problem!!

Some algorithm's, you will find, are quite trivial, and in fact, are
obsolete junk, including "selection sort", "bubble sort", "exchange
sort", and all their "modfied" cousins.

I showed in a previous post in this thread, how indicies can be used to
quickly give the info the OP requested.
A simple example:

As every listing of property is entered into the database, it is
"indexed", by which I mean, if that property has 2 bedrooms, then a
file (will call it _2bedrm.dat), will have that property's record I.D.
number, entered into it. Let's say the record ID number is 10, 527.

Now someone queries the database, wanting a listing of all 2 bedroom
properties. The 2bedrm file is opened, the records read (and whether
it's a file, or a linked list, doesn't matter at all). The records are
brought up into a "table array or linked list" which is just a list of
the record I.D.'s of all 2 bedroom properties. Boom! there is # 10,527,
right on the list, so a copy of that record i.d.'s data is sent to the
new 2 bedroom table that is made.

Other data in the 2 bedroom file might be:
7
220
152
1079
14438
etc.
And ALL of these properties, referenced here by their master record
I.D., will have EXACTLY 2 BEDROOMS!

There will also be a 1 bedroom file, a 3 bedroom file, etc., and they
will have all the record I.D.'s of the properties in the database,
which have 1 or 3 bedrooms, respectively.

So there is no "knapsack" problem. Just a simple search, through a
series of indexed files.

Now, if the guy/gal who set up the database, was a goof-ball, and set
the database up with indicies which cataloged the number of light
fixtures in the properties, or the number of doors, or something dumb,
THEN it becomes a knapsack problem. (and the database programmer is
fired and the problem fixed).

Before you say "Ah, that stupid Adak", just ask someone who is
knowledgeable about databases, this question. Their organizational
methods far exceed those needed for a "knapsack" problem, whether you
belive it, or not.

Why should I put up pseudo code for someone who "thinks you need to
take a course in basic algorithms".

You know little about databases, and even less about human psychology.
You should ask for pseudo code BEFORE you insult the one you're asking
a favor of. <grin, grin>

I belive we've beat this horse to death, and I'm sure the OP has
smartly moved on to more fertile fields. So am I.

Adak


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to