0% found this document useful (0 votes)
30 views7 pages

Y10 05 CT25 Slides

slides

Uploaded by

molaposk10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views7 pages

Y10 05 CT25 Slides

slides

Uploaded by

molaposk10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 7

Y10-05-CT25: Merge sort

Y10-05-CT25: Merge Sort

Learning objectives
In this lesson you will learn to:

• Describe the merge sort algorithm


• Merge two sorted lists.

For more detail on this topic, and additional learner activities, refer to
Topic 1.12 of the student book.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-05-CT25: Merge Sort

Sorting data

In a previous topic, you learned that there are many ready made
algorithms that can be used to perform common actions.

You learned about the linear search algorithm.

Now, you are going to learn about an algorithm used to sort data in a
list or array.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-05-CT25: Merge Sort

Merge sort
The merge sort is a commonly used algorithm. It is suitable for
sorting large datasets because of its efficiency.

It is a divide-and-conquer algorithm. It breaks a problem down into


small parts and solves each in turn.

It operates by splitting a dataset (a list or array) into two parts,


repeatedly, until each subset is a single item.

Each pair of subsets is then merged back together in order.

This merging process is repeated until there is one set remaining –


the sorted list.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-05-CT25: Merge Sort

Merge sort algorithm

• Keep dividing the list


into sub-lists until each
list has exactly 1 item.
• Merge pairs of sub-lists
in order.
• Repeat until one
ordered list remains.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-05-CT25: Merge Sort

Merge sort in Python


You’ve learned how to manipulate Python lists in previous lessons.
You do not need to be able to implement a full merge sort in Python,
but you can learn more about how it works by completing part of the
algorithm in code.

The Python skills required to do this are:


• performing repetition, using ‘while’
• indexing lists and adding items to lists
• comparing items to find the smallest value.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.
Y10-05-CT25: Merge Sort

Wrap up: you have learned how to…


 Describe the merge sort algorithm.
• A divide-and-conquer algorithm which uses recursion to break
the dataset into smaller and smaller subsets then merges
them back in order.
 Merge two sorted lists.
• Use the Python list function to select the item at the top of one
list, then compare and add it to the sorted list.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy