Algorithms-Meanings of mathematical terms and mathematical terms in discrete mathematics, and answers to discrete mathematics and Algorithms
Here we will introduce two important functions in discrete mathematics: The base function and the top function. Make x a real number. The base function rounds x to an integer smaller than or equal to x and closest to x, while the top function rounds x to an integer gr
Quick sorting (Quick sort)Start by selecting one of the data (usually the first number of the array) as the key data, and then putting all the smaller numbers in front of it, all the larger numbers are placed behind it, this process is called a quick sort.The array is split into two arrays and then the remaining two arrays are sorted, so the loop is done until one element is left.Import Time,randomimport copydef Cal_time (func): #该装饰器用来测量函数运行的时间 def wrapper (*args,**kwargs): T1 = Tim E.time () r
15 is:27-15=12 (15>12) 15-12=3 (12>3)12-3=9 (9>3) 9-3=6 (6>3)6-3=3 (3==3)Therefore, 3 is the greatest common divisor#include ⑶ Poor Lifting methodThere are two integers a and B:①i=1② If a, B can be divisible by I at the same time, then t=i③i++④ If I ⑤ If i > A (or b), then T is greatest common divisor, endingImproved:①i= A (or b)② If a, B can be divisible by I at the same time, then I is greatest common divisor,End③i--, go back and run ②.There are two integers a and B:①i=1② If a, B can be divis
;3)12-3=9 (9>3) 9-3=6 (6>3)6-3=3 (3==3)Therefore, 3 is the greatest common divisor#include ⑶ Poor Lifting methodThere are two integers a and B:①i=1② If a, B can be divisible by I at the same time, then t=i③i++④ If I ⑤ If i > A (or b), then T is greatest common divisor, endingImproved:①i= A (or b)② If a, B can be divisible by I at the same time, then I is greatest common divisor,End③i--, go back and run ②.There are two integers a and B:①i=1② If a, B can be divisible by I at the same time, then t=
Method One: Incremental construction methodUnderstanding recursion has to understand what a function does.#include { printf ("{"); for (int i=0;i, A[i]); printf ("}\n"); int mi=cur?a[cur-1]+1:0; Use dictionary order to avoid duplicate printing for (int i=mi;i { a[cur]= }}int main () {int n; int a[ 10]={}; scanf ("%d",N); Print_subset (n,a,0);//initially a subset of 0 elements is stored in a, starting to recursively print return 0;} Method Two: Bit vector methodEnumer
Liu zitao
Here we mainly introduce a method to prove that the greedy algorithm is the best: Exchange Argument (I do not know how to translate it to Chinese and Exchange parameters? It sounds awkward, not like the name of a method ~ O (Clerk □clerk) o)
The main idea of Exchange Argument is to assume that an optimal algorithm is the closest to our greedy algorithm, and then Exchange one step (or element) of the two algorithms ), A new optimal algorithm
When I was in elementary school, I learned the ball's volume formula V = (4/3) π R weight. At that time, I thought it was amazing, is it possible for someone who has obtained this formula to melt an iron into molten metal and put it in a rectangular container? It wasn't until I went to school that I realized that I had used points for calculation. Of course, the calculus may hate more than love for many students, including me, however, it is undeniable that points play an irreplaceable role in a
trees in the forest, figure 6.22 (d) There is only one tree in the forest, and this tree is the husky tree. I may ask whether the length of the weighted path is unique in the Heman tree composed of N leaves? It is unique. Is the tree unique? Not unique. This is because when we merge the two sub-trees with the minimum and minimum weights in the forest, it is not strictly limited to the left sub-tree and the right sub-tree. The practice in Figure 6.22 is to treat the left subtree with a smaller w
Basic sorting (5): Summary of basic sorting algorithms and summary of sorting algorithmsBasic sorting
If a basic sorting algorithm is slower than data processing, such as reading and reading data, there is no need to find a faster algorithm.
If the sorted files are suitable for storing in memory, the sorting method is called"Internal sorting"; Sorting files from a disk is called"External sorting".DifferencesInternal sorting can easily access any el
SymmetricAlgorithmUsed in combination with asymmetric algorithms, such:
The sender has a public key and the receiver has a private key.
1. Sender:
First, the sender generates a random symmetric key, encrypts the data with the symmetric key, and puts it in a digital envelope. Then, the sender uses the public key to package the random symmetric key, put it in a digital envelope, and finally transmits the digital envelope to the receiver.
2 "receiv
Chapter 2-Introduction to Algorithms
Summary: This chapter describes the examples of insertion sorting and algorithm analysis, proof of non-variant loops, combined sorting (divide and conquer), and algorithm analysis.
1. Insert sorting
Similar to the playing card insertion process, set a [1... j-1] is an array of sorted order, insert a [J] into a [1... in J-1], making a [J] an array of sorted orders, j
Algorithm Analysis: In the best case, the ent
behind socks.
2,Theorem:Directed Graph G has no loop. If the directed graph G does not have a reverse edge.
3. Theorem: the topological-sort (g) algorithm can generate topological sorting for directed acyclic graph G.
5. Strongly Connected branches
1. In a directed graph, if any two different points are reachable, the directed graph is strongly connected. A strongly connected subgraph of a directed graph is calledStrongly Connected branches.
2. Many algor
/**************************************************************************************************************
File Description: "1" internal sort: refers to in the sort period of the elements are stored in memory of the sort "2" external sort: refers to in the sort of the elements can not be stored in memory at the same time, must be in the process of ordering, as required, constantly moving between the inside and outside the
The stability of the sort "3" Sorting algorithm
Chapter 2 Basic Search Algorithms
Data search is a basic computer programming task and has been studied for many years. This chapter only studies one aspect of finding a problem-finding a given value in the list (array.
There are two basic methods to search data in the list: sequential search and binary search. The ordered search applies when the items in the list are randomly arranged. The binary search applies to the sorted list.
Sequential search
Direct insertion of sorting algorithms and direct insertion of sorting algorithmsInsert the sorting definition directly:Each time the first element is extracted from the unordered table, it is inserted to the proper position of the ordered table, so that the ordered table is still ordered. Directly inserted sorting is a stable sorting. The worst time complexity is O (n ^ 2), and the space complexity is O (1 ).
Class Program {static void Main (string [
I. Summary
Definition:
Ii. Code
# Include
Iii. Exercise 22.5-1
Unchanged or reduced
22.5-2
First DFS result:
R u q t y x z s v w
G transpose result:Q: YR: S: Q wt: Qu: RV: SW: q vx: t zy: r t uz: X result of the second DFS: ruq y TX Zs W v 22.5-3 error. See the 2nd floor. 22.5-5 Introduction to Algorithms
22.5-5 O (V + E) Find the branch graph of the directed graph 22.5-6 to be solved. The question doesn't quite understand. I found an answer online,
Js implements various common sorting algorithms and js sorting algorithms1. Bubble Sorting
var bubbleSort = function (arr) { var flag = true; var len = arr.length; for (var i = 0; i 2. Select sort
var selectSort = function (arr) { var min; for (var i = 0; i 3. Insert sorting
var insertSort = function (arr) { var len = arr.length, key; for (var i = 1; i 4. Hill sorting
var shellSort = function (arr) { var gaps = [5, 3, 1]; for (var g = 0; g 5.
Simple comparison of sorting algorithms
1. Stability Comparison
Insertion sorting, Bubble sorting, binary tree sorting, two-way merge sorting, and other linear sorting are stable.
Selecting sorting (from the code point of view, there is a location replacement), Hill sorting, fast sorting, and heap sorting are unstable.
2. Comparison of time complexity
Insert sorting, Bubble sorting, and select the time complexity of sorting as O (n2)
The time complex
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.