Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 O(n) , O(n log n), O(n^2) Rate Topic Display Mode Topic Options
Author
 Message
 Posted Tuesday, June 09, 2009 4:31 AM
 SSCrazy Group: General Forum Members Last Login: Friday, November 08, 2013 7:56 AM Points: 2,013, Visits: 2,495
 Gail,i expected this question from you. Since i studied these concepts just to pass the exams, beacuse that time i don't know the real time usage and it will be used in our programming skill, I forgot the concepts.Once i got the job, then only i realized that all i studied will be applied in the work...anyway hereafter i never forgot this chapters.:)..Thanks for teaching me....Thank you Gail :) karthik
Post #731302
 Posted Tuesday, June 09, 2009 4:38 AM
 Ten Centuries Group: General Forum Members Last Login: Wednesday, November 06, 2013 5:15 AM Points: 1,238, Visits: 1,366
 Hi I'm sure Barry & Gail will give full answers, but this interpretation may help.Don't think of O(n) / O(n^2) as proper mathematical formulas that can be solved. Think of them as a convenient shorthand description for a problem type.So O(n) describes a linear problem - as n increases, the solution increases proportionally to n as in a straight line graphO(n^2) is essentially a quadratic problem - as n increases, the solution increases proportionally to n-squared - or some function of n-squared.O(log n) means the solution increase proportional to log nI may be totally wrong or this could be too simplistic, but thats what I understood from the Wiki article and various other researching.
Post #731305
 Posted Tuesday, June 09, 2009 7:12 AM
 SSC-Insane Group: General Forum Members Last Login: Yesterday @ 7:48 PM Points: 22,095, Visits: 29,028
 karthikeyan (6/9/2009)Gail,i expected this question from you. Since i studied these concepts just to pass the exams, beacuse that time i don't know the real time usage and it will be used in our programming skill, I forgot the concepts.Once i got the job, then only i realized that all i studied will be applied in the work...anyway hereafter i never forgot this chapters.:)..Thanks for teaching me....Thank you Gail :)I have an idea, how about actually answering Gail's questions about where and when you went to school for your MCA and BS degrees instead of just this fluff.
Post #731410
 Posted Tuesday, June 09, 2009 7:27 AM
 SSC-Forever Group: General Forum Members Last Login: Today @ 1:11 AM Points: 40,117, Visits: 32,848
 Tom Brown (6/9/2009)I may be totally wrong or this could be too simplistic, but thats what I understood from the Wiki article and various other researching. That's pretty much the core of it, yes. There's a whole tonne of theory as to analysing algorithms to work out their complexity but I don't recall any of the details of that any more. It's way over most people's heads anyway and more for maths/CS researchers. Gail ShawMicrosoft Certified Master: SQL Server 2008, MVPSQL In The Wild: Discussions on DB performance with occasional diversions into recoverabilityWe walk in the dark places no others will enterWe stand on the bridge and no one may pass
Post #731428
 Posted Tuesday, June 09, 2009 10:50 AM
 SSCrazy Eights Group: General Forum Members Last Login: 2 days ago @ 9:34 AM Points: 9,874, Visits: 9,433
Post #731657
 Posted Tuesday, June 09, 2009 11:02 AM
 SSCrazy Eights Group: General Forum Members Last Login: 2 days ago @ 9:34 AM Points: 9,874, Visits: 9,433
Post #731679
 Posted Tuesday, June 09, 2009 11:12 AM
 SSCrazy Eights Group: General Forum Members Last Login: 2 days ago @ 9:34 AM Points: 9,874, Visits: 9,433
 So we should avoid pseudo cursor. Right? I never said anything like this.1) It will be treated as internal cursor. i.e it will perform looping internally.AFAIK all set processing in SQL Server uses internal cursors. And as long as CPU-cores execute single streams of instructions, all servers, programs and OS's will have to loop internally.But comparing to external cursor, it will be very fasy. Right?Yes.2) is it a good habit to use pseudo cursor in sql programming? if not, what is the workaround for this?It is a technique. It is not the most desirable technique, but neither is it entirely undesirable. And sometimes it is the best technique available for a problem. -- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoungProactive Performance Solutions, Inc. "Performance is our middle name."
Post #731693
 Posted Tuesday, June 09, 2009 1:27 PM
 SSCrazy Group: General Forum Members Last Login: Friday, November 08, 2013 7:56 AM Points: 2,013, Visits: 2,495
 Declare @str varchar(5)select @str = ''select @str = @str + no from mystringstep 1: '' + '1'step 2: '1' + '2'step 3: '12' + '3'step 4: '123' + '4'step 5: '1234' + '5'so if i apply ((N^2) + N)/2 formulaN = 5...5^2 = 5*5 = 2525+5 = 30/2 = 15. Right?O(n) operation where n = Len(A\$)+Len(B\$).so '1' + '2' is an O(n) operation.O(n^2) problem is1) Time to concatenate the string2) Space claimed by the variables3) Resource taken to do the above two operation karthik
Post #731817
 Posted Tuesday, June 09, 2009 1:52 PM
 SSCoach Group: General Forum Members Last Login: Friday, November 01, 2013 1:55 PM Points: 15,442, Visits: 9,579
 Karthik, '1'+'2' is still O(n^2). What's 1 squared? - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETCProperty of The Thread"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Post #731832
 Posted Tuesday, June 09, 2009 1:54 PM
 SSCrazy Group: General Forum Members Last Login: Friday, November 08, 2013 7:56 AM Points: 2,013, Visits: 2,495
 RBarryYoung (6/8/2009)karthikeyan (6/8/2009)[quote]4) What LHS (Left-hand side) function denotes exactly?Left-hand Functions appear left of the assignment operator ("="):` Set @str = UPPER('Some text.')`These are normal functions, and AFAIK, in T-SQL, all functions are LHS.3) What RHS (right-hand side) function denotes exactly?Right-hand Side functions appear on the right-hand side and they usually do "special" things having to do with addressing the output property or variable. AFAIK, T-SQL does not have any, but in some languages, STUFF is a RHS:` STUFF(@str, offset, len) = 'foo'`This example would overwrite the output string (@str) with the input string starting at 'offset' for 'len' characters. The difference between this and th LHS STUFF() function in T-SQL is that the RHS version does not return anything, it actually does write over the characters of the @str variable.3) The "pre-allocate and Stuff" trick popular with mutable strings is not workable in T-SQL because the STUFF() function in T_SQL is NOT like the function of the same name in some general purpose languages: the T-SQL STUFF() is an RHS (right-hand side) function and NOT an LHS (left-hand side) function. AFAIK, there is no function in SQL that can (physically) write into a pre-existing string.RBarryyoung,The above two points are confusing me...you mean to say TSQL STUFF() function can't write into a pre-existing string. karthik
Post #731834

 Permissions