Showing posts with label big-o. Show all posts
Showing posts with label big-o. Show all posts

Friday, June 8, 2012

List of Big-O for PHP functions


After using PHP for a while now, I've noticed that not all PHP built in functions as fast as expected. Consider the below two possible implementations of a function that finds if a number is prime using a cached array of primes.

Wednesday, May 9, 2012

array_unique vs array_flip


If I had an array of signed integers e.g:




Array
(
[0] => -3
[1] => 1
[2] => 2
[3] => 3
[4] => 3
)

Sunday, March 11, 2012

Why isn"t LinkedList.Clear() O(1)


I was assuming LinkedList.Clear() was O(1) on a project I'm working on, as I used a LinkedList to drain a BlockingQueue in my consumer that needs high throughput, clearing and reusing the LinkedList afterwards.