4 Replies - 1016 Views - Last Post: 25 October 2015 - 01:05 PM

#1 blvckphvroh   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 22-May 14

Algorithm run time analysis

Posted 22 October 2015 - 10:54 PM

What would the big-oh run time be for this loop?

for (int k =j/2; k < n/2; k++)
Is This A Good Question/Topic? 0
  • +

Replies To: Algorithm run time analysis

#2 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: Algorithm run time analysis

Posted 22 October 2015 - 11:47 PM

Moved to Computer Science.

What have you tried? What do you think?
Was This Post Helpful? 0
  • +
  • -

#3 blvckphvroh   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 22-May 14

Re: Algorithm run time analysis

Posted 22 October 2015 - 11:53 PM

View Postmacosxnerd101, on 22 October 2015 - 11:47 PM, said:

Moved to Computer Science.

What have you tried? What do you think?



At first I was thinking it would just be O(n) but the divide by 2 threw me off and I started thinking it could be O(log n)
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: Algorithm run time analysis

Posted 23 October 2015 - 10:57 AM

Note that O(log n) is a subset of O(n). However, O(n) is the correct bound. You start at some constant less than n and go to some constant multiple of n. If j == 0, it's still O(n), right?
Was This Post Helpful? 0
  • +
  • -

#5 ishkabible   User is offline

  • spelling expret
  • member icon





Reputation: 1749
  • View blog
  • Posts: 5,901
  • Joined: 03-August 09

Re: Algorithm run time analysis

Posted 25 October 2015 - 01:05 PM

Is more context provided? What is j? How does it relate to n?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1