Question about arrays

Results 1 to 2 of 2

Thread: Question about arrays

  1. #1
    Join Date
    Dec 1969

    Default Question about arrays

    Does anyone know how to quickly search through a two dimesional array. I have two arrays one for categoroies and one for subcategories, both pulled from two different tables. I need to be able to show all subcategories that fit under a specific category. (if that makes sence)<BR><BR>I can use a statement, but it is slow when you are dealing with several thousand items in both, so I was just wondering if there is a quicker way to it.<BR><BR>Any help would be greatly appreciated,<BR><BR>Nick

  2. #2
    Join Date
    Dec 1969

    Default Order By...

    &nbsp;<BR>If you get the list of subcategories in category order:<BR><BR>SELECT CatID, SubCatID, SubCatName FROM SubCats ORDER BY CatID, SubCatID<BR><BR>Now you know that all the subcats for a given cat are grouped together in the array, yes?<BR><BR>So the easisest thing you could do is make one run through all the subcats and build an "index" of the starting point of each cat.<BR><BR>Then, when it comes time to find all the subcats for a given cat, you just consult the index. If you don&#039;t want to do a linear search of it, you could do a binary search or build a binary tree or or or. But I suspect that the cats list will be small enough that a linear search will be adequate.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts