当前位置:网站首页>With notes: insert sort --from WCC
With notes: insert sort --from WCC
2022-06-28 23:47:00 【Run Coder】
Insertion sort
Insertion sort ( insertion sorting) It is an algorithm that sorts data from the left end of the sequence . During sorting , The data on the left is coming back , What's left on the right is the data that hasn't been sorted yet . The idea of insertion sort is to take out a data from the unsorted area on the right , Then insert it in the right place in the sorted area .
Ideas :
1. The default from the i = 1 Start judging , such preIndex Nature is the cursor of the internal loop ;
2.current preservation arr[i], Determine by cycling current The final position of ;
3. At the beginning of each internal cycle ,arr[i] === current === arr[preIndex + 1], So for the first time in the inner cycle arr[preIndex + 1] = arr[preIndex] You don't have to worry about arr[i] The value of is missing ;
4. The general idea is , The elements that need to be ranked are cached first , Then apply the internal circulation , So that the element to be adjusted is assigned to a position behind it , Form and move in turn ,
Finally, because the inner loop stops when the judgment condition does not take effect, it means that the correct position of the element to be ranked is found , Then assign the value , To complete the order
The greatest thing about human beings is that they can always think of ways to solve problems --wcc
边栏推荐
- 随笔记:重新认识 else if
- 好用免费的PPT模板
- PHP 使用endroid/qrcode 二维码生成, GD库生成分享海报
- ERROR 1067 (42000): Invalid default value for ‘end_ time‘ Mysql
- MSCI 2022 market classification assessment
- Have you ever met a fake interview in a job interview? How to avoid?
- stm32F407-------串行(串口)通信
- ES6模块
- 《英语语法新思维 基础版2》读书笔记(一)
- Chapter III processor scheduling exercise
猜你喜欢

VSCode里使用条件断点(基于GDB)

Yyds dry goods inventory building knowledge map from scratch with neo4j (I)

Finally, someone explained the cloud native architecture

Stm32f407 ------ clock system (systeminit clock initialization, systick tick timer)

Windows10 phpstudy installing redis extension

What are the virtual machine software? What are their respective roles?

Huawei's level 22 experts have worked hard for ten years to complete the advanced practical document of cloud native service grid. 6

三個pwn題

Stm32f407-------- NVIC interrupt priority management

stm32F407-------跑马灯、蜂鸣器
随机推荐
Huawei's level 22 experts have worked hard for ten years to complete the advanced practical document of cloud native service grid. 6
Mobile heterogeneous computing technology - GPU OpenCL programming (basic)
Would like to ask, how to open a stock account? Is it safe to open an account online?
Yyds dry goods inventory building knowledge map from scratch with neo4j (I)
Three communication skills in software testing
Form verification problem - El select (solution to automatically trigger verification on initialization page)
【狀態機設計】Moore、Mealy狀態機、三段式、二段式、一段式狀態機書寫規範
Is it reliable and safe to avoid five in case of stock trading account opening
Have you ever met a fake interview in a job interview? How to avoid?
TypeScript -- 第七节 枚举
Yyds dry goods count 【 vs code work record III 】 set vs code format
华为22级专家十年心血终成云原生服务网格进阶实战文档,是真的6
Blue Bridge Cup top ten common heaven level skill - breath of water The type of one recursion
Chapter II Classic synchronous exercises
What pitfalls should be avoided in the job interview for the operation post in 2022?
Online yaml to JSON tool
[Electronic Experiment 2] simple electronic doorbell
[machine learning] numerical analysis 02 -- finding roots of arbitrary equations
scrapy保存数据到excel:利用openpyxl创建多张表,设置Excel行数限制
stm32F407-------外部中断