JDK provides a set of major data structure implementations, such as list, MAP, set and other common data structures. This data is inherited from the Java.util.Collection interface and is located in the Java.util package.1. List interface
The three most important list interface implementations: ArrayList, Vector, Linked
) */private int nums;public triplenode[] GetData () {return data;} public void SetData (triplenode[] data) {This.data = Data;this.nums = Data.length;} public int getRows () {return rows;} public void setrows (int rows) {this.rows = rows;} public int Getcols () {return cols;} public void Setcols (int cols) {this.cols = cols;} public int getnums () {return nums;} p
See a topic on the Internet:Given a collection of strings, in the formof:. Requires merging a collection where the intersection is not empty, requiring no overlap between the completed collections, for example, the above example should be output.
(1) Please describe your idea of solving this problem;
(2) give the main processing flow, algorithm, and the complexity of the algorithm;
(3) Please describe the possible improvements.
One solution is to use and check the set, (the
(key);}4.3 Traversing the value of the HashMapThe first step: gets the collection of HashMap "values" based on value (). Step Two: iterate through the set of "first steps" through the iterator iterator. Assume that map is a HashMap object//The key in map is a string type, and value is an integer type integer value = null; Collection C = map.values (); Iterator iter= C.iterator (); while (Iter.hasnext ()) { value = (Integer) iter.next ();}The Traverse test program is as follows :View CodePart
: Network Disk DownloadThis book is a classical textbook of data structure and algorithm analysis in foreign countries, using excellent The Java programming language, as an implementation tool, discusses data structures (methods for organizing large amounts of data) and algo
Data | structure | Array I have not seen the data structures in other languages, but I think Java implementations are ingenious--with classes and objects. An array of tables, the idea is very simple is to define a class to store a set of data, I define the Arraylistclass cla
will use other methods to avoid, for example, only the node to delete the tag and not really deleteEfficiency of Ⅵ, red-HaishiSimilar to the general two-fork search tree, the red-Haishi lookup, the insertion deletion time complexity is O (log2n), the red-Haishi lookup time and the normal two-fork search tree lookup time almost exactly the same, the additional overhead is just storage space to increase the storage of a red-black color space.The time of insertion and deletion adds a constant fact
Summary
This article addresses http://blog.csdn.net/never_cxb/article/details/50211631
Recently to do a pen test questions Baidu has 20 arrays, each has 500 elements, ascending arrangement, find the first 500 of the number, review the heap sorting, summed up, with the implementation of the source code.
Heap Ordering (heapsort) is a sort algorithm designed by using the data structure of a stacked tree (heap
; - -stackNewStack(); + Stack.push (root); - +TreeNode prev =NULL; A while(!Stack.empty ()) { atTreeNode Curr =Stack.peek (); - - //go down the tree. - //Check if current node was leaf, if so, process it and pop stack, - //Otherwise, keep going down - if(prev = =NULL|| Prev.left = = Curr | | Prev.right = =Curr) { in //prev = = NULL is the situation for the root node - if(Curr.left! =NULL){ to Stack.pus
The following is a basic sorting algorithm in 7 of the data structures implemented in Java code:(1) Direct Insert sort/** Direct Insert Sort **//** array is a reference type, element value will be changed **/public static void Insertsort (int[] table) {/** n-1 scan **/for (int i = 1; i (2) Hill Sort(3) Bubble sort(4) Quick Sort(5) Direct Select sort(6) Heap sorting(7) Merge sortJava code Implementation of
1. As one of Java's most common data structures, the use of arrays is relatively simple, showing the number of comparisons that are commonly used by arrays in cases where duplicate values are allowed and not allowed2. After the encapsulated code:1 PackageCom.cn.higharray;2 /**3 * Further encapsulation of the array, more convenient to call.4 * @authorAdministrator5 *6 */7 Public classHigharray {8 Private Long[] A;9 Private intNelems;Ten PublicHig
1. BackgroundFor example, an integer x is a set of numbers in a sequence of columns sorted by size, and we want to find the index position of x in the sequence.For example, the sequence is arranged from small to large:-3,-2,0,4,5,7,12,64We want to find the position of the number 7, if it is a linear lookup, the time complexity is O (n), if you find with binary, the time complexity is O (log (n)), because each time the binary, the calculation of less than half, so take the logarithm.2. CodePackag
Thought:assuming the initial sequence rightNRecords, the first of theseNa record asNordered subsequence, each sub-sequence has a length of1, and then 22 merge, GetN/2Rounding upa length of2(Nis odd, the length of the last sequence is1) ordered sub-sequences. On this basis, the length of the2the ordered sub-sequences of 22 are merged to get several lengths of4ordered sub-sequences. So repeat until you get a length ofNordered sequence. Stability: StableCalculation of time complexity:
The
maximum of 2k-1 nodes (k≥1).Property 3 In any-tree binary tree, if the number of terminal nodes is N0, the degree of 2 of the node is N2, then no=n2+1.Property 4 The depth of a complete binary tree with N nodes isProperty 5 If the nodes of a complete binary tree with n nodes are numbered in sequence, any node I (1 2i> N, the node I have no left child, otherwise its left child is node 2i;3 if 2i+1>n, then node I no right child, otherwise the right child is node 2i+1;
The adjacency matrix implementation diagram uses a matrix to subscript the matrix as a vertex if there is an edge between the vertex and the vertex. Then set the value to 1 on the point at which the matrix corresponds. (Default is 0) Packagemygraph;Importjava.util.List;/*** adjacency Matrix representation graph *@authorRanter **/ Public classVertex {Private Charlable;//Matrix Element Private int[] List =New int[20] [20]; Private Char[] Vertexlist =New Char[20]; Private intNverts;//Current v
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.