Want to know data structures abstraction and design using java? we have a huge selection of data structures abstraction and design using java information on alibabacloud.com
Common data Structures in JavaCommon data structures are hash tables, linear lists, linked lists, and java.util packages with three important interfaces: List,set,map commonly used to implement basic data structuresHow the HashMap worksHashMap based on the hashing principle,
;importorg.junit.before;importorg.junit.test; importcom.xingej.algorithm.datastructure.array.myarray;/*** Object-Oriented programming,** That is, the you operate is an object, not a basic data type *** @author erjun2017 November 28 Afternoon 9:59:36*/publicclassmyarraytest{privatemyarray myarray; @Before publicvoidinit () { myarray=newmyarray (); testinsert ();}// Insert data test @Test publicvoidtest (
This article does not speak of technology, the time to talk about the technology and popular there is a strange relationship between the driving force to learn something.1) technology and popularThe University of the Min data structure is not thick, rich content, but the complexity of the explanation of the problem is less, more difficult to understand, C is not very good, but the basic ideas are still there.Simple list of lists, arrays, stacks, queue
The enumeration (enumeration) interface, although not part of the data structure itself, is widely used in other data structure categories. The enumeration (the enumeration) interface defines a way to retrieve contiguous elements from a data structure.For example, an enumeration defines a method called Nextelement, which is used to get the next element of a
Java data structures and algorithms (iii) -- simple sorting
Data alone is not enough. Data presentation often needs to be arranged in a certain order. The higher the requirement, the more complicated the sorting. This article only introduces three simple sorting types.
1) B
; 1){ - if(Peoples[index]) { incount++; - if(Count = = 3){ toPeoples[index] =false; +Count=0; -leftcount--;//minus 1 for the rest of the population. the } * } $ Panax Notoginseng //put the element under the label -index++; the + //If you have counted to the end of the array, start the number A if(Index > Len-1){ theindex = 0; + } - } $ $ for(i
List operation code is small but more error-prone, is more suitable for the interview place.
Code implementation
/** * Source Name: Mylinklist.java * Date: 2014-09-05 * program function: Java list operation * Copyright: [emailprotected] * A2bgeek */import Java.util.Sta Ck;public class Mylinklist {class Linknode"Data structures and Algorithms"
In actual programming, we often need to temporarily store data to implement a specific function. In pure C language, we need to implement a data structure (such as a linked list or Queue) to access elements, which is not only tedious, and the efficiency is not high (the encapsulation of the data structure by the class library is often optimized and has good perfo
List interface, repeatable, ordered. List has ArrayList, because is the array structure, is suitable for the data query, LinkedList, because is the chain list structure, is suitable for uses in the deletion operation. If the array of additions and deletions, need to follow the elements are moving forward or backward, if the first element to make additions and deletions, the following elements move is very large, inefficient. Linked list If you do a qu
This article is about the search for ordered tables, which mainly includes the optimization usage of sequential lookups, binary lookups, interpolation lookups, Fibonacci lookups;Sequential Optimization Search : The efficiency is very low, but the algorithm is simple, suitable for small data search;Binary lookup : Also known as a binary lookup, it is searched from the middle of the lookup table. Finding results requires only half of the
Stacks and queuesStack (last in, first out)Stack, which allows access to only one data item: The last inserted data item.Stacks can be used to check the matching problems of parentheses and parse mathematical expressions, similar to those used in the compilation principle.The operation of the picture is actually summed up: 1. Read the left delimiter into the stack, 2. The right delimiter is read to match th
) + (N-2) +...+1 = N (N-1)/2When the value of N is very large, the algorithm compares the number of N2/2 times, ignoring minus 1.Assuming that the data is random, it is possible to swap locations each time, possibly without swapping, assuming a probability of 50%, then the number of interchanges is N2/4. However, if the worst-case scenario is that the initial data is reversed, the position is swapped for ea
} the } + } - classdolinkedlist{ $ PrivateLinkedlistLinkedList; $ Publicdolinkedlist () { - This. LinkedList =NewLinkedlist(); - } the Public voidAddele (String str) { - Wuyi Linkedlist.add (str); the } - PublicString Getele () { Wu returnLinkedlist.removefirst (); - } About Public Booleanisemp () { $ returnlinkedlist.isempty (); - - } -}A simple small program, the package is not very good, written in
Chapter 6 of Robert lafore, Java data structures and algorithms
/* 6.1 assume that you have bought a cheap handheld computer, but find that its built-in chip cannot be used for multiplication and can only be used for addition. To get rid of this dilemma, you need to write your own program, write a recursive method mult (), and its parameter number is X and the re
(e e);//replace element in collection * "9" void Add (e e);//At the previous position of the current index or the current Adds a new element to the collection at the back of the index position. *//whether or not to add new elements before or after the current index position depends on whether you are traversing sequentially or in reverse order * If it is {@link#next}, insert at the previous position of the current position *//if it is {@link#previous} to inser
1. Bubble Sort: Time complexity is O (n2)The hypothesis is a small to large sort: a comparison between two adjacent numbers, and a larger number at the back. The largest number in the last row after a comparisonsuch as: 40, 8, 15, 18, 121 times after the order is: 8, 15, 18, 12, 40 in turn until from small to big pat good for (int i = 0;i ) { for (int j = 0;j n-1-i;j++) {//The last few are already lined up There is no need to sort the if(A[j] > a[j+1]) { k= a[j] ; = A
Stack top element public class stackelementTool Stack class:public class seqstackOperation Result:Shortcomings, please correct me.Implementation of the stack of data Structures (JAVA) (i)
]; while (end>start) { while (end>startarrys[key)//If there is nothing smaller than the key value, compare next until there is a smaller swap position than the key value, And then compare it back to the past End--; if (arrys[end]) { arrys[end]; arrys[arrys[start]; arrys[tmp; } while (end>startarrys[start]) Start+ +; if (arrys[key) {
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.