Data structure and algorithm (ten algorithms commonly used by programmers: 1 ~ 5)
1: Binary search
Binary search algorithm (non recursive) Introduction
(1) Previously, we talked about the binary search algorithm, which uses the recursive method. Next, we will explain the non recursive method of the binary search algorithm
(2) The binary search method is only suitable for searching from an ordered sequence of numbers (suc ...
Added by BenMo on Tue, 28 Dec 2021 23:19:42 +0200
Algorithm notes - sorting algorithm
1, Time complexity
The number of constant operations to be performed by the algorithm according to the worst performance, leaving only the highest order term and removing the coefficients
2, Bubble sort, select sort, and insert sort
The three simplest sorting algorithms are time complexity O(N^2) and space complexity O(1)
Bubble sort:
publ ...
Added by jazzydog on Tue, 28 Dec 2021 23:06:46 +0200
Swipe questions and punch in every day on December 24, 2021
Swipe questions and punch in every day on December 24, 2021
Force deduction - one question per day
Sword finger Offer 36 Binary search tree and bidirectional linked list
Enter a binary search tree and convert the binary search tree into a sorted circular two-way linked list. It is required that no new node can be created, and only the node p ...
Added by ow-phil on Tue, 28 Dec 2021 21:04:58 +0200
The beauty of design patterns iterator pattern (middle): why can't you add or delete set elements while traversing the set?
The beauty of design patterns by Wang Zheng Study notes
What happens when you add or delete collection elements while traversing?
While traversing the collection elements through the iterator, adding or deleting the elements in the collection may lead to a certain element being traversed repeatedly or not being traversed.Unexpected behavior o ...
Added by djnrempel on Tue, 28 Dec 2021 15:52:06 +0200
Summary of classical algorithms
Binary search algorithm
You can use loops or recursion
Divide and conquer algorithm
Divide a complex problem into two or more identical or similar subproblems, and then divide the subproblem into smaller subproblems... Until the last subproblem can be simply solved directly, and the solution of the original problem is the combination of the ...
Added by MatrixDancer on Tue, 28 Dec 2021 12:59:18 +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
Segment tree / tree array: enemy array
Summary:
This problem mainly uses the single point modification of the line segment tree and the operation of interval summation.
Or use the interval summation operation of the tree array
Title Link: https://acm.hdu.edu.cn/showproblem.php?pid=1166
Title:
Problem Description
Country A, the sworn enemy of country C, is conducting ...
Added by cuvaibhav on Tue, 28 Dec 2021 05:46:29 +0200
Data structure array
Today, I start learning java data structure. Data structure, therefore, is a storage method of data. First, open the simplest data structure, array learning.
array
1. Understanding of array: an array is a collection of multiple data of the same type arranged in a certain order and named with a name,
These data are uniformly managed by number ...
Added by Namadoor on Tue, 28 Dec 2021 02:40:36 +0200
Simple sorting
Take a[5] as an example
a[5] = {9,6,15,4,2};
1. Simple Selection Sorting
Traversing through the array finds the minimum (or maximum) value of the array and places it at position 0. Then scratch off position 0, traverse through the remaining numbers to find the best value, and put it on position 1 of the array, and so on
Selecting the smallest ...
Added by galafura on Tue, 28 Dec 2021 01:52:43 +0200
0. Linear table stored sequentially
This column code has been tested on the ubutun system and the source code can perform the following commands to clone on the terminal
git clone https://github.com/celery1798/coder210714
1. Linear tables
Linear tables are the most basic, simple and common data structure. A linear table is a finite sequence of n data elements with the same ...
Added by kemu_ on Mon, 27 Dec 2021 23:15:13 +0200