• karthikeyan (6/8/2009)


    They used some concepts which i couldn't understand.

    1) O(n) means ?

    2) O(n^2) means ?

    3) O(n log n) means ?

    4) What is mean naive linear string concatenation?

    For (1-3), see the Wikipedia articles that Gail referenced. Big-O notation is simple once you understand it, but a little confusing to explain so I'm deferring to the experts.

    For (4), "naive linear string concatenation" is just the normal way of concatentating many strings together by appending each one onto the end of an accumulated output string:

    --NOTE: This is an example. I dont really use While loops in SQL.

    Declare @i As int

    Declare @a As varchar(MAX)

    Select @i = 1, @a = ''

    WHILE @i = Len(A$) + Len(B$), then copy all of A$ inot it, then copy B$ in after A$ and then re-point A$ to the new buff (and deallocate the old). Besides all of the memory allocation overhead, this is an O(n) operation where n = Len(A$)+Len(B$).

    However, if A$ just happens to have an unused portion of memory after it whose size is >= Len(B$) then, instead you can just copy B$ into that unused memory after A$ and extend A$'s length value to inlcude the appended characters.

    2) Can you explain about the formula you used?

    Which formula? I use a lot of them.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]