Programming Thread

Started by the-pi-guy, Mar 13, 2016, 10:39 PM

previous topic - next topic

0 Members and 1 Guest are viewing this topic.

Go Down

darkknightkryta

Increasing cache memory can actually decrease performance if using a FIFO algorithm.  

It never hurts performance in least frequent or least recent algorithms.

But for FIFO, there are work loads where having a smaller cache gives better results.  
What are you?  An Engineer?  Call it a queue like a normal computer scientist!

the-pi-guy

What are you?  An Engineer?  Call it a queue like a normal computer scientist!
I see FIFO all the time in CS books.
My OS book calls a lot of things FIFO.  

A queue is a "FIFO data structure" is usually how they call it.

darkknightkryta

I see FIFO all the time in CS books.
My OS book calls a lot of things FIFO.  

A queue is a "FIFO data structure" is usually how they call it.
Those CS books were made by engineers.

On another note, when I had an interview with Capcom and I said "I'd store the files with a stack" he was like "No, have you heard of Filo?"  I wanted to slap him since he didn't know they were the same thing.

the-pi-guy

Those CS books were made by engineers.
No. ::P
First in, first out is the official name for the algorithm in the context of scheduling.

darkknightkryta

Nov 09, 2017, 09:19 PM Last Edit: Nov 09, 2017, 09:21 PM by darkknightkryta
No. ::P
First in, first out is the official name for the algorithm in the context of scheduling.

That's scheduling, not compsci



Anyways, I have to write lessons for all the sorting algorithms in textbooks.  I'm arbitrarily starting with quicksort.  Does it "have" to be recursive?  I can't find a non-recursive algorithm and I'd rather not write one.

the-pi-guy

That's scheduling, not compsci



Anyways, I have to write lessons for all the sorting algorithms in textbooks.  I'm arbitrarily starting with quicksort.  Does it "have" to be recursive?  I can't find a non-recursive algorithm and I'd rather not write one.
No. Nonrecursive
Optimized QuickSort -- C Implementation (Non-Recursive)



Usually it's possible to change an implementation from recursive to iterative.  

darkknightkryta

No. Nonrecursive
Optimized QuickSort -- C Implementation (Non-Recursive)



Usually it's possible to change an implementation from recursive to iterative.  

It is, I just didn't want to write one from scratch.

the-pi-guy

Hmmm this code isn't getting the right answer. Let's track what's going on with a print statement.  

What.. now I got the right answer.  
*Runs it a few more times*.
Okay, half the time I get the right answer of 94, the other half I get 109.

This makes no sense.

Legend

Hmmm this code isn't getting the right answer. Let's track what's going on with a print statement.  

What.. now I got the right answer.  
*Runs it a few more times*.
Okay, half the time I get the right answer of 94, the other half I get 109.

This makes no sense.
Is it somehow not starting with a clean slate before each test?

the-pi-guy

Nov 11, 2017, 11:58 PM Last Edit: Nov 12, 2017, 12:26 AM by the-pi-guy
Is it somehow not starting with a clean slate before each test?
It's starting with a clean state every time.  But half the time it keeps counting even though it shouldn't. 

There's nothing in it that depends on time or randomness, so it doesn't make a lot of sense. 

Every time it comes to the wrong value, it's because it is adding up another value that it shouldn't even be reaching.

Like I'm passing in an array of 10 values, but half the time it adds an 11th value that seems to come out of nowhere.

darkknightkryta

It's starting with a clean state every time.  But half the time it keeps counting even though it shouldn't.  

There's nothing in it that depends on time or randomness, so it doesn't make a lot of sense.  

Every time it comes to the wrong value, it's because it is adding up another value that it shouldn't even be reaching.

Like I'm passing in an array of 10 values, but half the time it adds an 11th value that seems to come out of nowhere.
At least your while loop based quick sort isn't bugging out when a zero is on the right side.

Go Up