[data structure] Java implementation of eight sorting algorithms

methodaverage timeWorst timeExtra spacestabilityBubble sortingO(n2)O(n2)O(1)stableSelect sortO(n2)O(n2)O(1)instableInsert sortO(n2)O(n2)O(1)stableCardinality sortO(d(n+r))O(d(n+r))O(d+r)stableShell Sort O(nlogn)O(n2)O(1)instableQuick sortO(nlogn)O(n2)O(nlogn)instableMerge sortO(nlogn)O(nlogn)O(1)stableHeap sortO(nlogn)O(nlogn)O(1)instable 1. In ...

Posted by souravsasi123 on Thu, 17 Feb 2022 18:28:20 +0100

Recursive maze eight queens

recursion Basic concepts Recursion means that the method calls itself, and different variables are passed in each call. Recursion helps solve more complex problems than that, while making the code simpler Call mechanism Analysis of printing problems: Recursive call rule: When the program executes a method, it will open up an independ ...

Posted by laurton on Thu, 17 Feb 2022 18:23:30 +0100

The third reason for the second kill algorithm interview question -- Analysis of the 240 phase of the weekly match of force deduction

Competition address: https://leetcode-cn.com/contest/weekly-contest-240 First of all, I wish you a happy mother's Day! Let's look at the question Question 1 subject Enter a two-dimensional integer array logs, where l o g ...

Posted by powah on Thu, 17 Feb 2022 11:58:19 +0100

Sort | quick sort

thought For each division, make the left side smaller than the benchmark and the right side larger than the benchmark, but in disorder, and then divide the left and right sides once again. In this way, the division will continue until the size of the decomposed array is 1 and the division stops. At this time, it is in order Partition function ...

Posted by varecha on Thu, 17 Feb 2022 10:19:44 +0100

Big factories knock on the door. Eight common sorting algorithms

1, Algorithmic mind map 2, Algorithm classification Time complexity and space complexity of the algorithm: 3, Bubble sorting 1. Basic thought Compare the two adjacent numbers in turn, and put the smaller number in the front and the larger number in the back. 2. Dynamic rendering 3. Code implementation //Bubble sorting private ...

Posted by drbigfresh on Thu, 17 Feb 2022 00:59:22 +0100

How is the condition in AQS implemented

Function of condition In fact, there are many usage scenarios of condition, which can be used in concurrent scenarios involving condition judgment, such as: Judge whether the queue is full or empty in the ArrayBlockingQueue of the blocking queueBlock and wake up all threads in CyclicBarrierJudgment of blocking access queue data in DelayQueueC ...

Posted by umguy on Wed, 16 Feb 2022 15:12:48 +0100

Algorithm data structure -- linked list -- copy linked list with random pointer

1 topic analysis Link: 138. Copy the linked list with random pointer - LeetCode (LeetCode CN. Com) Give you a linked list with a length of n. each node contains an additional random pointer random, which can point to any node or empty node in the linked list. Construct a deep copy of this linked list. The deep copy should consist of exac ...

Posted by hpg4815 on Wed, 16 Feb 2022 13:43:11 +0100

General code template for binary search problem

The idea of binary search is very simple, but there are many traps in the process of code writing. In particular, binary search has many variants, such as: Find the first element equal to the target value, and return None if it does not existFind the last element equal to the target value, and return None if it does not existFind the first ele ...

Posted by marcnyc on Wed, 16 Feb 2022 08:46:17 +0100

task 01 array -- datawhale and Tianchi

task 01 array - datawhale and Tianchi Example analysis 1. Sum of two numbers class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { int n = nums.size(); for (int i = 0 ; i < n - 1; ++ i) for (int j = i + 1; j < n ;++ j) { if (nums[i] + nu ...

Posted by FD_F on Tue, 15 Feb 2022 17:29:43 +0100

The beauty of data structure and algorithm -- review of queue

1. Course content For details, please refer to the course "beauty of data structure and algorithm" on "geek time": 09 | queue: application of queue in limited resource pools such as process pool (geekbang.org) 2. After class practice code Array queue package dataStruct; /** * @ClassName ArrayQueue * @Version 1. ...

Posted by mjurmann on Tue, 15 Feb 2022 15:02:38 +0100