Other Topics‎ > ‎Complexity‎ > ‎Big O notation‎ > ‎

BYOB examples of Big O

BYOB is short for Build Your Own Blocks and is a program that is a powerful extension of the Scratch program from MIT. As the name implies the user can build their own blocks. For blocks read functions. Blocks can have parameters and return values. Version three is the current version of BYOB and can be downloaded from the BYOB homepage

If you can use Scratch, moving up to BYOB is relatively easy. Once you have tried it you are unlikely to go back to using Scratch!



The screenshots below show examples of each Big O notation. They are part of a collection of scripts for one sprite. The BYOB file is attached at the bottom of this page. Note: you must use BYOB to open it, Scratch can not do it. The best way to open the script is to 1) open BYOB, 2) drag the Big O.ypr file into the program window.

Also, attached is an Excel file that show graphs of the timings of many of the scripts.


 Big O
 Script block
 T(n) = O(1)
 


Initialise a list called aList of length n, then randomly pick one item from it. No matter how big n is the retrievel time is constant.

 T(n) = O(n)  

Iitialise a list of n random numbers and sequentially search it for the smallest item. The whole list is searched as the smallest item may be the last.

 T(n) = O(n^2)  


Loops are very costly in terms of processing time, so are perfect examples of Big O.

 T(n) = O(n^3)  
 T(n) = O(log(n))  


The value of counter changes slowly at first, but then rapidly increases as it is being doubles on each iteration of the loop.

 T(n) = O(n*log(n))
n(logn) Big O


This is similar to log(n), but multiplying by n has a significant effect, especially at large values of n as log(n) does not change much.



Č
Ĉ
ď
BigO.xls
(73k)
joebloggsnz .,
2 Apr 2011 16:01
ċ
ď
BigO.ypr
(29k)
joebloggsnz .,
9 Jun 2011 19:20
Comments