Big-Oh Notation,algorithm-analysis and running time - aagh headache!

Hey folks,
I was reading about the Big-Oh Notation, algorithm-analysis and running time.
Now, it's all probably very nice - if you get to understand it. Which I don't! Gives me headache! lol
And we're having an exam soon. Hmm. Could someone please help to explain it a bit better please?
Oh and by the way, one of the examples mention something about T(N), which I presume is running time for the size of a problem.
So it said:
"? Running time of a loop =
time taken by the body statement * size of the loop
? Example
for ( i = 1; i <= N; i ++)
c = c + 1;
? body statement takes O(1), the size of the loop is N
? So, this loop has running time T(N) = N * O(1) = O (N).
? More precise ?
? i = 1 takes 1 time unit
? Body statement takes 2 time units
? i <= N takes 1 time unit, i ++ takes 1 time unit
? Totally T (N) = 1 + 1 * (N +1) + 2 * N + 1 * N = 4N + 2 = O(N)
init condition body update
Nested loops
? Nested loops: Analyze them inside out
time take by body statement of innermost loop *
product of the size of all the loops
? Example:
line 1 for ( i = 1; i <= N; i ++)
line 2 for ( j = 1; j <= N; j ++)
line 3 k++;
? line 3 is the body statement in the innermost loop (for-j): takes
O(1).
? size of for-j: N
? size of for-i: N
? So the running time for this nested loops: N*N*O(1) = O(N2 )"
Please help me! I don't understand much of this.
Best Wishes!

Ok. I'll have a look about it - but the question I
had was... like...
what exactly is it that takes N steps? How do I know
what takes O(1) steps
and N steps?Depends on what you're doing. Example: adding an item to a linked list of N elements will always take the same effort: attach it to the end. Whether the list already has 0, 10 or 1000 elements doesn't matter. O(1).
If you want to try and find the maximum value in an array of numbers, you need to look at each number in there. So an array with 1 number takes one look, an array with 100 numbers needs 100 looks and an array with N members needs N looks. O(N).
Does the parametres themselves take a step each? How
many steps does the body (as far as I've understood
it, it's c = c + 1; which is the body) take? And how
long time does it take?That body takes only one step. The question is whether you want to account for the repetition or not. If you don't, it's O(1) . There is no N to take into account. If you count in the repetitions too, you end up with an N - the number of times you call the body. So the effort O to run the body once is O(1), the effort to run it N times using the loop is O(N). It really depends on what the actual action is you want to look at.

Similar Messages

  • MBP 17" Battery Capacity and Run Times : Survey

    I've had 2 MBP 17's so far, and I'd like to get a general idea from everyone about their battery capacity and run times they are experiencing.
    My first MBP17 had a Full Charge Capacity of ~5900mAh before calibration and PMU reset, and 6800mAh after. This translated to about 3:40 of run time under light load.
    My current MBP17 had a Full Charge Capacity of ~5899mAh before calibration and PMU reset, and 6942mAh after (currently). This translates to about 3:48 of runtime....still trying to get some more real-world run time numbers under different loads.
    This proves to me that it is quite critical to calibrate your battery and reset your PMU at least once to ensure that your battery is reporting it's correct capacity. I'd be interested to know what everyone else's batteries are reporting.

    I've had 2 MBP 17's so far, and I'd like to get a
    general idea from everyone about their battery
    capacity and run times they are experiencing.
    My first MBP17 had a Full Charge Capacity of ~5900mAh
    before calibration and PMU reset, and 6800mAh after.
    This translated to about 3:40 of run time under light
    load.
    My current MBP17 had a Full Charge Capacity of
    ~5899mAh before calibration and PMU reset, and
    6942mAh after (currently). This translates to about
    3:48 of runtime....still trying to get some more
    real-world run time numbers under different loads.
    This proves to me that it is quite critical to
    calibrate your battery and reset your PMU at least
    once to ensure that your battery is reporting it's
    correct capacity. I'd be interested to know what
    everyone else's batteries are reporting.
    Battery Information:
    Battery Installed: Yes
    First low level warning: No
    Full Charge Capacity (mAh): 6864
    Remaining Capacity (mAh): 6862
    Amperage (mA): -469
    Voltage (mV): 12436
    Cycle Count: 2
    William

  • Syncing design time and run time view in WPC

    Hi,
         We use WPC to develop web content. Especially when we use the table control provided in the Htmleditadvanced(advanced paragraph) component for creating web content the size of the font that is displayed in design time is very big. We do control the font size at run time by altering the font style available in the /etc/wpceditor/runtime/styles folder. But a the same time we are unable to alter the font style at designtime so that we can have the design time in sync with run time when the page is previewed. We did try exploring the css files available in /etc/wpceditor/designtime/styles folder, but was not of any use.
    Any pointers will be appreciated.

    Hi ulahoti,
    Welcome to our forum, I have downloaded your "Basic Project", I think it looks well after change
    <Border
    CornerRadius="20" Background="Black"
    Padding="8">
    <Border
    CornerRadius="20" Background="White"
    Padding="8">
    <GroupBox
    Header="Fading Mode" Background="White">
    <Grid>
    <Grid.RowDefinitions>
    <RowDefinition
    Height="*"/>
            <RowDefinition
    Height="Auto" />
    </Grid.RowDefinitions>
    to:
    <Border
    CornerRadius="20" Background="Black"
    Padding="8">
    <Border
    CornerRadius="20" Background="White"
    Padding="8">
    <GroupBox
    Header="Fading Mode" Background="White">
    <Grid>
    <Grid.RowDefinitions>
    <RowDefinition
    Height="Auto"/>
            <RowDefinition
    Height="Auto" />
    </Grid.RowDefinitions>
    If your issue persists, or I have misunderstood your concern, please let me know, and share your
    main concern
    with me, then I will do my best to resolve your issue.
    Best regards,
    Sheldon _Xiao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • SQL Trace(ST05) and Run Time Analysys(SE30)

    Hi ABAP Experts,
    Can any one explain what is the use of
    1) ST05 and
    2) SE30
    ponits will be given for clear cut explanation
    Thanks and Regards
    Vijaya

    Hi,
    The SQL Trace part of the Performance Trace tool allows you to see how the OPEN SQL statements that you use in ABAP programs are converted to standard SQL statements (see Embedded SQL) and the parameters with which the embedded SQL statements are passed to the database system.
    Overview
    From the time you turn on the trace function to the time you turn it off again, all database activity occurring either for a specific user or for an entire system is recorded. The SAP System takes OPEN SQL statements and converts them in to embedded SQL statements that it passes to the database and makes the results available. The embedded SQL statement and its parameters are recorded in the SQL Trace file. The results of the SQL statement, like return code, number of entries retrieved, inserted, or deleted by the database are recorded in the SQL Trace file as well. The log file also contains the runtime of the statement and the place in the application program, respectively transaction, from which it was called which enables additional analyses (supported by the SQL Trace function).
    From the recorded SQL trace you can deduce:
    ·        which SQL statements your application carries out
    ·        which values the system uses for specific database accesses and changes
    ·        how the system translates ABAP OPEN SQL commands (such as SELECT) into standard SQL commands
    ·        where your application positions COMMIT statements
    ·        where your application makes repeated database accesses
    ·        what database accesses or changes occur in the update section of your application
    Create a Trace (SQL Server Profiler)
    To create a trace
    On the File menu, click New Trace, and connect to an instance of SQL Server.
    The Trace Properties dialog box appears.
    Note: 
    The Trace Properties dialog box fails to appear, and the trace begins instead, if Start tracing immediately after making connection is selected. To turn off this setting, on the Tools menu, click Options, and clear the Start tracing immediately after making connection check box.
    In the Trace name box, type a name for the trace.
    In the Use the template list, select a trace template on which to base the trace, or select Blank if you do not want to use a template.
    To save the trace results, do one of the following:
    Click Save to file to capture the trace to a file. Specify a value for Set maximum file size. The default value is 5 megabytes (MB).
    Optionally, select Enable file rollover to automatically create new files when the maximum file size is reached. You can also optionally select Server processes trace data, which causes the service that is running the trace to process trace data instead of the client application. When the server processes trace data, no events are skipped even under stress conditions, but server performance may be affected.
    Click Save to table to capture the trace to a database table.
    Optionally, click Set maximum rows, and specify a value.
    Caution: 
    When you do not save the trace results to a file or table, you can view the trace while SQL Server Profiler is open. However, you lose the trace results after you stop the trace and close SQL Server Profiler. To avoid losing the trace results in this way, click Save on the File menu to save the results before you close SQL Server Profiler.
    Optionally, select the Enable trace stop time check box, and specify a stop date and time.
    To add or remove events, data columns or filters, click the Events Selection tab. For more information, see: How to: Specify Events and Data Columns for a Trace File (SQL Server Profiler)
    Click Run to start the trace.
    Runtime analysis:
    se30 is the tcode for run time analysis, is a tool it
    display report based on lps for abap pragram execution
    time , data base load, system load. these are all will
    display in micro seconds.this tool will use for Transaction
    code, function modules , abap progrmes
    In Transaction SE30, fill in the transaction name or the program name which needs to be analyzed for performance tuning.
    For our case, let this be “ZABAP_PERF_TUNING”
    After giving the required inputs to the program, execute it. After the final output list has been displayed, PRESS the “BACK” button.
    On the original SE30 screen, now click on “ANALYZE” button.
    The percentage across each of the areas ABAP/ Database/System shows the percentage of total time used for those areas and load on these areas while running the program . The lesser the database load faster the program runs.
    SQL trace:
    /people/siegfried.boes/blog/2007/09/05/the-sql-trace-st05-150-quick-and-easy
    SE30
    /people/siegfried.boes/blog/2007/11/13/the-abap-runtime-trace-se30--quick-and-easy
    regards,
    vasavi.
    kindly reward if helpful.

  • Does the definition of "Execution State" equals "Bad" change between developmen​t environmen​t and run-time?

    My basic question is:
    If the execution state of vi is "bad" under the development environment, shouldn't it also be "bad" under the run-time environment?
    So here is the background:
    So I use SVN and I ran into this problem where I would be working on one piece of code without having my top-level vi open and would inadvertantly break the top-level vi.  And being in hurry or whatever I would not open the top-level vi to check the run arrow and I would check in my code, which of course breaks the top-level vi for everyone else and causes lots of problems. 
    So to solve this I wanted to create a Tortoise SVN client side hook to check the check the top-level vi(s) to see if the run arrow was broken before I commit my changes.  I'm trying to use the Execution State to check this.  I am using an Equals primitive to compare it to a "Bad" constant. (as a side question is checking the execution state the best way to do this?  or is this even a valid way to do this?  It's the only way I've found so far to check the run arrow.).  
    So the way I'm going about this is:
    1.  I create a executable (written in LabVIEW) which is run by TSVN
    2.  When TSVN calls it  (I set it up as a start-commit hook) I pass it a parameter which is text file which lists all the top level vi(s)
    I do these first 2 steps in order to make it as generic as possible.  I can use it on any project with any number of top-level vis (or dynamically called vis) all I do is point it to a different text file.
    3.  Inside the executable I just read the list of vis, open a reference to each one and check the execution state.  I do this inside a for loop, but keep the references open and close them after the for loop in case they share some subvis or libraries, so they stay in memory (could this be the cause of some of my problems??)
    4.  Then after the for loop executes and the references are closed I simply fire off a popup if any of them are broken.
    5. Then I simply exit LabVIEW to return control to TSVN.
    So my problem is this:
    In the development environment everything works as expected.  But when I try the exact  same thing in the executable it tells me the run arrow is broken.
    Why the difference?  I'm checking the same list of vis and the runs arrows have not changed, they are still all good.
    So it appears that checking the execution state to see if it is bad behaves differently in the run-time versus the development environment.
    Can anyone confirm or deny that?
    It seems to me that it should behave the same.
    The help for the Vi.Exec.State property says that it works in the run-time (Read-only), so why am I getting different results?
    On a side question if anyone knows of an easier way to accomplish what I want to do, please let me know. I went this route because I had some experience with writing TSVN hooks and I thought it would be pretty simple and it is if I can get this comparison to behave.
    edited to fix a typo and to remove the duplicate attachment
    Attachments:
    Check Run Arrow_BD.png ‏6 KB

    I believe that plugins rely on the libraries being located in a specific location. The installer can place these libraries in the specific location or some other installer can do that. You can create code that scans the library directly to "learn" what packages/libraries are available. Then you would build the path to that VI and open the reference to it.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Having very difficult time setting up and running time capsule and airport

    I am having a very difficult time setting up and running airport express and time capsule. My time machine is not being recognized by my mac. The amber light keeps blinking. I'm ready to stsrt over.

    #3 for itunes streaming. I reset the base station and eventually was able to get the backup working and now my green light is on. Next I'd like to be able to play itunes using Airport Express and have connected to my stereo receiver in another room.
    AirPort Express Base Station (AX) - iTunes Setup
    Either connect to the AX's wireless network or connect directly, using an Ethernet cable, to the Ethernet port of the AX, and then using the AirPort Utility in "Manual Setup" mode, make the following changes:
    AirPort Utility > Select the AX > Manual Setup > AirPort > Wireless
    Wireless Mode: Join a wireless network
    Network Name: <existing TC's wireless network>
    Wireless Security: <select the encryption type of the existing wireless network>
    Wireless Password: <enter the existing wireless network password>
    Verify Password: <re-enter the existing wireless network password>
    AirPort Utility > Select the AX > Manual Setup >Music
    Enable AirTunes (checked)
    iTunes Speaker Name: <enter desired speaker name>
    iTunes Speaker Password: (optional)
    Verify Password: (optional)
    Click Update to write the new settings to the AX

  • SAP Gui 6.40 BeX Analyser problem (Run Time Error)

    Dear All
    Really need some help
    We get the following error in EXCEL 2003 when running transaction rrmx from SAP easy access:
    Run time error 91 Object variable or with block variable not set
    When debugging we get the following error message:
    call pAddin.SetConnectionFromHandle(p_connectionObj).
    We've rolled out the same package globally to all our users, some machines have this problem and some don't - which has been making this very difficult to resolve and troubleshoot.
    We've tried patch level 29 of the GUI and this did not resolve.
    I've read lots of threads relating to the .net framework and made sure all the service packs are installed, and also tried .net framework 2.0 and 3.0 - the problem still existed with both.
    I'm really stuck and appreciate any guidance.
    If we manually launch Analyzer (SAP BW 3.x) from the start menu, EXCEL and the BW add-in works fine... we only get the run time error when using transaction rrmx from SAP GUI.
    Please help!
    Thanks.

    OK, so I've done the following - which DID work and i no longer get the RUN TIME error:
    -uninstalled SAPGUI
    -uninstalled Office 2003
    -uninstalled all .net framework versions + updates.
    -install .net framework 2.0 with SP1
    -install microsoft office 2003 + SP3
    install sap gui 6.40 + patch level 29
    However, if anyone out there has got an easier and quicker solution to this problem I'd REALLY appreciate it. I have got lots of our users with this problem and it took a long time to complete all the steps above.. there must be something easier to do to fix this...
    thanks for your help

  • Tiles and run-time expressions

    I use an in-house developed library similar to Struts Tiles.
    Consider this line <put name='header' value='header.jsp'/>. At run-time it will send header.jsp to web browser. I need to select a specific .jsp using a flag like <put name='header' value='header<%= flag %>.jsp'/>, so this will send, for example, header1.jsp, header2.jsp and so on.
    Unfortunately Tiles doesn't evaluate expressions <%=.. %> at run-time, so the uri will header<%= flag %>.jsp instead of necessary header1.jsp.
    I'm looking for a solution other than using "if".
    Evgeny
    Javadesk

    I want to send a bookmark label and web page using the same specific Locale. But I see a problem in Tiles. This sends output in UTF-8 charset, and displays correct output
    <%@ page language="java" contentType="text/html; charset=UTF-8" %>
    <fmt:bundle basename="bundle">
      <put name="header" type="page"> 
        <fmt:message key="sample" />
      </put>
      <region:put section='content' content='home.jsp'/>
    </fmt:bundle>but this, when setLocale is executed in Tiles, will send output in default ISO-8859-1 encoding, and display not English characters as gibberish
    <%@ page language="java" contentType="text/html; charset=UTF-8" %>
    <fmt:setLocale value="<%= locale %>" />
    <fmt:bundle basename="bundle">
      <put name="header" type="page"> 
        <fmt:message key="sample" />
      </put>
      <region:put section='content' content='home.jsp'/>
    </fmt:bundle>I ran a number of tests and looked at the JSTL source code and found, that the problem occurs after fmt:setLocale tag internally calls the response.setLocale(locale);
    Any advice?

  • Java compile and run time questions

    Hello, I have two generic question about java compile and run:
    1. When I used javac to compile my project, it complained some classes can't be found. I added the jar file which contains these needed classes to the jre/lib/ext/ directory. The compiler no longer complains. But I'm confused. I thought the jar files in jre/lib/ext/ only used for java run time, not the compile time. Can someone help me to explain this?
    2. If I need certain user defined jar file in the classpath to compile my application, does that imply that I have to have that jar file if I want to run my project?
    Thanks in advance.

    1. lib/ext is used for generally finding classes, it doesn't matter whether you are compiling or running.
    2. Yes, you will.

  • LabView and Run-Time

    Hello, I have written a vi in LabView 7.0 and I would like to install this vi on other computers for which we do not have a license to run LabView. I understand the way around this is to download Run-Time from the National Instruments website. This I have done (downloaded and installed the latest run-time software from NI website) but I have no idea how to run my vi in the run-Time suite of programs. Which program should I use and so on. Are all sub-vis supported etc.
    Nevica
    Message Edited by nevica on 08-12-2009 09:11 AM

    You also need to check to make sure you actually have the Application Builder, depending on which "edition" of LabVIEW you have. The Professional edition had the Application Builder included. The Full and Base did not, and needed to be purchased separately. I think this still applied going back to 7.0. If you don't have the Application Builder then you will need to check with NI to see if you can still get it.

  • Question about Slow Motion and Running Times

    I am using iMovie '08 to help my boss make a video of the pump and suction cup assembly he has created. He asked me if I knew how to slow it down to a frame by frame type of shot. He also asked if there is any way to have a running time on the video both in real time and the slow motion shot. Can anyone help me?
    At work I am using a Mac Pro with 4 G of RAM and 2x2.8 GHz Quad-Core Intel processor.

    iMovie 08 was primarily designed for SIMPLE editing.
    iMovie 06 is a free download to iLife 08 owners. (THEY WANT YOU TO HAVE IT!)
    Much has been written about the differences between iMovie 06 and iMovie 08. I have found the below link to be helpful.
    http://www.geethree.com/slick/imovie8.html

  • AutosizeHeight and run-time value

    I know this has been asked many times before, but my Google-fu has failed me.
    PowerBuilder 12.5.2 classic mode, running on Win7 64 bit.
    I have an autosize height column in a datawindow, and I want to know how tall it has become after I set a value to it (to account for word/line wrapping, etc.). There is only one row in the datawindow at a time.
    I have tried dw.Describe(ColumnName + ".Height"), and I get the design-time value.
    Tried dw.Describe("Evaluate('" + ColumnName + ".Height', 1)"), get an invalid expression error.
    Used RowHeight(), but it seems to increment sporadically (every 5-12 lines).
    Even put an invisible line under the column with SlideUp, and looked at the Y1 value, but again only get the design time value.
    Help?
    -Kennon

    Aha.
    The RowHeight() expression was the trick, BUT
    I have several autosize columns stacked below the one I'm interested in. They were uninitialized (null actually), and had zero(!) height at run-time. It seems that the row autosize "reserved" enough room for the design-time height, and once a column took up all the phantom allotted space, then the row would resize. Took off autosize on the other columns, and hey presto.
    I am now a bit more bald, but good golly the dang thing works.
    Thank you both for your help.
    -Kennon

  • Context at design time and run time

    Hi,
    Can anyone tell me what is the difference between context at design time and context at run time?
    Regards
    V. Suresh Kumar

    The structure of context is usually defined at design time while context node and attributes are created at runtime based on the design. However, it is possible to modify the contents of context as well as to alter its structure at runtime too. To help understand it better, see these 2 online presentations.
    1.  [The context at design time|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f059fe81-90f2-2a10-9593-cda1645f0020].
    2. [The context at run time|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a015df6f-28f3-2a10-0291-e8e5c8aeb1bd].
    Hope it helps,
    Vishwas.

  • How i can fix "Wiki setting error" and "Running time error" ?

    I've found this message when using server app on Mountain lion.
    and this error data.
    Can i fixed this? Thanks guys!

    It so happens that I saw an answer to a similar question today somewere else. I have not tested this myself:
    "I have the final solution and fix but beware you may not like it that much.
    Having had all of the above problems with more or less everything I finally pieced it all together from various threads. This will fix both the AEBS control and the central services problems.  Dont shout at me for being a bit basic and not coding etc. but it worked for me.  If I can avoid code I do as often as possible as am less likely to balls it up!
    This method will loose some data but the main files and users do remain
    The Fix:
    1. Close Server.app
    2. Library/Server  make a copy of Server file under a diff name as software server files and a few others would appear to still be usable and you will have to re download it all again of you dont copy it back in ( I didn't and now have learned my lesson). then delete the whole of the Server file.
    3. Go to Keychain and search all Airport then delete associated keys permissions etc
    4. Delete Server.app and reinstall.
    5. Start new setup and it will migrate properly with no errors. This time a big green tick will appear!
    6. Replace the software update files into the new Library/Server folder if you want to or leave it untill the rest is done
    7 Reconfigure any missing bits..... any enrolled devices will have vanished but probably if you have  saved the data from this in Library/Server prior to deletion you may be able to reinstate this but I didnt risk it
    This is going to be a total pain if in a large organisation but once working the system is excellent with no swapping from one control set to the other.  As each service is switched on it auto configures the AEBS and no further errors and a joy to work with unless you really like to get into the nuts and bolts.
    Hope this helps and good luck"

  • External hard drive connected and running time machine backups but icon not showing up in finder

    My external hard drive has been connected for a couple of years and is using time machine perfectly. i am trying to save my iphoto library on the external drive but the icon is not displayed in finder. Only time machine icon is displayed......thanks for your help! 

    Did you create a second partition for your iPhoto Library or did you just use the same single partition that TimeMachine is on?
    Formatting & Partitioning a Hard Drive in OS X
    Apple Tips: Using Disk Utility 3. Add a Partition

Maybe you are looking for

  • Any way to export anamorphic SD QT that will play back 16:9?

    I haven't posted for a while because FCS2 has been working great. However one thing has been nagging me for quite a while and I wonder if it's a gap in my FCP education. When I work in SD 16:9 projects (either DV NTSC or DV50 Easy Setup), I often exp

  • X-fi xtrememusic. can't get mic to work

    Iv been trying to get it to work for hours. I know the mic works as i have tested it on another pc. Iv changed loads of settings many times and iv included a screenshot http://img72.imageshack.us/img72/860/soundscreenyr4.jpg)? I'm not sure if those s

  • Problem with buyer case

    hello recently i sold an item (statue) with costly shipping costs  about 70$ to usa to a client,the buyer recieved the item broken so i recent one to him with charge,(i paid the shipping cost) the second one too went bent so i asked the buyer to retu

  • Refresh table-form query on table only

    Hello, I have a group being generated as a table-form layout. What I would like is for the table page to be refreshed always on entry. I can't set the group requery condition to always, or "when entering the page" as then the view object is executed

  • Search for photos with a certain keyword ...

    Hi, I want to use the Filter-Pane to find all photos with a certain keyword on my disk - and not only in a specifiy folder. Is this possible with Bridge? Or do I always have to go into a specific subfolder and look there for the keywords? If yes, the