Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7439059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:39:00+00:00 2026-05-29T10:39:00+00:00

Im having a problem analyzing this method. Im trying to figure out the big

  • 0

Im having a problem analyzing this method. Im trying to figure out the big Oh complexity.
If I’m right it is O(n^2) hence the two for loops, which is the domninant joint of the algorithm. But i can’t seem to figure out how to prove it.

The thing i got this far is.

1+n*((n-1)+1)/2+n. But when i test this it cant be right, can it?

Text is in norwegian, if you have any problem with understanding the code just yell out.
(Should code in english but because our teachers is giving all the material in norwegian, they want it back in norwegian. Hence the english and norwegian text 😛 )

public void skrivUtStat(){
    LinearNode<CD> temp = start;
    int[] amt = new int[CD.GenreAmt()];
    String[] genre = CD.sendGenre();

    if(amount != 0){
        for(int i=0; i<amount; i++){
            for(int j=0; j<CD.genreAmount(); j++){
                if(temp.getElement().getGenreNr() == j){
                    ant[j] += 1;
                }
            } // End inner for-loop
            temp = temp.GetNext();                              // O(1)
        }// End outer for-loop

        for(int a=0; a<CD.GenreAmt(); a++){
            System.out.println(Genre[a] + ":");
            System.out.println(ant[a]);
        }
    }
}

Edited to english now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:39:01+00:00Added an answer on May 29, 2026 at 10:39 am

    I understand that CD.genreAmount() is O(1) and you have a fixed list of genres. Right?

    In that case you’re iterating over all of your CD’s (for i) and checking each one against your entire genre global listing (for j). So:

    Being:

    • N = CD count
    • M = Genre count

    Order will by O(N.M)

    Of course: your algorithm is iterating over you genres again (at the end of method), but that’s will be N.M + M, and of course O(M) is always lower than O(N.M)… so O(N.M+M) is equivalent to O(N.M)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problem selecting an element with an id like this <li =0f:Bactidol_Recorder.mp4>. I
Having problem with this bit of code qith jQuery. it should pick the values
I having problem to update the counter (integer value). this is the definitions of
i having problem in converting this C# code into VB.net. The loadLecturer seem to
I am having problem transforming xml to xml using xsl. I found out where
I'm having problem with global variable in PHP. I have mysqli config file which
Having problem in displaying relational properties b/w two tables having one(company) to many(package_master) relationship
I'm having problem with a copying method in a simple C++ program. Everytime I
Am having problem in using simple date format for this: having date as 12/13/2011
I having problem to print out check box according to booth and total days.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.