0% found this document useful (0 votes)
15 views

Module 3 - Student

Uploaded by

Rejean Fabria
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Module 3 - Student

Uploaded by

Rejean Fabria
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Module 3

Searching and Sorting

Where Are You Now? 2


Exercise 4
Me First! Sorting 5
Exercise 6
CSI - Finding Information
on the Internet 7
Exercises 8
End of Module Quiz 12

© 2013 Lero
Where Are You Now?

Why do Computers Need to Perform Searches?

Some examples

Mobile Phones can Bank tellers need to


query the amount of look up the balance
credit remaining. for a customer’s
account number.

Online music stores


are able to find songs
by a given artist.

How do Computers Perform Searches?

The Method

Get a Search Key


For example
• Phone Number
• Bank Account Number
• Song Artist/Song Title

Locate Information Related to the


Search Key
For example
• Amount of Credit Remaining
• Account Balance
• Songs available for download by an
artist

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

• Your items must be sorted in order for a binary search to work.


• It is similar to how people locate information in a dictionary.
• Check the middle item of the list to identify which half the search
key is in. The process is repeated on each successive half until the
list has been narrowed down to just one item.
• In the phone book example, a book with 1 million names can
now be searched with a maximum of 20 probes, which might
take a computer two hundredths of a second.

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

 A worker wishes to find the phone extension of Ailish Power.


Follow instructions below to perform this search comparing the search methods described on the
previous page.

4 | Scratch Workbook
Me First! Sorting

Write out the items from the list below in the sort order outlined in the boxes provided.

First Name Surname PPSN


Anna Ryan 7860277B
Ruth Horgan 8392109D
Brian Scott 7861212F
Shane Ryan 9058693D
Mary Hogan 7860133C

First Name (A to Z) Surname (Z to A) PPSN (low to high)

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

What are Search Engines?

• A web search engine searches for information on the web.


• Most search engines operate algorithmically and automatically.
• They are like a well-trained dog – they will ‘fetch’ what you want, but only if you use the right
commands.
• Search Engines use ‘Spiders’, special programs to ‘crawl’ the Internet to find results.
• More ‘keywords’ are better as this means more relevant results and fewer hits are returned.

Popular Search Engines

• http://www.google.com
• http://search.yahoo.com
• http://www.ask.com

Too many results? Confused?!

• Use inverted commas “” around a phrase to limit number of results.


• Enter the phrase transition year in Google.
• Now try it with inverted commas i.e. “transition year”.
• How relevant are the links on the first one or two pages of the result and
how many results did you get each time?

Searching with the help of Mr. Boole

• A Boolean Search is made up of keywords connected by logical operators AND


(+), OR(/), and NOT(-).
• It is named after George Boole, first professor of Mathematics at Queen’s
College Cork, now U.C.C.
• Computers cannot understand human language, but they can match words.
• By using a combination of keywords and boolean operators you will improve
the results of your search.

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.

This means that print resources contain accurate, useful information.

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

 Internet Treasure Hunt Activity Sheet


You are going on a treasure hunt on the Internet. You will use various web sites, including search
engines to find the answers to the questions below.

• Use the Internet to find the answers to questions 1 – 8.


• Write down the answers.
• When you have found all the answers, write the first letter of the answers in the spaces
provided below.
• You must unscramble these letters to give you an 8-letter magic word.
Good luck!

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: ___________________

6. What is the medical term for fear of flying?


Answer: ___________________

7. Go to the Irish Government website http://www.gov.ie

8 | Scratch Workbook
What government department deals with road, rail, air and maritime services?
Answer: ___________________

8. Name the waterfall at the border of Argentina, Brazil and Paraguay.


Answer: ___________________

Letters 1 – 8 (First letters of all your answers): ____ ____ ____ ____ ____ ____ ____ ____

Magic Word Unscrambled: _________________________________________

 Try the following searches:

1. Search http://www.google.com for “italian restaurants” +ireland.


2. Search http://search.yahoo.com for ireland +football/hurling.
3. Search http://www.ask.com for “Famous Irish People” –sport.

Compare your results when you don’t use “ ” or boolean operators.

 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.

Purpose of the Site Circle one Explain


Can you tell if the site is fact
or opinion? (If the information
seems one-sided, or biased, you Yes No
will have to go elsewhere to hear
the other side of the issue.)
Is the site free of advertising? Yes No
Is a large proportion of the
Yes No
website covered with ads?

Is the site sponsored by any


Yes No
organisations?
Is the tone calm and fair? (Sites
that are hateful and angry
Yes No
may not be a good source of
information).
Is the site open to everyone
or are there fees, passwords, Yes No
registration etc.?

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

Was this site recommended by a


Yes No
site you trust?

Is the site without spelling,


typographical, and grammatical Yes No
errors?

Up to date information Circle one Explain


Is the date the article, page, or
Yes No
site that was created given?
Is the date the site was last
Yes No
updated given?
Do all the links lead to active
Yes No
pages?

Usefulness of Information Circle one Explain


Does this site have enough
Yes No
information for your search?
Is most of the information useful
for your research?
Yes No
(If not, it may be hard to find
what you do need.)

10 | Scratch Workbook
Ease of Use Circle one Explain
Is the text understandable? Yes No

Do the titles and headings give a


Yes No
clear idea of the content?

Does the website include a site


map that provides an overall
Yes No
view of how the website is
structured?

Is there a tool for searching the


Yes No
site?

Are the web links labelled clearly


and do they accurately describe Yes No
the sites they are pointing to?

Discussion

1. How many ‘Yes’ answers did you circle?


2. What are the most important questions in this evaluation, in your opinion, and why?

Module 3 | 11

You might also like