常见排序算法
下面的这些排序算法可以在leetcode 912. Sort an Array练习
Prerequisites
排序算法的稳定性:
数值相同的元素在排序前后相对位置不变,则称算法稳定。如果只是针对数值类型,谈论稳定性没有意义,稳定性针对有对个属性的对象类型而言。
基于比较的排序算法
基础排序算法
冒泡排序
1234567891011void bubbleSort(vector<int>& nums) { int N = nums.size(); for (int i = 0; i < N - 1; i++) { for (int j = 1; j < N - i; j++) { if (nums[j - 1] > nums[j]) { swap(nums[j - 1], nums[j]); } } }}
优化思路:如果在某一轮扫描中,没有发生元素交换, ...
博客搭建
Prerequisites
工具安装
安装npm
安装hexo
1npm install install hexo-cli -g #全局安装
仓库搭建
创建github仓库
仓库的格式必须为:<username>.github.io
配置免密连接github
生成ssh密钥
1ssh-keygen -t ed25519 -f github_id_ed25519 -C "github"
复制公钥到github中
1xclip -sel clip < ~/.ssh/xxx.pub
测试连接
1ssh -T git@github.com
如果在生成ssh密钥那一步生成的文件名不是默认的,在测试连接的时候可能会出错,这其中牵扯到openssh中ssh连接时的一些原理,这里不细将,感兴趣的小伙伴可以查看相关资料,通常我的解决办法是使用「~/.ssh/config」文件来管理所有的ssh连接。
12345Host github.com Hostname github.com User git preferredA ...
使用busybox制作rootfs
Prerequisites
Download busybox and linux kernel source code.
Create some necessary directories.
123mkdir initrdcd initrdmkdir {proc,sys,etc}
Create init file.
12345#!/bin/shmount -t proc proc /procmount -t sysfs sysfs /sysmknod /dev/ttyS0 c 4 64setsid sh -c 'exec sh </dev/ttyS0 >/dev/ttyS0 2>&1'
Don’t forget to make init executable
Compile linux kernel
Here, I use default configuraton file, you can tweak it with gui through make menuconfig or manually ...