当前位置:网站首页>Lexicographic order -- full arrangement in bell sound
Lexicographic order -- full arrangement in bell sound
2022-06-30 07:41:00 【ASUKASS】
Write an algorithm to solve the problem of bell ringing by computer
It is known that there is 12 Oral chime , Knock randomly , So how many full permutations are there ?
We found that , You can add a shorter permutation to a highest order and move it to grow an element permutation .
So we think of recursion .
So how to arrange them all by computer ?
The dictionary order is adopted here .
Here we can find , According to the dictionary order , The last permutation should be 321, Scan from right to left , The number on the left should be strictly greater than that on the right .
1.
2. here 1 Than 3 Small , Therefore, the ratio suffix should be used ( The sequence after the descent point ) in 1 The smallest number of large , namely 2 And 1 swapping , At this time, the suffix is 31, Not the minimum suffix , therefore 31 Exchange for 213, And so on and so on , That is, you can get all the permutations .
sjt Algorithm
Define a new concept : Movable number
1. Point all numbers in the spread to the left .
2. The maximum movable number is successively exchanged with the adjacent number on the left until the end point , At the same time, one by one permutation is generated .
3. At this time, the maximum number cannot be moved , At this time, the maximum movable number is exchanged with the number of neighbors pointing to the direction , Then the direction of all the movable numbers is reversed .
4. At this time, the maximum movable number is transposed with the number pointing to the direction ...
...... You can get all the sequences by cycling .
Function implementation and call mode
边栏推荐
- Final review -php learning notes 5-php array
- PMIC power management
- 2021 China Enterprise Cloud index insight Report
- 342 maps covering exquisite knowledge, one of which is classic and pasted on the wall
- Introduction notes to pytorch deep learning (11) neural network pooling layer
- uniapp图片下方加标签标图片
- Program acceleration
- DXP software uses shortcut keys
- Adjacency matrix representation of weighted undirected graph (implemented in C language)
- How to quickly delete routing in Ad
猜你喜欢
深度学习——词汇表征
Binary tree related operations (based on recursion, implemented in C language)
Self study notes -- use of 74h573
Commands and permissions for directories and files
Network, network card and IP configuration
Network security and data in 2021: collection of new compliance review articles (215 pages)
right four steps of SEIF SLAM
Raspberry pie 4B Getting Started Guide
C language - student achievement management system
Three software installation methods
随机推荐
期末复习-PHP学习笔记4-PHP自定义函数
Sublime text 3 configuring the C language running environment
線程池——C語言
Projection point of point on line
Adjacency matrix representation of weighted undirected graph (implemented in C language)
DXP shortcut key
Xiashuo think tank: 28 updates of the planet reported today (including the information of flirting with girls and Han Tuo on Valentine's day)
Next initializesecuritycontext failed: unknown error (0x80092012) - the revocation function cannot check whether the certificate is revoked.
期末复习-PHP学习笔记11-PHP-PDO数据库抽象层.
uniapp图片下方加标签标图片
NMOS model selection
Program acceleration
Analysis of cross clock transmission in tinyriscv
Xiashuo think tank: 50 planet updates reported today (including the global architects Summit Series)
Final review -php learning notes 6- string processing
C language operators
November 22, 2021 [reading notes] - bioinformatics and functional genomics (Section 5 of Chapter 5 uses a comparison tool similar to blast to quickly search genomic DNA)
Arm debug interface (adiv5) analysis (I) introduction and implementation [continuous update]
2021 private equity fund market report (62 pages)
Processes, jobs, and services