O-level考试数学的备考一直是考生们关注的话题,尤其是涉及到一些理论知识的时候,考生们往往不知如何是好。那么今天小编就给大家介绍一下如何通过算法来给数字排序,希望对大家有所帮助。
Part.1 bubble sort
在bubble sort中,我们通过比较每两个相邻数字来进行排序。
■ 首先介绍一下基本流程:
Start at the beginning of the list. Pass through the list and compare adjacent values. For each pair of values

■ If they are in order, leave them
■ If they are not in order, swap them.
2. When you get to the end of the list, repeat step 1.
3. When a pass is completed without any swaps, the list is in order.
从已给列表的最左边开始,比较每两个相邻之间的数字,如果它们有序,保持不变;
如果没有排好序,交换他们的位置。 当你完成一个pass时,再重复前面的步骤直到我们完成了一个不需要任何交换位置的pass。
Part.2 quick sort
在quick sort中,我们选取一个pivot把数据分成两个sub-lists, 大于pivot的和小于pivot的数据。然后再在子表中继续选取pivot分成更多的子表。
■ 基本流程:
1. Choose the item at the mid-point of the list to be the first pivot.
2. Write down all the items that are less than the pivot, keeping their order, in a sub-list.
3. Write down the pivot.
4. Write down the remaining items (those greater than the pivot) in a sub-list.
5. Apply steps 1 to 4 to each sub-list.
6. When all items have been chosen as pivots, stop.
Part.3 Exam Tips
■ Exam Tips:
1. 看清题目中的要求,descending or ascending。
2. 在使用bubble sort的时候,注意我们要一直写出一个没有任何swap的pass才可以结束algorithm,不能因为数据已经完成排序就不写出最后的pass。
3. 在quick sort中,我们选择了pivot之后,我们剩下的数据仍然要按照原本的顺序写入sub-list。
以上是小编给大家带来的O-level数学考试备考的相关资讯,希望对考生们的备考有一定帮助!了解更多olevel评分标准、olevel高分作文等问题,可咨询在线客服。
报名咨询 电话:400 850 6500
地址:上海市杨浦区国泰路 11 号复旦科技园大厦 1504室
邮编:200433
电话:400 850 6500
地址:中国江苏省南京市栖霞区紫东路1号紫东国际创意园E1区351室
邮编:210000
电话:(+65) 6909 571
地址:8 Burn Road #06-05 Trivex, Singapore
邮编:369977
免费留学规划