Welcome to the Seventeenth of Altitude Foundation’s #MicroChallenges2020
Today we’re sorting data in to an order which is most relevant to our needs.
What’s a Micro Challenge?
These challenges are short activities to help you develop, revise or refresh your coding skills, posted every Monday, Wednesday and Friday.
Micro Challenge #17
This week, we are exploring ‘best possible solutions’ – finding different solutions to issues and determining which is the best. This challenge links to last week’s theme of searches. If you want to explore further, you can find the relevant challenges here: Challenge 13 and Challenge 14.
To store data, computers can use arrays – this is an index which stores information in numerical order. The information or data stored could be anything from numbers and letters to ‘strings’ of words. We could visualise this like this:
|Batman (1939)||Black Widow (1964)||Captain America (1941)||Superman (1938)||Wonder Woman (1942)|
The number at the top row is the index number; the bottom row is our data. At the moment, our data is organised alphabetically. But it could also be organised by that date they first appeared in print (listed after their names), in which case our current array isn’t accurate. For example, if we were creating a superhero timeline, this would be a more relevant way of organising the information.
to our operations. This is easily done with the above array, but gets more complicated if, for example, we want to organise this list by the date of their first appearance.
As explored in Challenge 14, one of the ways in which searches can be sped up is if they are organised effectively.
Could you create a pseudocode or algorithm which could sort our superheroes based on publication dates?
Can you come up with more than one way of sorting the data? Remember, we are looking for ‘best solutions’ – so it is worth looking at several approaches!
As with searches, sorts can be faster or slower, depending on how the system you use. Is there a method of sorting which is more effective than others?
This TEDEd video presents a series of solutions, if you want to compare your ideas to others.
If you are interested in the speed of different types of sorts, here’s a very cool video which visualises them with sound, to give you a sense of how fast each sort works.
Can your code be adapted to sort based on different criteria? We have looked at alphabetical and date sorting – how else might you organise information? And which contexts might it be useful in?
Is there anything in your house that you could sort? And how might you visualise this – for example as a chart, a video or a spreadsheet.
Share itWe would love to see what you have created! Please send any pictures, videos, or files of your activities to us – either via Facebook, Twitter or Instagram using #MicroChallenges2020 or to firstname.lastname@example.org. If you are emailing them to us, please let us know if you are happy for us to share your stuff on our social media platforms (with credit, of course).
Sign-up here to receive a weekly email with Micro Challenges top tips and solutions: