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

Worksheet 10.1 Classical Algorithms Searching and Sorting.

The document provides information about classical algorithms for searching and sorting. It includes examples of linear and binary search algorithms. Linear search looks at each item sequentially until the target is found, while binary search divides the list in half at each step to locate the target faster in an ordered list. The document also discusses the MergeSort sorting algorithm, which divides a list into individual elements, pairs them, groups them, and merges them in order. Worksheets are included for practicing matching algorithms to situations, reading comprehension with stop signs, and self-assessment questions.

Uploaded by

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

Worksheet 10.1 Classical Algorithms Searching and Sorting.

The document provides information about classical algorithms for searching and sorting. It includes examples of linear and binary search algorithms. Linear search looks at each item sequentially until the target is found, while binary search divides the list in half at each step to locate the target faster in an ordered list. The document also discusses the MergeSort sorting algorithm, which divides a list into individual elements, pairs them, groups them, and merges them in order. Worksheets are included for practicing matching algorithms to situations, reading comprehension with stop signs, and self-assessment questions.

Uploaded by

Harold
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

WORKSHEET 10.

1
Classical algorithms: searching and sorting.

Worksheet 10.1

Do the following tasks:

1. Order these countries from the smallest to the biggest:


Colombia Vatican Russia India

2. Order these subjects alphabetically:


Mathematics Physics Biology Spanish

3. Find the action movie in this list:


Titanic Conjuring ET Transformers
Worksheet 10.2

Match the vocabulary word with the antonym.

1. Search………………. Antonym
2. Sort………………….. Abandon disorder none
3. Each………………… Later whole output
4. Until……………….. lose disorganized length
5. Input……………….
6. Find…………………
7. Ordered…………………….
8. Height………………………
9. Middle………………………….
Worksheet 10.3
Read the text, and each time you see a *stop* sign, you need to stop and think whether
you understand what you are reading or not. If not, you have to go back and reread.

Top Algorithms You Really Need To Know

If you want to become a software engineer, the most basic thing that you have to learn
are algorithms and data structures. The more algorithms and data structures you learn,
the more useful they will be in your career as a software engineer. To start, let’s learn
Search and Sort, two classes of algorithms a programmer can’t live without. *stop*

Searching

There are two categories of search algorithms we will study: linear and binary.

Linear search

Linear search algorithms means that the program will look at each item in the line (=input)
until it finds the necessary item. *stop* If you have 100 items and you need to search for
one specific item, then you have to look at every item in the input before you find the
necessary item. Linear = simple. *stop* For example: imagine you want to find your friend
Maria in a line of people standing in no particular order. You already know Maria´s
appearance, so you have to look at each person, one by one, in sequence, until you
recognize Maria. In doing so, you follow the linear search algorithm. *stop*

Binary search

Binary search (binary - “relating to 2 things”) works by dividing the input into two parts
until it finds the necessary item. *stop* One part contains the necessary item and the
other part does not. It is faster than linear search, but it only works with ordered
sequences – and this is very important, because the linear search does not need an
ordered sequence. *stop* For example: imagine you’re want to find your friend John (who
is 170 cm tall) in a line of people ordered by height from left to right, shortest to tallest. It
is a very long line, and you do not have time to go one-by-one like with the linear search.
What can you do? Use binary search. You select the person in the middle of the line, and
measure their height. The person is 165 cm tall. You immediately know that this person,
and all the people on their left, are not John. *stop* Next, you turn your attention to the
people on the right and select the middle person again. The person is 172 cm tall. You can
eliminate that person and all the people on the right. And so on, until you find the person
who is 170 cm tall – and that is John. In doing so, you follow the binary search algorithm.
*stop*

Sorting

Sorting is a synonym of ordering. It is one of the most common programming tasks. We


will look at one type of sorting - MergeSort. *stop*

MergeSort

Imagine you have an unordered group of people, and you need to order them by height.
First, you divide the group in two; then you divide each of the two groups in two again,
and so on – until you have individuals. *stop* Second, you put individuals in pairs; you put
the taller person to the right, until you organize all the pairs. Next, you put pairs in groups
of four, and order them. *stop*After that, you put the groups of four into groups of eight.
And so on, until you have a complete line of people ordered by height. By doing so, you
follow the MergeSort algorithm. *stop*
Worksheet 10.4
Read the following situations and figure out which of the three algorithms you have to
use in each situation: linear search, binary search or MergeSort.

1. There are 30 students in class. You need them to stand in a line according to their age,
from the youngest to the oldest, from right to left.
2. You have 15 circles that are ordered in the line from the smallest (2 cm diameter) to
the biggest (50 cm diameter). You need to find the circle that is 22 cm in diameter.
3. You are in a supermarket, and your mother asked you to buy coffee that is called
“Super Delicious Coffee”.
4. You are in the library, in the section of “Original English Literature”. There are 100
books that are ordered alphabetically. You need to find “Harry Potter and the Order of
Phoenix”.
5.
There are 10 people in a bank. The oldest people have a priority. You need to make a
line of people taking into account the priority: oldest person first, youngest person
last.
Worksheet 10.5

Answer the following questions:

1. ¿Entiendo en qué consiste la estrategia de “rereading”?


Si No De pronto

2. ¿La estrategia “rereading” me ayuda a concentrarme más cuando leo un texto?


Si No De pronto

3. ¿Cuando vuelvo a leer, entiendo el texto mejor?


Si No De pronto

You might also like