hi,

i'm not sure if i'm on the right place too ask this question , but from some previous posts i see people are explaining their reasons for doing something through complexity.

so my question is the following:

let say i have one big table in ascii format(csv) and the 5 smaller ones. what i wish to do is search the big table with each and every small one. so when i import all those tables into sql db and make i query that takes each and every small data set and selects those data from the big table, in my understanding what i'm actually doing is :

N = 5 - number of small tables H = 100 rows -size of the small tables K = 10000 rows - size of the big table for(1..5){ # of those smaller ones for(1..100){ # number of steps i do when iterating through the smal + table for(1..10000){ # number of steps i do when iterating through big t +able //select a row } } } so \theta(NHK) is the complexity for that algorithm(?)
but if i hash all the small tables in a way:
value table ----- ----- %hash = (str1 => 1, str2 => 1, ... str100 => 1, str101 => 2, str102 => 2, ...);
my key is the value from the the small tables and its values are pointing to from which table did i take the value. so what can i do now is to while loop through the big table and for every row evaluate directly to which group does my data belongs to. example: if a hit the row that holds the str101 i now that that data belongs to the second small table.

so my question now is: is this just a faster implementation (because it runs much more faster than with db engine) or did i change the complexity to

for (1..5){ # hash tha data from smalo tables } while(1..10000){ # crosscheck with hash } so what i got is \theta(NH+K)
so the problem is how to treat hashed data.

thank you


In reply to how do hashes work - complexity question by baxy77bax

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.