Author Topic: Runtime Analysis.... kind of.  (Read 7845 times)

0 Members and 1 Guest are viewing this topic.

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Runtime Analysis.... kind of.
« on: March 05, 2009, 11:01:32 am »
Why in the world are you using a spin lock here?  I sure hope lock contention is low or the critical section is trivial.
I would guess it's for school.  (I had much worse assignments in my operating systems class).
Yeah, same. It's to learn how the stuff works, not how to use things properly. It's the same as the old "implement a bubble sort" thing.

Bubble sort is hardcore, but it's not quite as badass as stooge sort.  It has O(n^( log(3) / log(1.5) )), which is O(2.709...) running time! :D

MyndFyre edit: changed the title
« Last Edit: March 06, 2009, 11:41:30 am by MyndFyre »

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Semaphores using pthreads
« Reply #1 on: March 05, 2009, 11:56:24 am »
Why in the world are you using a spin lock here?  I sure hope lock contention is low or the critical section is trivial.
I would guess it's for school.  (I had much worse assignments in my operating systems class).
Yeah, same. It's to learn how the stuff works, not how to use things properly. It's the same as the old "implement a bubble sort" thing.

Bubble sort is hardcore, but it's not quite as badass as stooge sort.  It has O(n^( log(3) / log(1.5) )), which is O(2.709...) running time! :D

Nothing beats garbage sort. I don't know what the order is, but the algorithm is:

garbage_sort(list)
{
  while(!is_sorted(list))
  {
    shuffle(list)
  }
}

