当前位置:网站首页>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
边栏推荐
- What will be done after digital IC Verification?
- Thinking about lever
- ERROR 1067 (42000): Invalid default value for ‘end_ time‘ Mysql
- Form verification problem - El select (solution to automatically trigger verification on initialization page)
- 随笔记:定义setter和getter的三种方式
- 【狀態機設計】Moore、Mealy狀態機、三段式、二段式、一段式狀態機書寫規範
- The second session of question swiping and clock out activity -- solving the switching problem with recursion as the background (2)
- Implementation of dynamic timer for quartz
- Basic operation of MySQL database: import hellodb SQL and query as required; Create account and authorize
- The secondary market is full of bad news. How should the market go next? One article will show you the general trend
猜你喜欢

好用免费的PPT模板

Stm32f407 ------- RTC real time clock

Stm32f407 ------- GPIO input experiment

stm32F407-------外部中断

Analysis of CSRF Cross Site Request Forgery vulnerability

The second session of question swiping and clock out activity -- solving the switching problem with recursion as the background (III)

Mobile heterogeneous computing technology - GPU OpenCL programming (basic)

stm32F407-------寄存器地址名称映射分析

The second session of question swiping and clock out activity -- solving the switching problem with recursion as the background (2)

PHP uses endroid/qrcode QR code to generate, and Gd library generates sharing posters
随机推荐
SQL note 2 [MySQL]
stm32F407-------LCD
Edge extraction based on Halcon learning [2] circles Hdev routine
Design e-commerce seckill system
Solve the problem of Chinese parsing by configparser
Stm32f407 ------- RTC real time clock
Machine learning 6-decision tree
百度知道爬虫,根据问题id,线索id,评论id获取评论下面的对话
【狀態機設計】Moore、Mealy狀態機、三段式、二段式、一段式狀態機書寫規範
ROS2中的行为树 BehaviorTree
window10 phpstudy 安装redis扩展
[opencv] - linear filtering: box filtering, mean filtering, Gaussian filtering
IO playback function of FIO
10. Standard i/o redirection and pipeline
VSCode里使用条件断点(基于GDB)
Is it safe and reliable to open a securities account in Yixue school?
Stm32f407-------- NVIC interrupt priority management
Windows10 phpstudy installing redis extension
PHP函数file_get_contents与操作系统的内存映射
PHP 使用endroid/qrcode 二维码生成, GD库生成分享海报