java data structure

common data structures

Linear table (list)

  1. Ordered list, just like children queuing up (a team) to leave school after school, the order of insertion is the order of traversal, and the position remains unchanged (the length is fixed)

  2. Sequential storage: from the starting position, it is stored in sequence backwards, which is convenient for querying , but the efficiency of insertion (queuing and plugging) and deletion (queuing and fainting) is low, and the position is variable (variable length)

  3. Chained storage (linked list): store where there is a vacancy, and "chain" it up through the address , the query is troublesome (moving pointer addressing), but insertion and deletion are very efficient

hash table

Hash table (hash table, also called hash table) is a data structure that is directly accessed according to the key-value (Key-value). That is, it accesses records by mapping the key value to a location in the table to speed up lookups. (directory + linked list, like a dictionary)

tree (balanced binary tree)

A binary tree is an ordered tree with at most two subtrees per node. These two subtrees are divided into left and right, which are called "left subtree" and "right subtree" respectively.

A balanced binary tree means that the height difference between the left and right subtrees of the root node does not exceed 1, that is, the left and right are almost symmetrical. The value of all nodes in the left subtree is less than or equal to the value of its root node, and the value of all nodes in the right subtree is greater than or equal to the value of its root node.

Java Collections Framework


The java collection framework is divided into two major factions Collection and Map

Collection is divided into List (ordered and repeatable [the content of the collection can be the same and the insertion and query are consistent]) and Set (unordered and unique [the content of the collection cannot be the same and the insertion and query positions are not necessarily the same])

List has Vector, ArrayList, LinkedList first look at the difference between these three

Vector  features: ordered, dynamic and variable (the order of query and insertion of variable length of the collection is consistent) data is repeatable and relatively thread-safe (multi-threading) data structure belongs to sequential storage performance: add and delete Low efficiency (the entire subscript will move when adding and deleting, so the efficiency is low) but the query efficiency is high

ArrayList features: ordered, dynamic and variable (the length of the collection is consistent with the query and insertion order), the data is repeatable, the thread is not guaranteed to be safe, the data structure belongs to the sequential storage performance: the addition and deletion are inefficient (increase And when deleting, the entire subscript will move, so the efficiency is low) but the query efficiency is high

LinkedList  Features: Ordered, dynamic and variable (the order of query and insertion of a collection of variable length is consistent) data is repeatable, threads do not guarantee safe data structures belong to the linked list (that is, see the needle) Performance: add and delete High efficiency (where there is a place to store data, it is more efficient) but the query efficiency is low

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324688395&siteId=291194637