I've been playing around with list operations in Scratch. I had the idea that kids in the last couple of years of primary (elementary) school could do some cross-curricular activities by implementing statistics like mean, median, and mode in Scratch. Since I'm only going to be dealing with numbers 1-100 in my data (I want to do stats on data collected from the Picoboard) what I need is a bucket sort. To do mode, I put all the data into buckets (one per number) and find which bucket has the largest number of items in it. To do median, I go through the buckets until I've found half of my data, then I'm at the median. Average is pretty straightforward.
What is the runtime of a random access of a list operation? If I do
replace item [25] of [buckets v] with <<item [25] of buckets> + 1>(Sorry I couldn't get the Scratch blocks just right...)
Offline