hero image

木易空间

You can

1. 选择排序(Selection Sort)

基本思想:

首先找到数组中最小的那个元素,将它和数组的第一个元素交换位置。然后在剩下的元素中找到最小的元素,将它与数组的第二个元素交换位置。如此往复,直到将整个数组排序

算法分析:

时间复杂度: O ( n 2 ) O(n^2) O(n2)

空间复杂度: O ( 1 ) O(1) O(1)

稳定性:不稳定排序

public class SelectIonSort {
    public SelectIonSort() {
    }
    public static void main(String[] args) {
        int[] arr = new int[]{1, 3, 6, 8, 78, 9, 48, 8, 56};
        selectionSort(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void swap(int[] arr, int i, int j) {
        int temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }
    public static void selectionSort(int[] arr) {
        for(int i = 0; i < arr.length - 1; ++i) {
            int min_index = i;
            for(int j = i + 1; j < arr.length; ++j) {
                if (arr[j] < arr[min_index]) {
                    min_index = j;
                }
                swap(arr, i, min_index);
            }
        }
    }
}

MuYiAbout 10 min
Pytest

Pytest


Pytest是一种单元测试框架,Python第三方库,可以在框架内用Selenium或Requests编写自动化测试用例和执行测试用例,可拓展各类功能,包括日志、生成测试报告等等功能,是自动化框架必备的知识点,相比同类型库功能更多更灵活。

安装

pip install -U pytest

MuYiAbout 21 min
Requests

Requests


Requests是Python的HTTP库,用于发起HTTP请求

安装

pip install requests

使用


MuYiAbout 3 min
Selenium

Selenium

Selenium是一个用于Web平台测试的工具,通过模拟用户操作达到测试目的,Selenium本身是一系列工具,支持各种语言,这里以Python语言示例,主要讲Selenium WebDriver

Selenium系列工具

  • Selenium WebDriver

Web应用程序的自动化测试工具

  • Selenium IDE

自动化测试的一个浏览器插件。提供简单的脚本录制、编辑与回放功能。


MuYiAbout 10 min
2
3
4