Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: java question confused on:

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Thanked 0 Times in 0 Posts

    Default java question confused on:

    What is the order of complexity of the following method?
    int functionExam1 (int list[], int size)
    int sum=0, product=1;
    for (int index=0; index<size; index++) {
    sum = sum +list[index];
    for (int index2=0; index2<size; index2++) {
    product = product*list[index2];
    System.out.println(sum, product);

    im thinking exponential order
    but not too sure expert help please.

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Washington, DC
    My Mood
    Thanked 632 Times in 540 Posts

    Default Re: java question confused on:

    I would suggest running this with a series of inputs. What happens when N is 10? 100? 1000? 100000? How many calculations do you perform each time? Graph those out, and it'll be pretty easy to understand what's going on.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Java newbie confused about merging files
    By shibby in forum Member Introductions
    Replies: 0
    Last Post: April 6th, 2012, 09:02 AM
  2. Newbie: seem confused with Java
    By boyscout in forum Java Theory & Questions
    Replies: 1
    Last Post: April 8th, 2011, 09:12 AM
  3. [SOLVED] Java beginner is confused....
    By truebluecougarman in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 27th, 2011, 07:50 AM
  4. Java File IO question :confused:
    By byebyebye in forum File I/O & Other I/O Streams
    Replies: 9
    Last Post: August 17th, 2010, 06:45 AM
  5. Confusion about Java development IDES
    By neo_2010 in forum The Cafe
    Replies: 4
    Last Post: July 7th, 2009, 03:14 PM