Worse case analysis?

k = 0
for i = 1 to n do
    for j = n down to i do
        k = k + 1
        if j < 8 then
            k = k + jI am practicing analyzing worse case for algorithms and run across this interesting algorithm (at least interesting to me). What is the runtime of the above algorithm? I think it's N^2 but I am not so sure - looks kind of tricky. What is the value of k after the algorithm finishes? Instead of giving the answer, I would appreciate it very much if you could show me the process along with explanation in analyzing the above algorithm. Thanks guys/gals.

k = 0
for i = 1 to n do
for j = n down to i do
k = k + 1
if j < 8 then
k = k + jI am practicing analyzing worse case for algorithms
and run across this interesting algorithm (at least
interesting to me). What is the runtime of the above
algorithm? I think it's N^2 but I am not so sure -
looks kind of tricky. What is the value of k after
the algorithm finishes? Instead of giving the
answer, I would appreciate it very much if you could
show me the process along with explanation in
analyzing the above algorithm. Thanks guys/gals.Okay, to begin with, the first clue is that almost every time you have two nested
for loops, it usually O(n^2). But I'll show you a bit of logic for this one.
Consider the inner loop:
for j = n down to ialthough i does change every time through the outer loop, you can still say the following: The complexity is still linear. The larger n gets, the more often you have to pass through the loop.
The only way for this inner loop to be, say, constant, is for a condition i - n = k to always hold true for a given constant k. But since i changes each time through the outer loop, while n stays constant, this is clearly not the case. So the complexity of this loop is linear, or O(n).
Now the outer loop is easier to evaluate:
for i = 1 to n Yeah, now this is the most straight forward for loop you can get. This loop always has a complexity of O(n).
Then the total complexity is O(n) * O(n) = O(n^2).
Here's another easy way to think about it. I'm going to visually mark a "*" for each time the code in the inner loop is executed. It will look something like this:
Now, that's a triangle, right? The base is n, and the hight is n + 1. And the area of the triangle is (n * (n + 1))/2 = (n^2 + n) / 2.
Thus, the big oh of this formula is O(n^2), which is the complexity of your program.
Hope that helps clear things up for you.
- Adam

