Take you in-depth understanding of merging and sorting

Merge sort 🎈🎆🎇 preface: 1, Priority queue heap PriorityQueue 2, Deep understanding of fast scheduling and optimization The number of times that merge sort is often tested in the eight sorts can be said to be among the best, and its status is also very high, which can not be ignored. In the sort of quick sort, merge sort and heap s ...

Posted by Froy on Thu, 11 Nov 2021 02:11:57 -0800

Solution of Dutch flag problem: additional space complexity O, time complexity O(N)

Dutch National Flag Problem         a. Given a sequence arr and a number num, put > num on the right of the array and < = num on the left of the array         b. Given a sequence arr and a number num, put > num on the right of the array, < num on the left of the array, and equal in the midd ...

Posted by Paddy on Thu, 11 Nov 2021 00:30:36 -0800

Introduction to algorithms Chapter 2 fundamentals of algorithms (insertion sort, merge sort, complexity calculation)

(recently, I was studying the book introduction to algorithms. Before, I liked to write notes by hand, but then I found that I always lost my notes, so I planned to make an electronic version of notes)   (in addition, pseudo code is used in the book, and python code is used in the notes if you need to try.) 2.1 insert sort     &nb ...

Posted by josephman1988 on Thu, 11 Nov 2021 00:06:14 -0800

2021 Niuke winter vacation algorithm basic training camp 1D parallel search set inverse element combinatorial mathematics two-dimensional grid to one-dimensional precautions

subject Problem solving ideas Firstly, the idea of two-dimensional to one-dimensional is discussed. Convert each point to abscissa multiplied by N + ordinate. It seems that it can be realized, but this problem needs four points, so 3 and 4 are implicitly connected. So it will be Wa. When we first increase N by 1, each available XY will not ...

Posted by Bloodwine on Wed, 10 Nov 2021 20:13:54 -0800

Top ten sorting algorithms (fast sorting, merging, heap sorting and direct insertion) - Java implementation

Bubble sorting Start from the first element of the sequence to be sorted, constantly compare the values of adjacent elements, exchange if it is found that the reverse order, and gradually move the elements with larger values from front to back. Every time the maximum value of the sequence to be sorted is found, the maximum value is fi ...

Posted by almightyegg on Wed, 10 Nov 2021 20:12:43 -0800

LeetCode brush notes linked list traversal linked list

160 intersecting linked list Given two linked lists, judge whether they intersect at a point, and find the intersection node. The input is two linked lists and the output is one node. If there are no intersecting nodes, an empty node is returned. Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,0,1,8,4,5], skipA = 2, skipB = 3 Out ...

Posted by suvarthi on Wed, 10 Nov 2021 19:12:06 -0800

Notes on basic course of acwing algorithm

Chapter III Search and Graph Theory 1. Depth-first search (dfs) Search down from start to finish, find the bottom and backtrace down to finish, use stack to store data, have two concepts of backtrace and pruning, do not have the shortest Array Array (Violent Search, Full Array) To restore the state to its original state after backtracking ...

Posted by darkerstar on Wed, 10 Nov 2021 15:05:55 -0800

Java array (multidimensional, Arrys, sorted, sparse)

Array overviewArray declaration creationArray usageMultidimensional arrayArrays classSparse array Definition of array An array is an ordered collection of data of the same typeArray describes several data of the same type, which are arranged and combined in a certain orderEach data is called an array unit, and each array element can access ...

Posted by kb0000 on Wed, 10 Nov 2021 12:39:37 -0800

Introduction to algorithm C-206. Reverse linked list

LeetCode problem brushing - algorithm learning plan (Introduction) Title Description Introduction of ideas If the linked list is bidirectional, reversing the linked list is very simple. You only need to exchange the forward pointer and backward pointer. But now the topic specifies a single linked list, how to reverse it? In fact ...

Posted by lordshoa on Wed, 10 Nov 2021 09:14:53 -0800

In Java, HashSet should override the equals method and hashCode method

When adding objects using HashSet in Java programming, the equals method and hashCode method must be rewritten because they must comply with the characteristics of Set (no order and no repetition). First: The Set set has no order and cannot be repeated. Why: simulate a collection of reality. The repetition here is only the repetition of the ...

Posted by eflopez on Wed, 10 Nov 2021 08:15:51 -0800