Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What exchange sort are there?

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

What sort of swaps are there? In response to this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more small partners who want to solve this problem find a simpler and easier way.

Bubble sort is a relatively simple sort algorithm in computer science with time complexity of O(N2), while Quick sort is an improvement on bubble sort with time complexity of O(Nlog2N).

exchange sort

bubble sort

Bubble Sort is a relatively simple sorting algorithm in computer science.

When sorting a sequence with N elements, N-1 cycles are performed. in that kth cycle, compare the elements from the 1st to the N-k th from front to back, compare two adjacent elements each time, if the former element is larger than the lat element, then the two elements exchange positions, otherwise the positions remain unchanged

Time complexity: O(N2)

quick sort

Quicksort is an improvement on bubble sort.

The unsorted elements are divided into two sub-sequences according to a "principal element" as a reference, wherein the records of one sub-sequence are all larger than the principal element and the records of the other sub-sequence are all smaller than the principal element, and then the two sub-sequences are sorted recursively in a similar way.

Time complexity: O(Nlog2N)

The answers to the exchange sorting questions are shared here. I hope the above content can be helpful to everyone. If you still have a lot of doubts, you can pay attention to the industry information channel to learn more about relevant knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report