Doctor Who:
Oh. [GASPS] I'm glad you're here. Slight problem. Your funny little planet is about to be destroyed unless you can help me.
Doctor Who:
[GASPS] [BREATHES HEAVILY] The daleks have engineered a supernova that's damaged the TARDIS and now the shockwave is heading towards earth. . . . [SCREAMS]
Doctor Who:
Look. I can't fix this alone. I need your help. . . . The TARDIS is damaged. I don't know where I am. I need you to locate the TARDIS for me.
Julia Hardy:
Right, yes, you heard the Doctor. Our first mission is to locate the TARDIS. Now you're gonna do this by using the micro:bit's compass function together with a special programme that we've given you.
Iain Stirling:
Now teachers if you haven't got these done already, don't panic. There is still time. You can download the Hex file now from our website and then get your class to drag them onto the micro:bits.
Julia Hardy:
That's right. Now, while you do that, I'm gonna explain the task at hand. So it's pretty simple. Everyone, plug the battery pack into your micro:bits now.
Julia Hardy:
Now you should see a question mark starting to flash on your LED screens.
Audience:
Yes.
Julia Hardy:
Ok. Now, in a minute. Wait for it. Not yet. Not yet. Simply point and press button A to try and find the TARDIS. Now, if you find it, the message TARDIS is gonna appear on your LED screen. Pretty straightforward.
Iain Stirling:
Not yet.
Iain Stirling:
And if you don't find it, it'll just remain as a question mark.
Julia Hardy:
That's right.
Iain Stirling:
Ok, but if it's the first time you've done this with the new programme on your micro:bit, you might need to calibrate your micro:bit's compass. The instructions draw a circle will come up on the screen and you can do this by tilting your micro:bit to create a circle. The clue is in the name.
Julia Hardy:
The word circle as well. Right. So, right, are you ready to find the TARDIS?
Audience:
Yes.
Julia Hardy:
Ok, we're gonna give you a few seconds to have a go. So, are you ready? Off you go.
Julia Hardy:
See if you can find it.
Iain Stirling:
Press A. Try and find it
Iain Stirling:
Quickly, quickly, quickly, quickly, quickly, quickly, quickly!
Iain Stirling:
Time's up. Sounds simple, doesn't it, but chances are you didn't find it no matter how hard you tried and if, in the extremely unlikely event, you have stumbled upon the TARDIS, well done. However, finding it randomly is not good enough.
Julia Hardy:
No, no. You know we want you to use skills to actually find it rather than just luck because skills are for life, obviously not just for Christmas. Now we need to search for the precise location of the Doctor and the TARDIS. So we need to do a spot of computational thinking.
Iain Stirling:
And to help us guide and to help guide us, reading out loud's hard.
Julia Hardy:
It is, isn't it? It's a tough day for you, Iain.
Iain Stirling:
Sorry everyone. And to help guide us, we've got a very special guest from the biggest internet search company on the planet. Please welcome from Google, it's Google and engineer, Laura Lowenthal, everybody. [APPLAUSE]
Iain Stirling:
Come on, she's from Google everyone!
Julia Hardy:
Hi!
Laura Lowenthal:
Hiya.
Iain Stirling:
Laura, Laura lovely to have you with us. Are you having a lovely day so far?
Laura Lowenthal:
Thank you.
Laura Lowenthal:
Lovely day.
Iain Stirling:
I'm glad to hear it. So you're an engineer so you must know a thing or too about computers. So what is it about computers and computer science that you found so interesting growing up?
Laura Lowenthal:
Well, ever since school I've really enjoyed solving puzzles and math problems and that's exactly the kind of skills that you need for computer science. See, computer science is all about getting real work problems and framing them in ways that computers can understand and help you solve.
Laura Lowenthal:
So since real work problems are always changing, the job itself always changing and it never gets boring.
Julia Hardy:
Oh, wow. Ok, so I think everyone here knows how to use Google. I mean, yeah, it's so commonly used that even the verb to google is now in the English dictionary. Obviously, you know, you type in what you want and then you find it. It all sounds very, very straightforward but how does actually the search programme work within that?
Laura Lowenthal:
Well Google has an index of all the web pages there are available publicly.
Julia Hardy:
All of them?
Laura Lowenthal:
Online. All of them.
Julia Hardy:
[SIGHS]
Laura Lowenthal:
Well . . . All that are available online. . . . So it works like an index at the back of a book where alphabetically you can find what pages contain the information that you are looking for. So, when you type in your search, say you type in Doctor Who: , Google has quick access to that index and has all the relevant pages that contain information about Doctor Who: . But that can be hundreds, thousands, millions of pages.
Laura Lowenthal:
So Google needs still to narrow it down to whatever's relevant for you. For example, when you're searching for Doctor Who: , you are probably interested in the Doctor Who: website or maybe some news about Doctor Who: , but certainly not in a page who lists the question, who is a doctor, a hundred times.
Iain Stirling:
Not interested in that.
Julia Hardy:
It's a really boring website if you've been there.
Laura Lowenthal:
Right. So to do that, Google will take some clues like whether Doctor Who: is on the title of a page or how fresh the content is or whether it's in a location that's close to you to show you what is most relevant to you.
Julia Hardy:
Ah, ok. A lot of things to think about.
Iain Stirling:
Yes, there's a lot to do with narrowing down a search. That seems to be the most complicated bit. So, how are computers narrowing down this search so we can find what we're actually looking for?
Laura Lowenthal:
Well, actually the journey started way before you typed in your search. . . . To build that index Google uses software called crawlers that start with a few web pages in the web and start clicking and following links like you would do if you were to browse all over the internet. So as you move along, you gather the information of each of the page and store it in the index for quick access later. So the index ends up being pretty big, about hundred million gigabytes.
Julia Hardy:
Google's, kind of, done it's homework ahead of time. It's found out where it needs to go before it needs to go there. Is that, kind of, right?
Laura Lowenthal:
That's right.
Iain Stirling:
A hundred million gigabytes.
Laura Lowenthal:
Yeah.
Iain Stirling:
That's like 800 million Ed Sheeran albums everyone.
Julia Hardy:
That's a lot of emotions all in one place.
Iain Stirling:
So where are all these index stored?
Laura Lowenthal:
They are stored in data centres across the world. So Google keeps this information replicated, which means it keeps several copies of it just in case so that your information reaches you fastest by being closest to you.
Julia Hardy:
Ah, ok. So searching, you know, using a search engine is clearly a complex operation underneath it all, but today to understand the basics we're just gonna focus on a couple of very simple search algorithms. So first of all, I guess we need to define what is a search algorithm before we go any further.
Laura Lowenthal:
Right. So an algorithm is simply a sequence of steps that you take to reach a certain result. So a recipe for a cake, for example, that is an algorithm.
Julia Hardy:
[INTAKES BREATH] A delicious algorithm.
Laura Lowenthal:
Yeah. An algorithm to reach a cake. So a search algorithm would be a sequence of steps to find something that you're looking for amongst a big collection of items or things, like finding your favourite book in a big book shelf. There are different kinds of search algorithms and each has its advantages and disadvantages; how simple it is to write, how fast it runs a computer or how many resources it consumes.
Julia Hardy:
Mmm. Ok.
Iain Stirling:
Right, cool. So, unfortunately, we cannot Google the TARDIS today to find out where it is.
Julia Hardy:
Why not?
Iain Stirling:
Because that would be boring. So what we're gonna have to do is look at how two of the most basic search algorithms work. We're gonna look at linear search and binary search. Here is a video about both of those things now on this screen.
Narrator:
To perform any search you need to know what you're looking for, your search term. In this case, a needle, and where to look for it, the list of items it's hidden in. In this case, a haystack. Now imagine each thing in that list is lined up one by one and given a number, that number is known as its index. But let's face it, computers don't look for needles in haystacks, so to make our search algorithms easier to understand, let's make the elements in our list numbers and 15 is the number we're looking for. A linear search algorithm basically go through all of the elements one by one looking for a match, which could take a while, or we could use a binary search algorithm, which uses the computer's ability to order elements in a list, in this case from low to high numbers. First the algorithm finds the mid-point of the list, index three. It then checks if the search value is higher or lower than the element in index three. If it's higher, everything lower than index three is discarded. If it's lower, everything higher than index three is discarded. Index three is now the end point and the new mid-point is one. It performs the check again and goes on performing the check until we find the search term. The computer has now found your needle.
Julia Hardy:
Ok. Using what we've just learnt, we're gonna use one of these search algorithms to locate the TARDIS' position. So you can do this in your classrooms as well, and teachers do refer to activity sheet one for all the info.
Iain Stirling:
Ok, so it's on the list. We are using a compass, which is numbered from zero to 360 degrees because that is how a compass works, everyone.
Julia Hardy:
Thanks for that, Iain.
Iain Stirling:
You're welcome.
Julia Hardy:
Teachers, you can join in if you wish by finding the bearing of magnetic north in your classrooms. For here in the black archives, north is in this direction.
Iain Stirling:
Scotland's that way everyone.
Julia Hardy:
Come on everybody. Now, to complete the search we'll need six volunteers to take their place on our compass. Hi, guys. Come on in. Now each volunteer has a special micro:bit torch with them to help us locate the TARDIS. So when they find it, the message TARDIS will appear on their micro:bit screens.
Iain Stirling:
So Laura, if we were to perform a linear search to find the TARDIS, how would we go about doing this? Talk me through it.
Laura Lowenthal:
Ok. Well, as we've just seen, the computer would go one element of the list at a time, or in this case would go from degree zero to 360 one at a time and see if they match our search term, which is, in this case, the TARDIS. So let's start by checking position zero.
Iain Stirling:
This is it. Zico, we want you to put in zero and then press the button.
Iain Stirling:
A question mark or TARDIS?
Zico:
Question mark.
Iain Stirling:
It's a question mark. It's not there, Laura.
Laura Lowenthal:
That means that the TARDIS isn't there, that we need to move on to the next position.
Iain Stirling:
Ok, Zico could you move out to ten.
Laura Lowenthal:
Let's skip ten.
Iain Stirling:
Press it again, mate.
Iain Stirling:
A question mark or TARDIS?
Zico:
Question mark.
Iain Stirling:
Question mark again.
Julia Hardy:
So, right, if the TARDIS is over there, this is gonna take absolutely forever.
Laura Lowenthal:
We'll check 320, 330, 340 . . .
Iain Stirling:
Alright, ok, how about, listen, listen, listen, listen to me. How about we do a binary search. Would that work?
Julia Hardy:
Would that be quicker?
Laura Lowenthal:
Yes, I think a binary search would work better.
Iain Stirling:
So how do we do that? [LAUGHS]
Laura Lowenthal:
Well, the way a computer would do this is we find the mid-point between the first and the last element of the list or, in this case, our degrees. So the mid-point between zero and 360.
Julia Hardy:
Which is, of course, 180, right?
Julia and Iain:
180!
Laura Lowenthal:
Exactly. So let's go all the way there.
Iain Stirling:
Wicked. Ok.
Iain Stirling:
Hello also, Lucas. You're 180. How does that make you feel?
Lucas:
Happy.
Iain Stirling:
Good. He loves it.
Julia Hardy:
He loves it. Right, ok.
Laura Lowenthal:
So if you want to point your torch exactly at the 180 line and press button B.
Julia and Iain:
What's it say?
Lucas:
Higher.
Iain Stirling:
Higher.
Julia Hardy:
Ah, ok. So that means that the TARDIS is somewhere on this side here.
Laura Lowenthal:
It's higher than 180. So what the computer will do now is disregard everything that is below 180.
Iain Stirling:
Ok, if you two could just go over there. Thank you so much for your help.
Julia Hardy:
So, already within one search we've basically eliminated half.
Laura Lowenthal:
Yes. Exactly.
Julia Hardy:
That's quicker.
Laura Lowenthal:
So 180 becomes our new starting point and we start all over again. We find the mid-point between 180 and 360.
Julia Hardy:
Which is 270 maths?
Laura Lowenthal:
Thank you. Yes. So Dylan over there, if you want to step on the red line that's 270. Point your torch there, press button B.
Iain Stirling:
What's it say, big man?
Dylan:
Lower.
Iain Stirling:
Lower.
Julia Hardy:
Ah, ok. So that means everyone standing on that side now needs to go 'cause we know that the TARDIS is somewhere between 270 and 180.
Laura Lowenthal:
That's what a computer would do. Disregard everything that is higher than 270.
Julia Hardy:
Ok.
Laura Lowenthal:
And 270 becomes our new end point. So now we have to find the mid-point between 180 and 270.
Julia Hardy:
Which is 225.
Laura Lowenthal:
Oh, thank you. You're so good with maths.
Iain Stirling:
Dylan, get in the little red line. Good man. You're smashing this.
Laura Lowenthal:
Press button.
Iain Stirling:
Give you a little squeeze, tell me what you see.
Dylan:
Lower.
Iain Stirling:
Lower.
Laura Lowenthal:
Ok. So 225 becomes our new end point. Thank you, Dylan.
Julia Hardy:
So, Lucas you're the only man standing. Now we need to find the mid-point between here.
Laura Lowenthal:
Right and we've really narrowed this down. It only took us how many? Three steps.
Laura Lowenthal:
And we already know that it's in this region.
Julia Hardy:
So the TARDIS is literally somewhere here. Ok, right. So I think we're gonna go to 202.5. So that line there.
Iain Stirling:
Why 202.50?
Laura Lowenthal:
Because that's the mid-point between 180 and 225. Have you been paying attention?
Iain Stirling:
I'm very confused. [SIGHS]
Laura Lowenthal:
Alright, so if you point your torch to 202.50.
Julia Hardy:
What's it say?
Lucas:
TARDIS.
Julia Hardy:
It says TARDIS! We've found it.
Iain Stirling:
We've found the TARDIS.
Iain Stirling:
I did not think that was gonna work. Amazing.
Iain Stirling:
We've done it. Ok, now using binary search we have precise located the TARDIS in four simple steps. We now need to work out which direction the TARDIS is in, but to completely stabilise it we need everyone here and around the UK, so even in schools as well, to find it. I'm gonna go and show the audience what direction they need to be facing. So everyone stand up, please. Everyone stand up.
Julia Hardy:
Everyone face towards Iain. Now here in the studio are you all facing towards Iain?
Iain Stirling:
A little bit to your left. Everyone, sort of, in a line like this.
Julia Hardy:
Ok, now everyone around the UK all together we're gonna press button B and it'll say higher or lower to tell you if the TARDIS is further to your right or to you left, and then you can use it to help you find it. So, are you ready everybody. Off you go, press button B.
Iain Stirling:
Hit B and go left and right and try and get it right.
Iain Stirling:
Go left and right.
Iain Stirling:
Come on, guys. I believe in you.
Iain Stirling:
I've done it. I've done it. I've got it. We've got it. We've done it. Listen, [UNSURE OF WORD] thinking is in override. You've used your binary search and succeeded an intergalactic identification of the lost target. Julia, how do you feel?
Julia Hardy:
I feel fantastic. That was really cool actually, and if you wanna know more about how the code and the compass on the micro:bit works have a look at worksheet two on our website.