Similar Messages

  • Does worst case analysis work with model parameters?

    The worst case analysis does not seem tow work with model parameters. I performed a worst case analysis on a simple one transistor amplifier stage. It gives correct answers for resistor tolerances, but for the transistor model parameters it never changes them. I did the same with a diode in the circuit and entered tolerances for the diode parameters and it never used the tolerances.

    That's the same message I get. See attached circuit.
    Attachments:
    FETamp.ms10 ‏96 KB

  • Data analysis question

    1.Is it compulsory to use all the events in Reports?
    2.What transactions do you use for data analysis?
    3.What are selection texts?
    4.When a program is created and need to be transported to prodn does selection texts always go with it? If not how do you make sure? Can you change the CTS entries? How do you do it?
    5.What are different tools to report data in SAP? What all have you used?
    6.What are Change header and detail tables? Have you used them?
    7.Is it possible to run host command from SAP environment? How do you run?
    8.What kind of financial periods exist in SAP? What is the relevant table for that?
    9.What is a currency factoring technique?
    10.How do you document ABAP programs? Do you use program documentation menu option?
    11.wha s output determination?
    12. what is the field length of Packed Number? What is the default decimal of packed number?

    Yes I have the 2004 MS Office for Mac installed. However, I cannot confirm that the add in has been loaded when using Excel.
    The procedure that I am using:
    1. With MS Excel open, I go into the "Tools" tab and select "Add-ins"
    2. The "Add-ins" sub-box opens and I check the desired utilities, in this case Analysis Toolbox and I hit the "Select" button.
    3. Next another sub-box opens entitled, "Choose an Add-in". With the MS Office CD in I scroll oven until I locate the sub-folder "Analysis Tools" which opens up four additional options: Analysis ToolPak, Analysis ToolPak - VBA, FuncRes, and ProcDBRes. I select Analysis ToolPak and then "Open".
    4. I receive a pop up message, "Copy Analysis ToolPak to the Add-ins folder?" I select "yes" .
    5. Thinking that the process has been completed, I go back to the MS Excel worksheet, select "Tools" tab and Data Analysis is not there.

  • BO XI R2 and SQL server 2005 Analysis services

    Post Author: fasttrack
    CA Forum: Olap
    Hello,
    I am new in BO, I am using XI R2 and I would like to know this:
    I have to build some reports on Data Warehouse using SQL server 2005 Analysis Services.
    My question is:
    1) How I have to build this reports: directly to data warehouse or building an OLAP (CUBE) in analysis services 2005?
    2) BO XI R2 supports SQL server 2005 and especially in this case Analysis services 2005 and provider (I have seen only provider for SQL Server 2000)?
    Do you some good resources where to learn how to make reports on DW SQL server 2005?
    Thank

    Post Author: ShaunOberem
    CA Forum: Olap
    Hello,
    I am new in BO, I am using XI R2 and I would like to know this:
    I have to build some reports on Data Warehouse using SQL server 2005 Analysis Services.
    My question is:
    1) How I have to build this reports: directly to data warehouse or building an OLAP (CUBE) in analysis services 2005?
    2) BO XI R2 supports SQL server 2005 and especially in this case Analysis services 2005 and provider (I have seen only provider for SQL Server 2000)?
    Do you some good resources where to learn how to make reports on DW SQL server 2005?
    Thank
    Hi,
    If you are trying to create a new OLAP Intelligence Report using SQL 05 I am afraid you are out of luck.
    You will need to get a copy of the Productivity Pack (Available for Download in Subscribenet) .
    Also, in your SQL Server Sufrace Configuraiton manager try setting Analysis Services to Allow Ananomous connections. This will make sure you get a little further initially. (Dont leave Anonymous on)

  • Howmany use cases

    This is an excerpt from "UML Distilled" by Martin Fowler & Kendall scott(pageno.47)
    "How many use cases should you have?During a recent OOPSLA panel discussion, several use case experts said that for a 10-person-year project, they would expect around a dozen use cases. These are base use cases; each use case would have many scenarios and many variant use cases. I've also seen projects of similar size with more than a hundred seperate use cases.(If you count the variant use cases for a dozen use cases , the number end up about the same.)As ever, use what works for you."
    EXCERpT END
    So far my understanding of variant use case is that a variant use case represents a functionality that is reapeating across many use cases. The above excerpt does not seem to fit with this understanding.
    During the initial phases of project, if high level use case representation has to be conveyed to a domain expert , making use cases which include a great deal of similar requirements is a good idea as the whole system can be represented in a very simple manner.
    For example , a use case like "manage accounts" can be further subdivided in to open , deposit, withdraw, close account in later stages of development. But the issue is could these be called as use case variants. And how these are to correlated to the original use case "manage accounts"?.
    thanking you,
    sprasad

    Be careful with RUP - it's very documentation centric, and I have yet to see a case where all of the required documentation is useful to the successful development of the project.
    The hierarchial decomposition of a problem domain is best illustrated through dual mechanisms - both the Use Case diagrams, and actual Use Case documentation. The diagrams can be developed in a hierarchial fashion (i.e. a single use case on a high level diagram decomposes into several more detailed use cases on a separate diagram).
    Where you stop the decomposition is really part of the art of use case analysis, and will be impacted by the methodology that your team practices. The teams that I work with practice various "Agile" methodologies (XP, Scrum, Crystal, DSDM, etc.), so what I look for in a "detailed" use case is 1) can a developer build the needed functionality within a single development iteration? and 2) What other functional areas (if any) are similar enough to encourage the development of more generic functionality to address multiple requirements. My guess is that this is equivalent to the "variant" use cases mentioned above (bear in mind I haven't read the book).
    So it really depends on how your project team works. If you are practicing a "heavy" methodology like RUP or Waterfall, where all of the analysis is done up front, it is important to define all of the use cases in advance. This doesn't change the issue of how to establish the functional requirements hierarchy, but it does change when you will put in the effort to identify this hierarchy.
    If, on the other hand, you are practicing an Agile methodology you will still need to identify the hierarchy, but you do it in stages. For instance, at the beginning of a project I will identify the major functional needs (i.e. an accounting system needs AR, AP, journals, GL, etc), but then I will concentrate on the detailed analysis of only one aspect of the application. From there the team will design and build it. Then we move on to the next aspect of the application. At the end you still have a detailed analysis of the application (hierarchial use case information), but you can much more readily adapt to changing business requirements, and you tend to produce a lot less meaningless documentation.

  • MS Excel Data Analysis toolpak question

    Attempted to add data analysis toolpak to MS Excel using MS Office 2004 for Mac.
    However, when I attempt to load/add the program, a folder is added containing Data Analysis is listed but "Data Analysis" does not show up in my MS Excel "Tools" tab.
    Probably an easy fix. Any assistance is appreciated - thanks.

    Yes I have the 2004 MS Office for Mac installed. However, I cannot confirm that the add in has been loaded when using Excel.
    The procedure that I am using:
    1. With MS Excel open, I go into the "Tools" tab and select "Add-ins"
    2. The "Add-ins" sub-box opens and I check the desired utilities, in this case Analysis Toolbox and I hit the "Select" button.
    3. Next another sub-box opens entitled, "Choose an Add-in". With the MS Office CD in I scroll oven until I locate the sub-folder "Analysis Tools" which opens up four additional options: Analysis ToolPak, Analysis ToolPak - VBA, FuncRes, and ProcDBRes. I select Analysis ToolPak and then "Open".
    4. I receive a pop up message, "Copy Analysis ToolPak to the Add-ins folder?" I select "yes" .
    5. Thinking that the process has been completed, I go back to the MS Excel worksheet, select "Tools" tab and Data Analysis is not there.

  • Making 3d graphs

    Hi!!!.... i m just a practicing programmer of LabVIEW, learning it for the completion of a my final year technical project of my bachelors degree. Can anyone please tell me how to use a 3D graph in LabVIEW. I want to use it to plot points for Principal Component Analysis and Linear Discriminant Analysis on the graph. I am not able to do that currently. A sample programme would be wonderful, if someone can attach that as well. Would be highly grateful!!

    Please see reply #7 of this thread to find a worse case example of how to use the 3d graph.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Invalid confidential channel(FWB 00032)

    Hi,
    We are having an issue with BOBJ analysis while giving the credentials it shows an error like "invalid confidential channel" intermittently.
    However we are using the correct password and user-id even though some users are effecting while login into BOBJ,even I faced the same.
    Could you please let me know why issue occurring intermittently.
    Appreciated for quick response.

    1887273 is a different problem due to the APS only so it only occurs when refreshing BICS reports, the security channel is just 1 of many possible errors/symptoms. The fix in there will only affect the APS not BI Launchpad and CMC. The invalid confidential channel in the 3 KBA's I mentioned is a session problem that seems to only occur if there is a clustered CMS (but it may also occur in single CMS servers). It also can be fixed usually by restarting tomcat, or restarting tomcat and deleting the work directory, or worse case redeploying tomcat. To me that issue (the one in question) is being caused by tomcat and I'm not sure if the ADAPTs raised will actually resolve. The fact that ADAPTs were raised on both 4.0 and 4.1 with fixes seems to indicate something is still missing. 
    Regards,
    Tim

  • Suggestion for a new OCA / OCE exam

    I have noticed that there are a lot of candidates who learn for an exam. There seems to be a lot of incentive to studying for the exam and "learning" the material.
    However, there are also a lot of candidates who do not understand the 'certification', 'learning', 'followup' processes. It also seems that if there is no reward, such as a certificate, skills and processes are overlooked or misunderstood.
    I suggest an OCA (or perhaps an OCE) level exam that tests the candidate for "How to find information on Education.oracle.com, Certification.oracle.com, Certview.oracle.com, Tahiti.oracle.com, OTN.oracle.com"; "What happens after you write the exam and how long do I have to wait"; "Why I should have only one testing ID"; "What is a FAQ"; "Ability to use internet search engines and how to formulate questions"; "Why do forum administrators bother with Forum Stickies", and the like.
    While somewhat tongue-in-cheek (or at least cheeky), I encourage thinking about this. We are churning out people who supposedly are professionals, and yet some have no idea what that 'professional' icon means or where to find out more information about it.

    Well not an OCA or an OCE certificate but perhaps an OCS, and that could be useful for partners as well. The problem is if offered online it would be abused.
    I get concerned when a candidate newly registered for OTN has just passed the high stakes exam for an OCA wonders where their certificate is. It is a concern they don't seem to have researched the certification process much. The lack of familiarity with the certification process seems slightly concerning ... and there is probably a lack of familiarity with the Oracle websites as well, which is not what one would expect from a certified person.
    The new OTN registration isn't a definite indicator of a problem here, but it is a strong indicator there may be something unsatisfactory.
    Indeed the absolute worse case is an SQL exam online by proxy taker followed by braindump use or a proxy take of the high stakes exams.
    In practice I would suspect that an unbalanced delivery of the WDP training or third party training or university training may be a culprit. (and I may be wrong here). (Note there seems to be an increasing tendency for some universities to focus on education by certification study ... ).
    I really think it would be useful if a candidate was required to register with Oracle (by means of an SSO/OTN account) before being able to book a certification examination rather than being simply able to goto Pearson VUE/Prometric (This is the case with a lot of other Testing programmes, and was the case with Sun until recently). IMHO This would encourage a good 'first contact' with Oracle and would encourage the following benefits:
    - A relationship with Oracle would be established sooner during the exam preparation process.
    - There would be an opportunity to point the candidate at useful processes, authorized learning methods and resources via email.
    - An earlier point in the learning process to discourage bad learning technique
    - The sales people would love the opportunity to sell oracle training.
    I think there is an argument for requiring OTN registration at least a month before a certification exam can be booked ... exceptions being if an Oracle University Course has been attended. However the logistics would probably fail on this and it could hurt people who have just left an employment.
    Edited by: bigdelboy on 07-Apr-2010 00:57 PS: - Hans - You also didnt great job with one of the sticky announcements. I really think however now that Prometric / Pearson Transition has happened and merge with Sun is stable all the sticky posts should be reviewed and rolled into one entitled something eyecatching like only silly people should not read this FAQ first

  • I've tried to install osx 10.6.8 and my computer freezes with some weird computer lingo during the reboot.

    this is what happened when i installed the 10.6.8 update last week (twice!!)  Thankfully, I had a time machine back-up, but how can I upgrade to Lion if this update doesn't work?
    My iMac
    Model Name:          iMac
      Model Identifier:          iMac7,1
      Processor Name:          Intel Core 2 Duo
      Processor Speed:          2.4 GHz
      Number Of Processors:          1
      Total Number Of Cores:          2
      L2 Cache:          4 MB
      Memory:          6 GB
      Bus Speed:          800 MHz
      Boot ROM Version:          IM71.007A.B03
      SMC Version (system):          1.20f4
      Serial Number (system):          xxxxx
      Hardware UUID:          00000000-0000-1000-8000-001B639A26E9
    < Edited by Host >

    That's a kernel panic.
    Help for Resolving Kernel Panics
    Apple - OS X Lion - Sign up to be notified when Lion is available.
    Worse case scenario, erase the startup disk and reinstall the Mac OS X.

  • Select query in materialized view with two dblinks

    Hi All,
    We have oracle 10g On windows.
    We are trying to create materialized view. Scenario is we have base table on other database and we are creating mview on different database.
    Basa database have two schema's and i am selecting records from that two schema's using two private db links.
    But when i am tryin gto create mview its not getting created. After 15 hrs. its still showing creation command and not finished.
    Query is :-
    Is it good practice to have two db links in select query of materialized view.

    Billy  Verreynne  wrote:
    Chanchal Wankhade wrote:
    Is it good practice to have two db links in select query of materialized view.Same db link being used twice, or two different db links?
    If the former, you ideally want the local Oracle db to send the join to the remote database, and for the remote database to drive the join between those 2 tables. There is a hint (<i>driving_site</i>) that can be used - or the join query can be defined on the remote database as a view, and the local materialised view can then use that remote view.
    If you have 2 different db links and joining across these - usually a bad idea to perform distributed database joins. There are lots of limitations as to how the tables can be joined. Worse case, full table scans of both remote tables, pulling all the rows from the 2 remote database tables to the local database, and joining these on the local database.
    I have seen some severe performance issues in the past as a result of distributed joins. I'll rather use 2 materialised views for pulling both distributed tables's data locally, and then do the join on local data (using indexes, partition pruning, etc)Hi Billy,
    My scenario is i have two database database A and database B. Database A is having two schema's SCOTT AND HR. SCOTT schema have select privileges on HR schema.
    DB LINK is between Database B to Database A. name is db.link.B.A.oracle.com.
    What if i priovide while creating materialized view, the schema name before the table name in database B for this particuler table so it will pick up the table from that schema using same DB LINK(db.link.B.A.oracle.com.) that i am using to fetch records from SCOTT schema.
    Above schnario is like two base schema's and one db link using two schema.

  • Creating a Fusion Drive ?

    Hi All,
    I have a mid-2011 iMac which I plan to install a Samsung 840 Pro SSD to use as part of a Fusion Drive setup.
    Typically I backup using Carbon Copy and wil be taking a backup prior to the mod.
    Once the drive has been configured......   will I need to reinstall the OSX from scratch, or is it just a matter of bringing back the Backup ??
    Pete

    When you use CoreStorage to format the SSD and mechanical HD it will be a destructive format/paritioning so the new Fusion disk will look like one HD but in fact will be two under the hood.   You should be able to use CC to restore your image as it will look like a single drive. 
    I'm not sure if that model iMac has a Fusion tool supplied by Apple or not.  I think you have to use one of the many guides found online to manually configure the drives to be a single Fusion drive using diskutil at the command line.  If I remember correctly, you'll need to boot with a thumb drive with 10.8.3 installation on it.  Then go to the Terminal to configure the Fusion drive setup.  Then you would have to find some way to run CC from a bootable thumbdrive, etc.  I think you could boot the backup disk made with CC then run CC from it to clone to the new Fusion drive.  That should work.  Worse case scenario, you always could just re-install OS X on the Fusion drive and then use the Apple Migration Assistant to grab your data from the CC'd drive. 
    Either way, give yourself at least half a day in the event you run into issues and have to work around things.

  • I believe that a smaller-than-normal CD disk is jammed in my iMac disk slot. It does not show up on my desktop, so I cannot do a normal eject. Any thoughts on how to force an eject? Thanks.

    Jammed CD drive on iMac

    Good idea about looking on YouTube for information on how to assault the internals of an iMac.
    Fortunately, I won't need to do so. Got the disk out using a kludge. I turned off the machine, inserted a slender metal ruler into the disk slot and powered up. As hoped, the ruler triggered the regurgitate-the-disk function of the drive and the (full size) disk slid out.
    Why take such a chance? Because the drive was useless with a jammed disk in it, and I figured there was a reasonable chance that my kludge would work. Probable worse case was that it would not and I'd be no worse off. There was the possibility I'd ruin the drive, but that did not seem probable, and it did not happen. I'm using it right now for a program installation.
    If I did ruin the drive, I'd just continue using my $39 USB plug-in drive, as I had been doing while trying to figure out how to solve the problem. If I ever upgrade to a new iMac, I will have to use this or similar drive in any case, since the new iMac's come sans an internal superdrive. (I dislike that Apple decided to do away with the drive, but they didn't ask me.)
    Anyhow, thanks for the response, and happy computing.

  • Disable new text vibrate when unlocked?

    I would like to disable vibrate when I'm currently in a texting session. It seems silly to be notified of a new text while I am in the texting conversation and looking at the screen. I would still like to be notified of a new text when the phone is locked, however.
    Is this possible?
    JP

    There is no deficiency.
    The phone vibrates unnecessarily, over and over again in the middle of text conversation
    It vibrates to let you know you have received a text message.
    This is clear evidence of poor use case analysis and deficiency in design
    It's clear evidence that you don't know what you are on about or how to use simple consumer electronic devices.
    Suggestions here -> http://www.apple.com/feedback/

  • Delete Dialogue not appearing... can't delete songs from hard-drive

    After downloading ver 7.0.2 I can't delete songs from my hard-drive by deleting them in iTunes.
    There's supposed to be a dialogue(sp?) box that shows up when you delete a song in the main library (not in playlists), that asks you if you want to permanantly delete a file (song, movie, etc), or if you only want to delete it from the iTunes list.
    It's not showing up for me, so I have to seek out the folder and delete the song manually in Windows.
    I'd get this problem occasionaly in the older versions, but usually a restart of the program, or in worse cases, rebooting the computer would solve the problem, but not this time.
    I've tried re-installing the program, but no luck.
    Any ideas?
    Thanks.

    I tried the following fix, and it didn't work..
    Is anyone else having this problem after upgrading to 7.0.2?
    I'm sure I didn't check the box in the delete dialog that says "do not show this again"
    I've also tried hitting the shift key when deleting.. still no luck.
    HELP!!
    Resetting the iTunes Preference Files:
    -- Quit iTunes
    -- Delete C:\Documents and Settings\<your username>\Application Data\Apple Computer\iTunes\iTunes.pref
    -- Delete C:\Documents and Settings\<your username>\Local Settings\Application Data\Apple Computer Inc\iTunes.pref
    You may need to enable 'Show Hidden Files/Folders' in Windows Explorer==>Tools menu==>Folder Options==>’View’ tab before you can see the Application Data & Local Settings folders.
    This will force iTunes to run the setup assistance the next time you open it. You'll have to go back and re-set any preferences you want changed from the iTunes default. When you restart iTunes, it will perform its initial startup process. Do not let iTunes search for your music files. The old library is still there and iTunes will see it after it gets past the initial dialog screens.

Maybe you are looking for

  • What's the general consensus regarding Generics in Java?

    Just curious what folks think about how it's implemented in Java and whether you're in favor of it or not (not that it will make any difference). I haven't been using it yet because I am still working on 1.4.x, but I've been familiarizing myself as b

  • SD  and MM FLOW with example

    Hi friends, Can any one tell me the SD and MM Flow with respect to company and customer like what the company and customer will do in various stages?

  • Cost center and Org unit relationship.

    Hi Guys, I need quick help from any one of you. Actually our org stucture is like Root-> company->plants-> costcenters( deparments)- users. so we create org unit in the structure with some 100001 and assign users for that cost center  org unit , so b

  • Reg: Basics of business package implementation

    Hi, Can someone provide me some documentation for basics on business package implemantation. and i have a question, once the business package is installed on the portal, the respective roles and the iviews will appear in the specialist folder? or we

  • DB Adapter Polling Parameters Issues

    Hi All, We have a DB Adapter which polls on a table at every 60 seconds.we set database rows for transaction to 1 in the wizard. but when 10 records inserted into the table,DB adapter is picking up all rows at a time. this is not the expected functio