From the course: Advanced Algorithmic Thinking with Python
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Presort for mode finding - Python Tutorial
From the course: Advanced Algorithmic Thinking with Python
Presort for mode finding
- If you took the first course in this series you may remember binary search. An important aspect of binary search is that you need to sort your data first before you can apply it. Sorting your data first, or presorting, is an example of instant simplification, which is one of the categories of transform and conquer. In a moment, we're going to look at a Python function for finding the mode of a set of data. If you like, you can pause the video now and have a go at implementing a function to do this yourself. Bear in mind though that we're looking at transform and conquer, and the brute force approach for finding the mode is likely to be much less efficient. On Branch 03_04, you will find a file called Motor.py. Now at the bottom on lines 20 through 25 we have some sample function calls with sample data. And then the main function is at the top from lines one to 17. Now the way this works, first of all we need to…
Contents
-
-
-
-
-
Coins on a star puzzle1m 28s
-
(Locked)
Coins on a star puzzle solution1m 8s
-
(Locked)
Introduction to transform and conquer1m 5s
-
(Locked)
Presort for mode finding3m 29s
-
(Locked)
Number placement puzzle revisited2m 55s
-
(Locked)
Challenge: Implement number puzzle solution in Python3m 29s
-
(Locked)
Solution: Implement number puzzle solution in Python2m 49s
-
-
-
-