Tag: php

  • PHP algorithms: knapsack 0/1

    PHP algorithms: knapsack 0/1

      The problem of optimization. Knapsack algorithm is frequent used piece of code appearing in variety different applications in various forms. Given a container with limited capacity and a set of items represented in two dimensions (weight/value), the goal is to find most valuable combination of items. To achieve this we must sort items by weight/value ratio in ascending…

  • PHP data structures: spl Stack

    PHP data structures: spl Stack

    Why no array? Sometimes (yes in web development too) you need to optimize your code for speed and memory usage. PHP is simplified by design and heavily depends on array usage. You can speed things up a little using proper data structures for the job. Luckily the language provides build in classes and interfaces for…