Insert sort

Insert sort directly: Algorithm idea: 1. The array is divided into two parts: ordered part and unordered part 2. Divide the initial data into ordered parts and unordered parts. In each step, insert the data of an unordered part into the ordered part that has been arranged previously And so on until all elements are sorted Average time complexit ...

Added by hhoeksma on Sun, 06 Mar 2022 13:59:05 +0200

bubbleSort

Algorithm idea: Starting from the first element, compare the values of two adjacent elements in pairs, and put the larger one behind (from small to large) Average time complexity: O(n2) Worst time complexity: O(n2) Optimal time complexity: O(n) Space complexity: 1 Stability: unstable Suitable for scene: few elements Code implementation: Mode 1 ...

Added by blacksnday on Sat, 05 Mar 2022 10:59:02 +0200

Chapter 5 sorting and paging

1, Sort 1.1 sorting rules Sort using ORDER BY clause ASC (ascend): ascendingDESC (descend): descending order The ORDER BY clause is at the end of the SELECT statement 1.2 single column sorting Example 1: mysql> SELECT last_name, job_id, department_id, hire_date FROM employees ORDER BY hire_date; +-------------+------------+------- ...

Added by w3evolutions on Mon, 28 Feb 2022 14:30:46 +0200

In-depth Analysis of Data Structure and Algorithms Solving Ideas and Examples of Alphabetic Word Grouping

1. Title requirements You will be given an array of strings, which you can return in any order by combining heterographic words.Alphabetic words are new words that result from rearranging the letters of the source word, and the letters in all source words are usually used exactly once.Example 1: input: strs = ["eat", "tea", "tan", "ate", "nat ...

Added by iamtom on Sat, 05 Feb 2022 19:14:15 +0200

[winter vacation daily question] luogu P1781 president of the universe

Title Link: P1781 president of the universe - Luogu | new ecology of Computer Science Education (luogu.com.cn) Title Description In the earth calendar year 6036, the whole universe is ready to run for the president of the most talented person. There are n extraordinary top-notch people running for the president. Now the votes have been counte ...

Added by phpion on Thu, 27 Jan 2022 04:34:39 +0200

Data structure -- LeetCode special exercise Day3

350. Intersection of two arrays II Given two arrays, write a function to calculate their intersection. Example 1: Input: nums1 = [1,2,2,1], nums2 = [2,2] Output: [2,2] Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] Output: [4,9]   explain: The number of occurrences of each element in the output result shall be consistent with the m ...

Added by LoStEdeN on Fri, 31 Dec 2021 03:22:10 +0200

Classic internal sort summary

Sorting algorithm directory Direct insert sortBinary Insertion Sort Shell Sort Bubble sortingQuick sortSelect sortMerge sortHeap sort 1. Insert sorting directly Direct insert sort Algorithmic thought Divide the sequence into ordered part and unordered part, select the elements from the unordered part, compare with the ordered part, fin ...

Added by burzvingion on Tue, 28 Dec 2021 06:17:09 +0200

Super detailed Java implementation of bubble sort, selection sort and insertion sort [super easy to understand] ❀❀❀

Bubble sorting Step analysis and introduction As can be seen from the figure below, when comparing two adjacent elements, the large number will move backward (how to move it later?), so after each comparison, a larger number will be placed at the end, and the last number does not need to be compared, that is, after each comparison, the ...

Added by fibonacci on Sat, 18 Dec 2021 23:03:06 +0200

Luogu P1068 [NOIP2009 popularity group] score line delineation [simulation - sorting]

Title Description The selection of Expo volunteers is in full swing in city A. In order to select the most suitable talents, city a has conducted a written test for all the applicants. Only those whose written test scores reach the interview score line can enter the interview. The interview score line is defined according to 150 \% of the plan ...

Added by Undrium on Sun, 05 Dec 2021 11:04:22 +0200

2021.12.03 leetcode daily question - maximized array sum after K negations

catalogue Maximized array sum after K negations describe Example 1 Example 2 Example 3 Tips Method 1: violence ranking Method 2: modify negative numbers Method 3: sorting improvement Maximized array sum after K negations describe Give you an integer array nums and an integer k. modify the array as follows: Select a subscript I & ...

Added by Uranium-235 on Fri, 03 Dec 2021 08:11:51 +0200