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
Vector implements a dynamic array. is an array of objects that can be automatically grown.Comparison of vectors and ArrayList:1, all in an array format to store data, index data block insert data slow2, ArrayList will be faster than vector, he is non-synchronous3, involving multi-threading, vector is a better synchronizationUsage:1. Constructor:1) Construction me
always increased. D. Sometimes the insertion time is reduced. Solution: Repeat may complicate the search algorithm: even if the last data item is matched, it must continue searching for possible matches until the last data item. 4. Random: When you look for a data item not in the array from an unordered array, it is usually faster than finding a
Array Advantages: Fast query, if you know the index can quickly access the disadvantage: Delete slow, size fixed ordered array advantages: Faster than unordered array lookup disadvantage: Delete and insert slow, size fixed stack advantages: Provide last-in-first-out access method disadvantage: Access to other items is slow queue advantages: Provide first-in-out access method disadvantage: access to other The items are slow. List Advantages: Quick Insert, delete fast disadvantage: find slow (each
more additions and deletions: LinkedList104 query MORE: ArrayList the I don't know, just use ArrayList.106 I don't know, just use ArrayList.107 108 3: Common methods of collection and Traverse mode 109 Collection: the Add ()111 Remove () the contains ()113 iterator () the size () the the Traversal: 117 Enhanced for118 iterators119 -|--List121 get ()122 123 Traversal:124 General for the|--Set126 127 Map: - put ()129 Remove () the Con
Stack implementation of data structures (JAVA) (I)
// Stack top element public class StackElement
{Private StackElement
NextElement; private T data; public StackElement (T data) {this. data =
//Delete a node in a binary sort tree the PublicBstree Deletebstree (Bstree bstree,intkey) { the if(Bstree = =NULL) { - return NULL; - } the the if(Bstree.data = =key) { the //first case: leaf node the if(Bstree.left = =NULL Bstree.right = =NULL) { -Bstree =NULL; the } the //second case: node has left dial hand nodes. the if(Bstree.left! =NULL Bstree.right = =NULL) {94Bstree =Bstree.left; t
Stackelement see the implementation of the stackPackage Com.lip.datastruture.stack;public class QueueOperation Result:Implementation of the queue of data structures (JAVA)
' (', directly into the stack, if ') ', out of the stack and sequential output operator until the first ' (', the first encountered ' ('), but not the output, if the arithmetic character, the top element of the stack and the current element precedence: If the top of the stack operator precedence >= the current element priority , out of the stack and sequential output operator until the top element of the stack priority 5, repeat the 3rd until the expression scan is complete.6, sequentially out
("Lookup data does not exist"); the return NULL; the } + -System.out.println ("Find successful, data is:" + This. list[p]); the return This. list[p];Bayi } the the //Sequential Table Size - Public intSizeOf () { - return This. Listlen; the } the the Public voidPrint () { theSystem.out.print ("["); - for(inti = 0; I This. list.length;
)
Unordered array Delete (query + fill hole)
O (N)
Ordered array deletion (query + fill hole)
O (N)
Why not use data to solve everythingAn unordered array is inserted (O (1) time), and the query spends (O (N) time). An ordered array query spends (O (logn) time), but inserts a missing cost (O (N) time). And the deletion takes (O (N) time). So a data structur
limited to a given size. So far, you've seen through the implementation of the queue that using the offer or Add method Enqueue queue (with remove or poll to dequeue queue) is assumed that if the queue does not provide add or remove operations, then you do not have to wait for the program to execute. The Java.util.concurrent.BlockingQueue interface implements blocking. It adds a put and take method. It may be more useful to cite an example.Use the or
Content:(1) Data type(2) operator(3) Branching structure1. Data type Basic data types in the Java language: Byte, short, int, long, float, double, Boolean, Char.1.1 Boolean type The types of false and true information described in the Java language are: Boolean.There are o
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.