17种编程语言实现排序算法-合并排序

news2024/11/14 13:42:23

开源地址

https://gitee.com/lblbc/simple-works/tree/master/sort/

覆盖语言:C、C++、C#、Java、Kotlin、Dart、Go、JavaScript(JS)、TypeScript(TS)、ArkTS、swift、PHP。
覆盖平台:安卓(Java、Kotlin)、iOS(SwiftUI)、Flutter(Dart)、Window桌面(C#)、前端(微信小程序、uni-app、vue)、后端(Java、Kotlin、NodeJS、Python、PHP、Go、C、C++)、鸿蒙


image

1. 安卓Java版

开发工具:下载Android Studio

public static void sort(int[] array) {
        int first = 0;
        int last = array.length - 1;
        mergeSort(array, first, last);
    }

    private static void mergeSort(int[] array, int first, int last) {
        if (first < last) {
            int mid = (first + last) / 2;
            mergeSort(array, first, mid);
            mergeSort(array, mid + 1, last);
            binaryMerge(array, first, mid, last);
        }
    }

    public static void binaryMerge(int[] array, int first, int mid, int last) {
        int[] tmpArray = new int[array.length];
        int left, right, index;
        for (index = first; index <= last; index++) {
            tmpArray[index] = array[index];
        }
        index = first;
        left = first;
        right = mid + 1;
        for (; left <= mid && right <= last && index <= last; index++) {
            if (tmpArray[left] <= tmpArray[right]) {
                array[index] = tmpArray[left++];
            } else {
                array[index] = tmpArray[right++];
            }
        }
        while (left <= mid) {
            array[index++] = tmpArray[left++];
        }
        while (right <= last) {
            array[index++] = tmpArray[right++];
        }
    }

image

2. 安卓Kotlin版

开发工具:下载Android Studio


fun sort(array: IntArray) {
    val first = 0
    val last = array.size - 1
    mergeSort(array, first, last)
}

private fun mergeSort(array: IntArray, first: Int, last: Int) {
    if (first < last) {
        val mid = (first + last) / 2
        mergeSort(array, first, mid)
        mergeSort(array, mid + 1, last)
        binaryMerge(array, first, mid, last)
    }
}

fun binaryMerge(array: IntArray, first: Int, mid: Int, last: Int) {
    val tmpArray = IntArray(array.size)
    var left: Int
    var index = first
    while (index <= last) {
        tmpArray[index] = array[index]
        index++
    }
    index = first.also { left = it }
    var right = mid + 1
    while (left <= mid && right <= last && index <= last) {
        if (tmpArray[left] <= tmpArray[right]) {
            array[index] = tmpArray[left++]
        } else {
            array[index] = tmpArray[right++]
        }
        index++
    }
    while (left <= mid) array[index++] = tmpArray[left++]
    while (right <= last) array[index++] = tmpArray[right++]
}

image

3. NodeJS

开发工具:下载Visual Studio Code


function sort() {
  let array = [2, 1, 5, 4, 3]
  var first = 0
  var last = array.length - 1
  mergeSort(array,first, last)
}
function mergeSort(array,first, last) {
  if (first < last) {
    var mid = Math.floor((first + last) / 2)
    mergeSort(array,first, mid)
    mergeSort(array,mid + 1, last)
    binaryMerge(array,first, mid, last)
  }
}
function binaryMerge(array,first, mid, last) {
  var tmpArray = Array(array.length).fill(0)
  var left, right, index
  for (index = first; index <= last; index++) {
    tmpArray[index] = array[index]
  }
  index = first
  left = first
  right = mid + 1
  for (; left <= mid && right <= last && index <= last; index++) {
    if (tmpArray[left] <= tmpArray[right]) {
      array[index] = tmpArray[left++]
    } else {
      array[index] = tmpArray[right++]
    }
  }
  while (left <= mid) {
    array[index++] = tmpArray[left++]
  }
  while (right <= last) {
    array[index++] = tmpArray[right++]
  }
}

image

4. Php

开发工具:下载Visual Studio Code

 public function sort()
    {
        $array = [2, 1, 5, 4, 3];
        $start = 0;
        $end = count($array) - 1;
        $this->sortMe($array, $start, $end);
        return var_dump($array);
    }
    private function sortMe(&$arr, $start, $end)
    {
        if ($start < $end) {
            $mid = floor(($start + $end) / 2);
            $this->sortMe($arr, $start, $mid);
            $this->sortMe($arr, $mid + 1, $end);
            $this->mergeSort($arr, $start, $mid, $end);
        }
    }

    private function mergeSort(&$arr, $start, $mid, $end)
    {
        $i = $start;
        $j = $mid + 1;
        $tmp = [];
        while ($i <= $mid && $j <= $end) {
            if ($arr[$i] <= $arr[$j]) {
                $tmp[] = $arr[$i++];
            } else {
                $tmp[] = $arr[$j++];
            }
        }
        while ($i <= $mid) {
            $tmp[] = $arr[$i++];
        }
        while ($j <= $end) {
            $tmp[] = $arr[$j++];
        }
        for ($k = 0; $k < count($tmp); $k++) {
            $arr[$k + $start] = $tmp[$k];
        }
    }

image

5. Python

开发工具:下载PyCharm


array = [2, 1, 5, 4, 3]


def merge(left, mid, right):
    start = mid - left + 1
    end = right - mid

    left_arr = [0] * start
    right_arr = [0] * end

    for i in range(0, start):
        left_arr[i] = array[left + i]

    for j in range(0, end):
        right_arr[j] = array[mid + 1 + j]

    i = 0
    j = 0
    k = left

    while i < start and j < end:
        if left_arr[i] <= right_arr[j]:
            array[k] = left_arr[i]
            i += 1
        else:
            array[k] = right_arr[j]
            j += 1
        k += 1

    while i < start:
        array[k] = left_arr[i]
        i += 1
        k += 1

    while j < end:
        array[k] = right_arr[j]
        j += 1
        k += 1


def sort(left, right):
    if left < right:
        m = int((left + (right - 1)) / 2)

        sort(left, m)
        sort(m + 1, right)
        merge(left, m, right)

image

6. Swift(SwiftUI版)

开发工具:XCode(mac电脑自带)

var array = [2, 1, 5, 4, 3]
func sort() {
    sortMe(arr: &array, left: 0, right: array.count - 1)
}

func sortMe(arr:inout [Int],left:Int,right:Int) {
    if left == right {
        return
    }
    let mid = left + (right - left) >> 1
    sortMe(arr: &arr, left: left, right: mid)
    sortMe(arr: &arr, left: mid + 1, right: right)
    mergeSort(arr: &arr, left: left, mid: mid, right: right)
}

func mergeSort(arr:inout [Int],left:Int,mid:Int,right:Int){
    var tmpArr:[Int] = [Int]()
    var leftLocation:Int = left
    var rightLocation:Int = mid + 1
    
    while (leftLocation <= mid && rightLocation <= right) {
        if arr[leftLocation] <= arr[rightLocation] {
            tmpArr.append(arr[leftLocation])
            leftLocation += 1
        }else{
            tmpArr.append(arr[rightLocation])
            rightLocation += 1
        }
    }
    
    while leftLocation <= mid {
        tmpArr.append(arr[leftLocation])
        leftLocation += 1
    }
    while rightLocation <= right {
        tmpArr.append(arr[rightLocation])
        rightLocation += 1
    }
    var index = left
    for item in tmpArr {
        arr[index] = item
        index += 1
    }
}

image

7. uni-app

开发工具:下载HBuilderX

sort() {
	let array = [2, 1, 5, 4, 3]
	var first = 0
	var last = array.length - 1
	this.mergeSort(first, last)
	this.array = array
	this.arrayStr = this.convertToStr(array)
},
mergeSort(first: number, last: number) {
	if (first < last) {
		var mid = Math.floor((first + last) / 2)
		this.mergeSort(first, mid)
		this.mergeSort(mid + 1, last)
		this.binaryMerge(first, mid, last)
	}
},
binaryMerge(first: number, mid: number, last: number) {
	let array = this.array
	var tmpArray = Array(array.length).fill(0)
	var left: number, right: number, index: number
	for (index = first; index <= last; index++) {
		tmpArray[index] = array[index]
	}
	index = first
	left = first
	right = mid + 1
	for (; left <= mid && right <= last && index <= last; index++) {
		if (tmpArray[left] <= tmpArray[right]) {
			array[index] = tmpArray[left++]
		} else {
			array[index] = tmpArray[right++]
		}
	}
	while (left <= mid) {
		array[index++] = tmpArray[left++]
	}
	while (right <= last) {
		array[index++] = tmpArray[right++]
	}
},

image

8. vue

开发工具:下载Visual Studio Code

sort() {
      let array = [2, 1, 5, 4, 3]
      var first = 0
      var last = array.length - 1
      this.mergeSort(first, last)
      this.array = array
      this.arrayStr = this.convertToStr(array)
    },
    mergeSort(first: number, last: number) {
      if (first < last) {
        var mid = Math.floor((first + last) / 2)
        this.mergeSort(first, mid)
        this.mergeSort(mid + 1, last)
        this.binaryMerge(first, mid, last)
      }
    },
    binaryMerge(first: number, mid: number, last: number) {
      let array = this.array
      var tmpArray = Array(array.length).fill(0)
      var left: number, right: number, index: number
      for (index = first; index <= last; index++) {
        tmpArray[index] = array[index]
      }
      index = first
      left = first
      right = mid + 1
      for (; left <= mid && right <= last && index <= last; index++) {
        if (tmpArray[left] <= tmpArray[right]) {
          array[index] = tmpArray[left++]
        } else {
          array[index] = tmpArray[right++]
        }
      }
      while (left <= mid) {
        array[index++] = tmpArray[left++]
      }
      while (right <= last) {
        array[index++] = tmpArray[right++]
      }
    },

9. 微信小程序

开发工具:下载微信开发者工具

sort() {
    let array = [2, 1, 5, 4, 3]
    var first = 0
    var last = array.length - 1
    this.mergeSort(array, first, last)
  },
  mergeSort(array: number[], first: number, last: number) {
    if (first < last) {
      var mid = Math.floor((first + last) / 2)
      this.mergeSort(array, first, mid)
      this.mergeSort(array, mid + 1, last)
      this.binaryMerge(array, first, mid, last)
    }
  },
  binaryMerge(array: number[], first: number, mid: number, last: number) {
    var tmpArray = Array(array.length).fill(0)
    var left: number, right: number, index: number
    for (index = first; index <= last; index++) {
      tmpArray[index] = array[index]
    }
    index = first
    left = first
    right = mid + 1
    for (; left <= mid && right <= last && index <= last; index++) {
      if (tmpArray[left] <= tmpArray[right]) {
        array[index] = tmpArray[left++]
      } else {
        array[index] = tmpArray[right++]
      }
    }
    while (left <= mid) {
      array[index++] = tmpArray[left++]
    }
    while (right <= last) {
      array[index++] = tmpArray[right++]
    }
  },

image

10. 鸿蒙(ArkTS)

开发工具:下载DevEco Studio


  sort() {
    let array = [2, 1, 5, 4, 3]
    var first = 0
    var last = array.length - 1
  }

  mergeSort(first: number, last: number) {
    if (first < last) {
      var mid = Math.floor((first + last) / 2)
      this.mergeSort(first, mid)
      this.mergeSort(mid + 1, last)
      this.binaryMerge(first, mid, last)
    }
  }

  binaryMerge(first: number, mid: number, last: number) {
    let array = this.array
    var tmpArray = Array(array.length).fill(0)
    var left: number, right: number, index: number
    for (index = first; index <= last; index++) {
      tmpArray[index] = array[index]
    }
    index = first
    left = first
    right = mid + 1
    for (; left <= mid && right <= last && index <= last; index++) {
      if (tmpArray[left] <= tmpArray[right]) {
        array[index] = tmpArray[left++]
      } else {
        array[index] = tmpArray[right++]
      }
    }
    while (left <= mid) {
      array[index++] = tmpArray[left++]
    }
    while (right <= last) {
      array[index++] = tmpArray[right++]
    }
  }

image

11. Go语言

开发工具:下载Visual Studio Code


var array = []int{2, 1, 5, 4, 3}

func sort() {
	mergeSort(array, 0, len(array))
}

func mergeSort(array []int, begin int, end int) {
	if end-begin > 1 {
		mid := begin + (end-begin+1)/2
		mergeSort(array, begin, mid)
		mergeSort(array, mid, end)
		merge(array, begin, mid, end)
	}
}

func merge(array []int, begin int, mid int, end int) {
	leftSize := mid - begin
	rightSize := end - mid
	newSize := leftSize + rightSize
	result := make([]int, 0, newSize)

	left := 0
	right := 0
	for left < leftSize && right < rightSize {
		lValue := array[begin+left]
		rValue := array[mid+right]
		if lValue < rValue {
			result = append(result, lValue)
			left++
		} else {
			result = append(result, rValue)
			right++
		}
	}

	result = append(result, array[begin+left:mid]...)
	result = append(result, array[mid+right:end]...)

	for i := 0; i < newSize; i++ {
		array[begin+i] = result[i]
	}
}

image

12. Java

开发工具:下载IntelliJ IDEA

public static void sort(int[] array) {
        int first = 0;
        int last = array.length - 1;
        mergeSort(array, first, last);
    }

    private static void mergeSort(int[] array, int first, int last) {
        if (first < last) {
            int mid = (first + last) / 2;
            mergeSort(array, first, mid);
            mergeSort(array, mid + 1, last);
            binaryMerge(array, first, mid, last);
        }
    }

    public static void binaryMerge(int[] array, int first, int mid, int last) {
        int[] tmpArray = new int[array.length];
        int left, right, index;
        for (index = first; index <= last; index++) {
            tmpArray[index] = array[index];
        }
        index = first;
        left = first;
        right = mid + 1;
        for (; left <= mid && right <= last && index <= last; index++) {
            if (tmpArray[left] <= tmpArray[right]) {
                array[index] = tmpArray[left++];
            } else {
                array[index] = tmpArray[right++];
            }
        }
        while (left <= mid) {
            array[index++] = tmpArray[left++];
        }
        while (right <= last) {
            array[index++] = tmpArray[right++];
        }
    }

image

13. Kotlin

开发工具:下载IntelliJ IDEA


fun sort(array: IntArray) {
    val first = 0
    val last = array.size - 1
    mergeSort(array, first, last)
}

private fun mergeSort(array: IntArray, first: Int, last: Int) {
    if (first < last) {
        val mid = (first + last) / 2
        mergeSort(array, first, mid)
        mergeSort(array, mid + 1, last)
        binaryMerge(array, first, mid, last)
    }
}

fun binaryMerge(array: IntArray, first: Int, mid: Int, last: Int) {
    val tmpArray = IntArray(array.size)
    var left: Int
    var index = first
    while (index <= last) {
        tmpArray[index] = array[index]
        index++
    }
    index = first.also { left = it }
    var right = mid + 1
    while (left <= mid && right <= last && index <= last) {
        if (tmpArray[left] <= tmpArray[right]) {
            array[index] = tmpArray[left++]
        } else {
            array[index] = tmpArray[right++]
        }
        index++
    }
    while (left <= mid) array[index++] = tmpArray[left++]
    while (right <= last) array[index++] = tmpArray[right++]
}

image

14. Flutter

开发工具:下载IntelliJ IDEA


void sort(List<int> array) {
  var first = 0;
  var last = array.length - 1;
  mergeSort(array, first, last);
}

void mergeSort(List<int> array, int first, int last) {
  if (first < last) {
    int mid = (first + last) ~/ 2;
    mergeSort(array, first, mid);
    mergeSort(array, mid + 1, last);
    binaryMerge(array, first, mid, last);
  }
}

void binaryMerge(List<int> array, int first, int mid, int last) {
  var tmpArray = List.filled(array.length, 0);
  int left, right, index;
  for (index = first; index <= last; index++) {
    tmpArray[index] = array[index];
  }
  left = first;
  index = first;
  right = mid + 1;
  for (; left <= mid && right <= last && index <= last; index++) {
    if (tmpArray[left] <= tmpArray[right]) {
      array[index] = tmpArray[left++];
    } else {
      array[index] = tmpArray[right++];
    }
  }
  while (left <= mid) {
    array[index++] = tmpArray[left++];
  }
  while (right <= last) {
    array[index++] = tmpArray[right++];
  }
}

15. C语言

开发工具:下载Visual Studio


void mergeSort(int *a, int *tmp, int begin, int end)
{
	if (begin >= end)
		return; 
	int middle = (begin + end) / 2;
	int begin1 = begin;
	int end1 = middle;
	int begin2 = middle + 1;
	int end2 = end;
	mergeSort(a, tmp, begin1, end1);
	mergeSort(a, tmp, begin2, end2);

	int i = begin;
	while (begin1 <= end1 && begin2 <= end2)
	{
		if (a[begin1] <= a[begin2])
		{
			tmp[i++] = a[begin1++];
		}
		else
		{
			tmp[i++] = a[begin2++];
		}
	}
	while (begin1 <= end1)
	{
		tmp[i++] = a[begin1++];
	}
	while (begin2 <= end2)
	{
		tmp[i++] = a[begin2++];
	}
	memcpy(a + begin, tmp + begin, sizeof(int) * (end - begin + 1)); 
}

void sort(int *array, int n)
{
	int *tmp = (int *)malloc(sizeof(int) * n);
	mergeSort(array, tmp, 0, n - 1);
	free(tmp);
}

image

16. C++

开发工具:下载Visual Studio


void mergeSort(int arr[], int left, int mid, int right)
{
	int i = left;
	int j = mid + 1;
	int k = 0;
	int *tmp = new int[right - left + 1];
	while (i <= mid && j <= right)
	{
		if (arr[i] < arr[j])
			tmp[k++] = arr[i++];
		else
			tmp[k++] = arr[j++];
	}
	while (i <= mid)
	{
		tmp[k++] = arr[i++];
	}
	while (j <= right)
	{
		tmp[k++] = arr[j++];
	}
	for (i = 0; i < k; i++)
	{
		arr[left++] = tmp[i];
	}
	delete[] tmp;
}

void sort(int array[], int left, int right)
{
	if (left == right)
		return;
	int mid = (left + right) / 2;
	sort(array, left, mid);
	sort(array, mid + 1, right);
	mergeSort(array, left, mid, right);
}

image

17. C#

开发工具:下载Visual Studio

public static void Sort(int[] array)
        {
            int first = 0;
            int last = array.Length - 1;
            MergeSort(array, first, last);
        }

        private static void MergeSort(int[] array, int first, int last)
        {
            if (first < last)
            {
                int mid = (first + last) / 2;
                MergeSort(array, first, mid);
                MergeSort(array, mid + 1, last);
                BinaryMerge(array, first, mid, last);
            }

        }
        public static void BinaryMerge(int[] array, int first, int mid, int last)
        {
            int[] tmpArray = new int[array.Length];
            int left, right, index;
            for (index = first; index <= last; index++)
            {
                tmpArray[index] = array[index];
            }

            for (index = left = first, right = mid + 1; left <= mid && right <= last && index <= last; index++)
            {
                if (tmpArray[left] <= tmpArray[right]) { array[index] = tmpArray[left++]; }
                else { array[index] = tmpArray[right++]; }
            }
            while (left <= mid) array[index++] = tmpArray[left++];
            while (right <= last) array[index++] = tmpArray[right++];
        }

image

关于

厦门大学计算机专业|华为八年高级工程师
专注《零基础学编程系列》 http://lblbc.cn/blog
包含:Java | 安卓 | 前端 | Flutter | iOS | 小程序 | 鸿蒙
公众号:蓝不蓝编程

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/177697.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

分享139个ASP源码,总有一款适合您

ASP源码 分享139个ASP源码&#xff0c;总有一款适合您 下面是文件的名字&#xff0c;我放了一些图片&#xff0c;文章里不是所有的图主要是放不下...&#xff0c; 139个ASP源码下载链接&#xff1a;https://pan.baidu.com/s/1Vk4U4EXVCWZWPMWf9ax2dw?pwdif23 提取码&#x…

【C++】类和对象(上)---什么是类?

目录1.面向过程和面向对象初步认识2.类的引入2.1使用struct定义类3.类的定义3.1类的两种定义方式&#xff1a;3.2成员变量命名规则的建议3.3成员函数与成员变量定义的位置建议4.类的访问限定符及封装4.1访问限定符4.2封装5.类的作用域6.类的实例化7.类对象模型7.1如何计算类对象…

springboot静态资源目录访问,及自定义静态资源路径,index页面的访问

springboot静态资源目录访问&#xff0c;及自定义静态资源路径&#xff0c;index页面的访问静态资源目录的访问位置静态资源访问测试自定义静态资源路径和静态资源请求映射web首页的访问自定义静态资源请求映射影响index.html首页的访问的**解决方案**&#xff1a;1.取消自定义…

【JUC系列】CountDownLatch实现原理

简单示例 public class Main {private static final int NUM 3;public static void main(String[] args) throws InterruptedException {CountDownLatch latch new CountDownLatch(NUM);for (int i 0; i < NUM; i) {new Thread(() -> {try {Thread.sleep(2000);Syste…

梯度之上:Hessian 矩阵

原文链接&#xff1a;原文 文章目录梯度之上&#xff1a;Hessian 矩阵梯度、雅克比矩阵海森矩阵海森矩阵应用梯度之上&#xff1a;Hessian 矩阵 本文讨论研究梯度下降法的一个有力的数学工具&#xff1a;海森矩阵。在讨论海森矩阵之前&#xff0c;需要首先了解梯度和雅克比矩阵…

基础知识一览3

这里写目录标题1.Servlet1.1 入门1.2 什么是Servlet1.3 Servlet的作用1.4 Servlet生命周期1.5 Servler的体系结构1.6 Servler的两种配置方式2.Filter2.1 Filter拦截路径配置2.2 过滤器链2.2 入门2.3 过滤器链2.4 过滤器生命周期3.Listener3.1 监听器分类3.1.1 一类监听器4.Serv…

ESP32设备驱动-GA1A12S202光线传感器驱动

GA1A12S202光线传感器驱动 1、GA1A2S202介绍 GA1A1S202 对数刻度模拟光传感器使用起来非常简单,只需添加电源,然后监控模拟输出。大多数光传感器对光强度具有线性响应,这意味着它们对低光水平非常不敏感,然后在高光水平下达到最大值。另一方面,该传感器具有对数响应,这…

第九届蓝桥杯省赛 C++ B组 - 乘积最大

✍个人博客&#xff1a;https://blog.csdn.net/Newin2020?spm1011.2415.3001.5343 &#x1f4da;专栏地址&#xff1a;蓝桥杯题解集合 &#x1f4dd;原题地址&#xff1a;乘积最大 &#x1f4e3;专栏定位&#xff1a;为想参加蓝桥杯的小伙伴整理常考算法题解&#xff0c;祝大家…

Thread的join()方法的作用

文章目录官方文档对join()的解释&#xff1a;结合实例解释官方文档对join()的解释&#xff1a; Thread.join() method javadocs&#xff08;点击跳转&#xff09; join() Waits for this thread to die. 线程类的 join()方法将等待子线程完成&#xff0c;然后继续当前线程。j…

【Python】常见的时间操作(时间区间、时间相加减、指定年月天数等。。。

前言 记录在Python中使用的时间操作&#xff0c;方便以后查找。 在使用Python中&#xff0c;常会遇到关于时间的操作。 虽说每次都能借助搜索引擎找到解决的方法&#xff0c;但好记性不如烂笔头&#xff0c;遂有此文。 暂时记录了笔者所使用过的Python关于时间的操作&#xff0…

人世正道沧桑,她亦奋力向前 --读《李清照传》有感

有一次陪小孩晨读&#xff0c;朗诵诗歌&#xff0c;读到了李清照的《夏日绝句》&#xff1a;“生当作人杰&#xff0c;死亦为鬼雄。至今思项羽&#xff0c;不肯过江东”。这首诗是1129年&#xff0c;李清照在芜湖的乌江县触景生情&#xff0c;有感而作的。这首诗写得大气磅礴&a…

JQuery总结(一)

JQUERY概述&#xff1a; JQUERY和DOM相互转换&#xff1a; 基础选择器&#xff1a; 筛选选择器&#xff1a; show hide toggle方法 jQuery hover方法 jQuery stop()方法 例子&#xff1a;显示、隐藏、切换 button{/* 随着字体大小变化,button跟着变化大小 */font-size: 20px;ba…

【Git】国内代码托管中心码云(Gitee)

9、国内代码托管中心码云(Gitee) 9.1、简介 众所周知&#xff0c;GitHub 服务器在国外&#xff0c;使用 GitHub 作为项目托管网站&#xff0c;如果网速不好的话&#xff0c;严重影响使用体验&#xff0c;甚至会出现登录不上的情况。针对这个情况&#xff0c;大家也可以使用国…

边界框回归 Bounding-Box Regression

文章目录边界框回归&#xff08;Bounding-Box Regression&#xff09;一、边界框回归简介二、边界框回归细节三、相关问题思考1. 为什么使用相对坐标差?2. 为什么宽高比要取对数?3. 为什么IoU较大时边界框回归可视为线性变换&#xff1f;边界框回归&#xff08;Bounding-Box …

协调中心性能大对比:zookeeper是如何解决负载均衡问题的

作为分布式系统的一个长久话题&#xff0c;协调中心的性能是一个很有意思的突破口。 作为java的分布式协调中心&#xff0c;常见的有zookeeper&#xff0c;redis &#xff0c;memcache等全局性功能的组件&#xff0c;也有MySQL&#xff0c;mongoDB之类的数据库形持久存储。 两…

PyCharm无法打开,提示Internal error错误。

安装LeetCode插件后&#xff0c;重新打开PyCharm后&#xff0c;出现该错误。 删除安装目录下的 plugins 文件夹后&#xff0c;重新打开后&#xff0c;又出现该错误。 重新把回收站的文件夹恢复后&#xff0c;再次打开还是之前那个错误。 尝试了 cmd ,powershell&#xff0c;管…

Python Flask构建微信小程序订餐系统 (五)

🔥 微信小程序登录态 🔥 所谓登录态,就是程序在运行时,能够识别当前用户,能够证明自己的唯一性且合法。 WEB服务器通过浏览器携带的cookie获取session来判断是否是同一用户(或浏览器);Restful服务通过客户端传过来唯一ID,来识别调用用户。 维护登录态的原因 有自身…

行为型模式-模板方法模式

1.概述 在面向对象程序设计过程中&#xff0c;程序员常常会遇到这种情况&#xff1a;设计一个系统时知道了算法所需的关键步骤&#xff0c;而且确定了这些步骤的执行顺序&#xff0c;但某些步骤的具体实现还未知&#xff0c;或者说某些步骤的实现与具体的环境相关。 例如&…

机器学习(五):机器学习算法分类

文章目录 机器学习算法分类 一、监督学习 1、回归问题 2、分类问题 二、无监督学习 三、半监督学习 四、强化学习 机器学习算法分类 根据数据集组成不同&#xff0c;可以把机器学习算法分为&#xff1a; 监督学习无监督学习半监督学习强化学习一、监督学习 定义&…

Python初学者看过来啊,老油条来复习

嗨嗨嗨&#xff0c;我又又又又来了 目录 一、Python常用的基本语句 1、format字符串格式化 2、连接字符串 3、if...else条件语句 4、for...in、while循环语句 5、import导入 2.详细介绍 对于初学者来说&#xff0c;想要学好Python语言&#xff0c;必须从最基本的知识开…