small to largeThe following are a few common sorting algorithms:
##1. Bubble sort
1. ** Principle **
- It repeatedly visited the sequence to be sorted, comparing two adjacent elements each time, and if the order was wrong (such as the larger element being before the smaller element), it would swap them.
- He repeated the process of searching the sequence until there were no more elements that needed to be exchanged. At that time, the sequence was completed.
2. ** Instance **
- Suppose there is a sequence [5, 3, 4, 6, 2].
- The first round of comparison: first compare 5 and 3, because 5 > 3, the exchange is [3, 5, 4, 6, 2]; then compare 5 and 4, 5 > 4, the exchange is [3, 4, 5, 6, 2]; then compare 5 and 6, no exchange; then compare 6 and 2, 6 > 2, the exchange is [3, 4, 5, 2, 6].
- The second round of comparison: starting from 3, compare 3 and 4 without swapping; compare 4 and 5 without swapping; compare 5 and 2, 5 > 2, swap to get [3, 4, 2, 5, 6].
- The third round of comparison: compare 3 and 4 without swapping; compare 4 and 2, 4 > 2, swap to get [3, 2, 4, 5, 6].
- The fourth round of comparison: compare 3 and 2, 3 > 2, swap to get [2, 3, 4, 5, 6]. At this moment, the sequence was completed.
##2. Sorting
1. ** Principle **
- Its basic idea was to select a certain element from the data to be sorted according to the specified rules, and then exchange the positions according to the rules to achieve the purpose of sorting.
- The first time, the minimum value was selected from the entire array and exchanged with the first element of the array; the second time, the minimum value was selected from the remaining elements (except for the first element that had been sorted) and exchanged with the second element of the array; and so on.
2. ** Instance **
- For the sequence [5, 3, 4, 6, 2].
- First round: First assume that 5 is the smallest value, then compare it with the following elements and find that 2 is the smallest. Exchange 2 and 5 to get [2, 3, 4, 6, 5].
- The second round: Start from 3. Assuming that 3 is the smallest value, compare it with the later ones and find that 3 is the smallest. Without swapping, the sequence is still [2, 3, 4, 6, 5].
- The third round: Start from 4. Assuming that 4 is the smallest value, compare it with the later ones and find that 4 is the smallest. Without swapping, the sequence is still [2, 3, 4, 6, 5].
- The fourth round: Starting from 6, assuming that 6 is the smallest value, compare it with the later ones and find that 5 is the smallest. Exchange 5 and 6 to get [2, 3, 4, 5, 6].
##3. Heap Sorting
1. ** Principle **
- First of all, he had to understand the concept of a heap. A heap had the properties of a complete tree. If the value of each node is less than or equal to the value of its children, it is called a small top heap.
- The basic idea of heap sorting was to construct the sequence to be sorted into a small top heap. At this time, the minimum value of the entire sequence was the root node at the top of the heap. If it was exchanged with the last element, the last element would be the minimum value. Then, the remaining n - 1 elements were reconstructed into a heap, which would get the second smallest value of n elements. Repeating this process would result in an orderly sequence.
2. ** An example (simple)**
- Suppose there is a sequence [5, 3, 4, 6, 2].
- First, construct it into a small top heap (the detailed steps are omitted here) to obtain a small top heap structure. The top heap element of 2 is the minimum value.
- Exchange 2 with the last element 6 to get [6, 3, 4, 2, 5], then rebuild the top heap of the sequence except for the last element 6, and continue this process until the sequence is orderly.
##4. Counting Sorts (applicable to a certain range of numbers)
1. ** Principle **
- This was a sorting algorithm that was not based on comparison.
- When sorting a certain range of numbers, its complexity is O (n + k)(where k is the range of numbers). It counted the number of times each number appeared in the sequence, and then according to the results of the statistics, the numbers were output in order to achieve sorting.
2. ** example (Assuming the range of the whole number is 0 - 9)**
- For the sequence [5, 3, 4, 6, 2].
- First, count the number of times each number appears. For example, 2 appears once, 3 appears once, 4 appears once, 5 appears once, and 6 appears once.
- Then, in the order of 0 - 9, the elements in the sequence were output according to the statistics, and [2, 3, 4, 5, 6] was obtained.
A small story made up of a large number of shotsIn the world of film and television, a failed scene was like an unexpected interlude. It was also very interesting to weave them into a story.
Take 'The Story of Roses', for example. That was really the " gathering place " for those who were exposed. There was a romantic date, and the male lead was about to confess to the female lead. The scene was set in a beautiful sea of flowers, but not far away, a staff member carrying music equipment entered the scene. It was like a small stone suddenly thrown into a calm lake, instantly breaking the romantic atmosphere. The audience was stunned, and there was a heated discussion online. Some people ridiculed the staff member, and some questioned the editor. And this wasn't the only flaw. In the ancient setting, the actors had modern phones in their hands. In the ancient banquet scene, the actors showed jeans and sneakers, and the props were taped together. In the urban street chase scene, the pedestrians in the background inexplicably decreased or even disappeared when the main character ran. The document in the main character's hand suddenly increased by a few pages when the scene changed, the color of the clothes inadvertently changed, the main character's position in the office scene suddenly changed, and the clock showed that the time did not match the plot time.
" Celebrating Years " had a similar situation. The netizens watched the drama as if they were holding an 8x scope. Comparing Fan Xian five years ago and now, all kinds of illogical things were discovered, like a flash of black shadow in a dense forest. There were also modern items appearing in ancient dramas. Everyone also ridiculed these exposed scenes.
In " The Selection of the Heavens," Lu Han and Gulnaza had a scene where they kept laughing. Yuan Quan walked into the office. The young man inside was playing cards. In Princess Huanzhu, a modern item like an iron appeared. In the ancient drama, two ancient uncles were plotting in the grass, but there was a white plastic bottle behind them. In Yang Mi's costume drama, transparent shoulder straps could be seen.
The old version of Journey to the West also had problems with being exposed. In Che Chiguo's episode, Sun Wukong asked Tang Sanzang to guess that the palace clothes that the empress had originally put on the screen were a big bell. After the broadcast, the audience pointed out that the "bell" in the original work was a cloak. Although the clothes scene was re-shot later, the lines of Zhu Bajie were forgotten.
The story formed by these scenes reflected the complexity and difficulty of the film and television production process. At the same time, it also brought a different kind of " fun " to the audience.
<a href="/?from=ask_words" style="color:red" target="_blank">Read more exciting novels for free</a>
A small story of a sea of peopleHere are a few stories about the sea of people:
- There was a movie called " A Sea of People " directed by Cai Shangjun, with Chen Jianbin, Tao Hong, and Wu Xiubo as the main actors. The story was adapted from a real social news event that happened in the mountainous area of Guizhou in southwest China. It told the story of the five brothers chasing after the murderer after the sixth brother was robbed and killed. The film had its world premiere at the 2011 Venice International Film Festival and was released in the mainland of China on August 3, 2012.
- In a folk story, Ma Dafu, the landlord of the Ma Village, asked his son Ma Yu to follow the butler Wang Cheng to collect rent, but Ma Yu went to propose marriage and was rejected. Ma Dafu personally brought Ma Yu and the betrothal gift to the Zhang family to propose marriage, but because the Zhang family wanted to recruit a son-in-law, the talks collapsed, and Ma Yu fell ill. With this story in mind, one could imagine the Ma Village being crowded with people during some seasons such as the autumn harvest. For example, when the housekeeper brought the servants to collect rent, many tenants would come to pay the rent. It would be a crowded scene.
- In the modern life scene, when the founder of Zhulin Town, Secretary Zhao Mingen, gave his blessings to the 100-year-old tourists who came to Longevity Mountain for the Double Ninth Festival, the scene was crowded and lively.
The story of one person and a group of people is equally exciting. Everyone is welcome to click and read it!