(My friend's algorithm, not mine :) )

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Semaphores using pthreads
« Reply #2 on: March 05, 2009, 05:35:41 pm »
Why in the world are you using a spin lock here?  I sure hope lock contention is low or the critical section is trivial.
I would guess it's for school.  (I had much worse assignments in my operating systems class).
Yeah, same. It's to learn how the stuff works, not how to use things properly. It's the same as the old "implement a bubble sort" thing.

Bubble sort is hardcore, but it's not quite as badass as stooge sort.  It has O(n^( log(3) / log(1.5) )), which is O(2.709...) running time! :D

Nothing beats garbage sort. I don't know what the order is, but the algorithm is:

garbage_sort(list)
{
  while(!is_sorted(list))
  {
    shuffle(list)
  }
}

(My friend's algorithm, not mine :) )

Haha, yeah.  Well, the search space is O(n^n) (n^n is \Theta(n!)).  Since it's stochastic, there really isn't an order.  You could analyze the expected run time, but there is no "worst" case.  For any proposed finite worst case (i.e., n^n iterations), you could still do worse if you're unlucky.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Semaphores using pthreads
« Reply #3 on: March 05, 2009, 05:51:31 pm »
Why in the world are you using a spin lock here?  I sure hope lock contention is low or the critical section is trivial.
I would guess it's for school.  (I had much worse assignments in my operating systems class).
Yeah, same. It's to learn how the stuff works, not how to use things properly. It's the same as the old "implement a bubble sort" thing.

Bubble sort is hardcore, but it's not quite as badass as stooge sort.  It has O(n^( log(3) / log(1.5) )), which is O(2.709...) running time! :D

Nothing beats garbage sort. I don't know what the order is, but the algorithm is:

garbage_sort(list)
{
  while(!is_sorted(list))
  {
    shuffle(list)
  }
}

(My friend's algorithm, not mine :) )

Haha, yeah.  Well, the search space is O(n^n) (n^n is \Theta(n!)).  Since it's stochastic, there really isn't an order.  You could analyze the expected run time, but there is no "worst" case.  For any proposed finite worst case (i.e., n^n iterations), you could still do worse if you're unlucky.
So it's O(∞). Good game, try finding a worse algorithm! :)

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Semaphores using pthreads
« Reply #4 on: March 05, 2009, 06:49:03 pm »
Why in the world are you using a spin lock here?  I sure hope lock contention is low or the critical section is trivial.
I would guess it's for school.  (I had much worse assignments in my operating systems class).
Yeah, same. It's to learn how the stuff works, not how to use things properly. It's the same as the old "implement a bubble sort" thing.

Bubble sort is hardcore, but it's not quite as badass as stooge sort.  It has O(n^( log(3) / log(1.5) )), which is O(2.709...) running time! :D

Nothing beats garbage sort. I don't know what the order is, but the algorithm is:

garbage_sort(list)
{
  while(!is_sorted(list))
  {
    shuffle(list)
  }
}

(My friend's algorithm, not mine :) )

Haha, yeah.  Well, the search space is O(n^n) (n^n is \Theta(n!)).  Since it's stochastic, there really isn't an order.  You could analyze the expected run time, but there is no "worst" case.  For any proposed finite worst case (i.e., n^n iterations), you could still do worse if you're unlucky.
So it's O(∞). Good game, try finding a worse algorithm! :)

All algorithms are O(∞). :)

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Semaphores using pthreads
« Reply #5 on: March 05, 2009, 06:53:58 pm »
Why in the world are you using a spin lock here?  I sure hope lock contention is low or the critical section is trivial.
I would guess it's for school.  (I had much worse assignments in my operating systems class).
Yeah, same. It's to learn how the stuff works, not how to use things properly. It's the same as the old "implement a bubble sort" thing.

Bubble sort is hardcore, but it's not quite as badass as stooge sort.  It has O(n^( log(3) / log(1.5) )), which is O(2.709...) running time! :D

Nothing beats garbage sort. I don't know what the order is, but the algorithm is:

garbage_sort(list)
{
  while(!is_sorted(list))
  {
    shuffle(list)
  }
}

(My friend's algorithm, not mine :) )

Haha, yeah.  Well, the search space is O(n^n) (n^n is \Theta(n!)).  Since it's stochastic, there really isn't an order.  You could analyze the expected run time, but there is no "worst" case.  For any proposed finite worst case (i.e., n^n iterations), you could still do worse if you're unlucky.
So it's O(∞). Good game, try finding a worse algorithm! :)

All algorithms are O(∞). :)
Well, it's O(∞) for any value n > 1. :)

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Semaphores using pthreads
« Reply #6 on: March 05, 2009, 07:00:43 pm »
All algorithms, regardless of input size, are O(∞).

The following is O(∞).
function :
  return 2;

Big-O denotes an upper bound.  It's often assumed that it's the "best" upper bound, and most text/literature uses it in this way, but it isn't something that's given to you automatically by using big-O.  If f(x) is O(g(x)), we know that f(x) is bounded above by g(x), but we don't know that it's bounded above.  If f(x) is Theta(g(x)), then it's bounded both above and below by g(x).  Big-O is used in place of big-Theta often because it's harder to prove a big-Omega (bounded below by) bound, and it isn't particularly useful for most things.
« Last Edit: March 05, 2009, 07:02:16 pm by Sidoh »

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Semaphores using pthreads
« Reply #7 on: March 05, 2009, 07:43:40 pm »
Fine, then my algorithm has the worst case of ∞ for any input > 1. :P

(I haven't used big O or theta or omega since second year comp sci :P)

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Semaphores using pthreads
« Reply #8 on: March 05, 2009, 08:04:14 pm »
Fine, then my algorithm has the worst case of ∞ for any input > 1. :P

(I haven't used big O or theta or omega since second year comp sci :P)

That wording seems a little iffy.  Maybe it's acceptable, but I'd probably be a weeny and say it doesn't have a worst case.

heh, algorithms is one of things I've decided to study in more depth.  Asymptotic analysis is pretty important if you intend to do research that involves producing new stuff.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Semaphores using pthreads
« Reply #9 on: March 05, 2009, 08:15:11 pm »
Asymptotic analysis is pretty important if you intend to do research that involves producing new stuff.
Fortunately, I don't produce new stuff, I just break old stuff. :D

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Runtime Analysis.... kind of.
« Reply #10 on: March 06, 2009, 12:05:27 pm »
Thanks for splitting it off.

Also, your new avatar looks too much like Ender's, I keep getting mixed up :)

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Runtime Analysis.... kind of.
« Reply #11 on: March 06, 2009, 12:35:17 pm »
Thanks for splitting it off.

Also, your new avatar looks too much like Ender's, I keep getting mixed up :)


Uhhh.....


I can't say I see the similarity.   :o
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Blaze

  • x86
  • Hero Member
  • *****
  • Posts: 7136
  • Canadian
    • View Profile
    • Maide
Re: Runtime Analysis.... kind of.
« Reply #12 on: March 06, 2009, 12:42:08 pm »
Thanks for splitting it off.

Also, your new avatar looks too much like Ender's, I keep getting mixed up :)


Uhhh.....


I can't say I see the similarity.   :o

Try:

And like a fool I believed myself, and thought I was somebody else...

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Runtime Analysis.... kind of.
« Reply #13 on: March 06, 2009, 12:52:06 pm »
Thanks for splitting it off.

Also, your new avatar looks too much like Ender's, I keep getting mixed up :)


Uhhh.....


I can't say I see the similarity.   :o

Try:


I don't see that avatar.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Runtime Analysis.... kind of.
« Reply #14 on: March 06, 2009, 01:14:58 pm »
See no evil? :O

Does this one look better, iago?


Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Runtime Analysis.... kind of.
« Reply #15 on: March 06, 2009, 02:42:56 pm »
Yeah, I was talking to Sidoh. :)

Sidoh -- I can't tell, you'd have to use it. I suspect so, though, the main issue for me is the coloured picture on a white background, from the corner of the eye it looks the same.

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Runtime Analysis.... kind of.
« Reply #16 on: March 06, 2009, 07:06:47 pm »
Yeah, I was talking to Sidoh. :)

OH.  I split it off.  That's why I thought you were talking to me.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Runtime Analysis.... kind of.
« Reply #17 on: March 06, 2009, 07:48:22 pm »
Yeah, I was talking to Sidoh. :)

OH.  I split it off.  That's why I thought you were talking to me.

Well, I assumed Sidoh did. I didn't actually check. :P

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Runtime Analysis.... kind of.
« Reply #18 on: March 07, 2009, 03:57:50 am »
Yeah, I was talking to Sidoh. :)

OH.  I split it off.  That's why I thought you were talking to me.

Well, I assumed Sidoh did. I didn't actually check. :P

I even said it in the first post!  It says "MyndFyre edit: split" or something! :P
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Runtime Analysis.... kind of.
« Reply #19 on: March 07, 2009, 10:43:43 am »
Yeah, I was talking to Sidoh. :)

OH.  I split it off.  That's why I thought you were talking to me.

Well, I assumed Sidoh did. I didn't actually check. :P

I even said it in the first post!  It says "MyndFyre edit: split" or something! :P
Why would I read a post I'd already read? :P