Module 3 - Student
Module 3 - Student
© 2013 Lero
Where Are You Now?
Some examples
The Method
2 | Scratch Workbook
Types of Search performed by a Computer
Linear Search
• Computers work very quickly from the top of a list checking each
item one by one until it hits the search item.
• How efficient is a linear search?
• e.g. Imagine starting at the first page of the phone book and
checking every page until you find a phone number for a man
called John Williams
Binary Search
Hashing
• Until quite recently, the Hong Kong telephone directory worked like this: names were sorted
into groups according to the number of strokes they contained, and having found the right
group, you had to scan through it to find the name you wanted.
• Computer programmers usually use some version of the hashing strategy for searching,
unless it is important to keep the data in order, or if an occasional slow response is
unacceptable—as in a life support system.
Module 3 | 3
Exercise
4 | Scratch Workbook
Me First! Sorting
Write out the items from the list below in the sort order outlined in the boxes provided.
Did it take you a long time to sort this information? Imagine how long it would take to sort a list with
thousands of items.
We know that computers are good at performing algorithms that do repetitive tasks well. This is why
they are often used to order data, whether alphabetic, numeric, or by date. Many clever algorithms have
been devised for putting values into order efficiently. If you use the wrong method, it can take a long
time to sort a large list even on a fast computer. Fortunately several fast methods are known for sorting.
Check out the 3 “Scratch Sorting Videos” in the resources section of Module 3
at http://www.scratch.ie/students
We will look briefly at three algorithms used for sorting with a computer.
Bubble Sort
Bubble sort works by repeatedly stepping through the entire set of items to be sorted, comparing two
adjacent items at a time and swapping them around if they are in the wrong order. When no swap is
required the sorting is completed. This is the least efficient method of the three algorithms we will look
at, although it works well enough for a small set of items.
Selection Sort
This works by examining all the items in the list until the lowest value is found. Swap this with the value
in the first position. The remaining items are continuously scanned in this manner, swapping the smallest
item from the remaining items to the second position, third position etc, until all items are in correct
order from left to right. This is a more efficient method than bubble sort.
Quicksort
This works by choosing a random item from a list and placing it in the centre of the list. The other items
are placed to the right or left of this item, depending on whether they are lower or higher than the item.
An item is then chosen from one of these bundles and that bundle is sorted in the same manner, as is the
last bundle. Quicksort is the most efficient method (divide and conquer).
Module 3 | 5
Exercise
First Name Use the bubble sort method described previously to sort the first names from
Anna the list shown. Fill in the boxes below. You should use a separate sheet of paper
Ruth to help with your workings.
Brian
Amount of times you have to work through the entire list
Shane
Mary Total amount of swaps required
6 | Scratch Workbook
CSI - Finding Information on the Internet
• http://www.google.com
• http://search.yahoo.com
• http://www.ask.com
A Useful Tool
• For longer pages the ‘Find on this Page’ function helps you to find words on a page.
• Click on the magnifying glass and choose ‘Find on this Page’ from the menu.
• Type the word you want to find and it will be highlighted on the page.
• You can also use the shortcut ‘Ctrl F’.
Module 3 | 7
Choosing which Websites
Respected, books, magazines, and journals go through many stages of development, involving authors,
editors, designers, proofreaders, and publishers.
Remember, anyone can be an author on the Internet. Creators of websites do not have to be experts in
any subject and their facts don’t have to be true. All you really need to be an author on the Internet is
knowledge of how to build a website. It’s up to you to judge which sites are good and reliable and which
sites are not.
Exercises
1. What is the main colour of the Latvian flag? Be careful, you need to research this one
carefully!
Answer: ___________________
2. Go to the TG4 website and navigate to the ‘weather’ section. Find the Irish word for
‘present’ or ‘current‘.
Answer: ___________________
3. What is the name given to the address of a specific website or file on the Internet?
Answer: ___________________
4. Find a web site with a list of world currencies. Use the “Find on this Page” function
(Shortcut = Ctrl + F) to find Somalia and then write the currency of Somalia.
Answer: ___________________
5. Use the web site http://www.bubl.ac.uk to find a Dutch language for Beginners website.
On this website find the Dutch word for ‘elbow’.
Answer: ___________________
8 | Scratch Workbook
What government department deals with road, rail, air and maritime services?
Answer: ___________________
Letters 1 – 8 (First letters of all your answers): ____ ____ ____ ____ ____ ____ ____ ____
So, which websites should you trust? What websites will meet your needs?
1. Choose a topic that interests you. Find a web site on this topic - you may use a
search engine.
2. Answer the following questions to help you decide whether or not you should
use the site for information.
Module 3 | 9
Trustworthiness of the author Circle one Explain
Is the author identified by name? Yes No
Can the author be contacted if
you have any questions? (E-mail
Yes No
address, postal address, phone
number)
Is the author’s place of work or
the organisation he/she belongs Yes No
to given?
Is the site’s domain .edu
(educational organisations),
.com (businesses), .org (usually
non-profit organisations), or .gov
(government agencies)?
(If you see a ~ in the website
Yes No
address, it may be a personal
site, not an official site). You can
also see .ie (Ireland) / .uk (United
Kingdom) etc. as the domain.
These are not tightly regulated,
however
10 | Scratch Workbook
Ease of Use Circle one Explain
Is the text understandable? Yes No
Discussion
Module 3 | 11