node of the K node represented by biggerindex+1 existsif (biggerindexLastIndex) {//If the value of the right child node is largeif (data[biggerindex]]){//Biggerindex always records the index of a larger child node biggerindex++; } }//If the value of the K-node is less than the value of its larger child nodesif (data[k]Data[biggerindex]) {//Exchange them swap (data,k,biggerindex); // give the Biggerindex to K, start the next loop of the while loop, Re-guarantee that the value of the K-node is gr
) {Result=New Long[n]; for(inti = 1;i ) Result[i]= Integer.max_value;//the distance from the initialization of the No. 0 vertex to the other vertices is infinity, which is represented by an integer maximum value. for(inti = 1;i ) { for(intj = 0;j ) { if(result[a[j].b] > RESULT[A[J].A] +a[j].value) result[a[j].b]= Result[a[j].a] +A[j].value; } } BooleanJudge =true; for(inti = 1;i //determine if a negative ring exists in a given graph i
Java language implementation of the α-β pruning algorithm (very practical), C language pruning algorithm wuziqi
Use the α-β pruning algorithm to search for the game tree shown in, search for the node to be selected for the root node, and find the node that does not need to be evaluated, and find out where the pruning o
Full version of MD5 Encryption Algorithm in Java, javamd5 Encryption Algorithm
Some data is inevitably encrypted during Java software development. Therefore, Java provides its own MessageDigest to implement text encryption algorithms, the following is an example of the MD5 e
First, describeThis paper analyzes and compares the binary search algorithm of JDK and the common binary search algorithm written by itself, uses bits unsigned right shift to replace the 2 operation, and uses the method of generating random number to produce a range of random number array, and calls the sort () static method of the arrays class to sort the array of int type.math.random () Usage: Generates a
; Array lengthInt J; The position of the current value is 5 for the initial positionint i; Position in front of J is the position of 3 for the initial point.int key; The current value for the insertion sort is 5 for the initialThe insertion is traversed from the second position of the array, that is, it is compared to the first value of the array, and the first value is moved backward if it is smaller than the first one.for (j=1;jKEY=A[J]; The first time is to assign a value of 5 to key, and the
Sophomore next semester Applied Cryptography Course Design synchronized GitHub project: Url:https://github.com/ericli404/java-demos/tree/master/des-demo Git:https://github.com/ericli404/java-demos.git
Implementation of the DES algorithm, the specific output of each step are recorded, did not join the working mode, supporting the encryption input for the English a
The idea of odd-even ordering is to repeat the two-pass scan in the array. The first scan selects all data item pairs, A[j] and a[j+1],j are odd (J=1, 3, 5 ...). If the values of their keywords are reversed, they are exchanged. The second scan makes the same operation for all even-numbered data items (j=2, 4,6 ...). Repeat this two-pass order until the array is all in order. Public Static voidOddevensort (int[] arr) { intLen =arr.length; intGroupnumber = (int) Math.ceil (Doubl
One: Shorten the string according to a certain rule/* * Shorten string */public class Dome07 {public static void main (string[] args) {string str = "According to the rules C:\\windows\\resources\\themes \\aero ";" while (true) {System.out.println (str); int endIndex = Str.lastindexof ("\ \");//intercept string str = str.substring (0, EndIndex); The range of the//substring (start,end) method: [Start,end] if (str.indexof ("\ \") = =-1) {System.out.println (str); return;// Exit Program}}}}Two: Coun
Today, I sorted out the vampire digital algorithm and adjusted some of it. I saw another one on the Internet, but I didn't understand it. He improved the performance by 10 times.
First look at the code I have compiled
Import Java. util. arrays;
Running result
1st groups: 15*93 = 13952nd groups: 21*60 = 1260Group 3rd: 21*87 = 18274th groups: 27*81 = 21875th groups: 30*51 = 15306th groups: 35*41 = 14357t
The fast sorting algorithm belongs to the sort of "exchange class", and its efficiency is mainly related to the symmetry of data distribution.Sort Ascending:/** * Quick Sort * ascending sort * * @Overridepublic Sort Descending:/** * Quick Sort * descending sort * * * @Overridepublic A sort algorithm of data structure Java implementation (4)--Fast sorting
Directory
1 Problem Description
2 Solutions
1 problem description Problem Descriptiongenerates a random integer of n ∈[a,b], outputting the probability of their and x. Input Formatenter four integers on a line, followed by N,a,b,x, separated by a space. output FormatThe output line contains a decimal place and a probability of x, leaving four decimal places after the decimal pointSample Input2 1 3 4Sample Output0.3333data size and conventionsfor 50% of data, n≤5.for 100% of data, n≤
[index] >value) {End
= index-1;
} else {
start = index+1;
}
}
return number;
}The binary lookup premise is that the array is already ordered. The first index is written as end and start subtraction, resulting in a dead loop. Actually want to be added. 1,2,3,6,7. index=2,value=7,3 is less than 7,start=3, then index wants the middle number between 3 and 4, so it is added and divided by 2,6 less than 7,start=4,find to 7.
My Java development and learning journey ------) Java classic Sorting Algorithm merging and sortingI. Merge SortingMerge Sorting is an effective Sorting Algorithm Based on merge operations. This algorithm is a typical application of Divide and Conquer. Merges ordered subsequ
[Algorithm Data Structure Java Implementation] Java implements Dynamic Planning (Knapsack Problem) and data structure java1. The background follows the footsteps of buptwusuopu, who has recently studied dynamic planning. Dynamic Planning should be called a solution to the problem. Remember to be asked again when I went to a company for an interview. More than the
Package Net.qh.test.sort;import java.util.arraylist;import java.util.list;/** * Created by Administrator on 2016/03/07. */public class Radix {public static int[] ASC (int[] array) {int index = 1;/** maximum number of digits (for example, 100 is 3 digits, 2000 is 4 digits) */ /** gets the maximum number of digits */for (int i = 0; i Java cardinality sorting algorithm based on sorting
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.