teach-ict.com logo

THE education site for computer science and ICT

Search Sort Algorithms

Lesson tasks

Linear or Sequential search code

The link opposite contains a python file that carries out a linear search algorithm.

The student can run this to understand how linear search operates

A further task could be to extend it to include a counter that reports how many searches it made.

As a further task, the student could add extra code to allow the user to insert the unfound item into the list

(subscription only)

 

Click Here

 

Binary search code

The link opposite contains a python file that carries out a binary search algorithm.

The student can run this to understand how binary search operates

A further task could be to extend it to include a counter that reports how many searches it made.

A large list could could be coded with a loop, then use it to explore the worst and best case performance - it should come to O(log n)

As a further task, the student could add extra code to allow the user to insert the unfound item into the list at the correct point

(subscription only)

 

Click Here

Bubble sort code

The link opposite contains a python file that carries out a bubble sort algorithm.

The student can run this to understand how bubble sort operates

A further task could be to extend it to include a counter that reports how many compares and swaps it made.

 

Click Here

Insertion sort code

The link opposite contains a python file that carries out the insertion sort algorithm.

The student can run this to understand how insertion sort is encoded

 

 

Click Here

Merge sort code

The link opposite contains a python file that carries out the merge sort algorithm.

The student can run this to understand how merge sort operates

A further task could be to extend it to include output showing the lists created as it runs, then how it reforms the list into the final one

 

Click Here

Quicksort code

The link opposite contains a python file that carries out the quicksort algorithm.

The student can run this to understand how quicksort operates

A further task would be to explore sort time by giving it large lists of a certain type: a) already sorted, b) completely random with unique values, c) random with few unique values

 

Click Here