Data structure and algorithmic basics points
Linked list
1. A linked list is a linear set of data composed of nodes, each pointing to the next node through a pointer. It is a data structure that is composed of nodes and can be used to represent sequences.
2. Single linked list: Each node points to the next node only, and the last node points to an empty
3, double linked list: Each node has two pointer p,n. P points to the previous node,n refers to the next node , and the last node points to null.
4. Loop list: Each node points to the next node, and the last node points to the first node.
5. time Complexity: index:o (n), find:o (n), insert:o(1), delete: O ( 1 )
Stack
1, Stack is a collection of elements, supports two basic operations:push is used to press elements into the stack,pop is used to delete the top element of the stack.
2. Last-in, first-out data structure
3. Time complexity: Ibid.
Queue
1. The queue is a collection of elements that supports two basic operations: Enqueue is used to add an element to a queue, dequeue is used to delete
2, first-out data structure
3. Time complexity: Ibid.
Tree
1, the tree is a non-circular map of the Unicom
2, Binary tree: is a tree-shaped data structure, each node can have a maximum of two child nodes, called Left Dial hand node and right child node.
3, full two fork tree: two fork tree each node has 0 or 2 child nodes.
4, Perfect binary tree: two fork tree each node has two sub-nodes, and all the leaf node depth is the same
5, complete binary tree; In addition to the last layer in the binary tree, the nodes of each layer reach the maximum, and the last layer of nodes is continuously concentrated on the leftmost.
Binary search Tree
1, is a binary tree, any node is greater than or equal to the value in the left subtree, less than or equal to the value in the right subtree.
2. time Complexity: Index Lookup Insert Delete is O(log (n))
Dictionary Tree
1, also known as a radix tree or a prefix tree, is a lookup tree used to store a dynamic or associative array of key values as strings. The node in the tree does not store the associated key value directly, but the node's position in the tree determines its associated key value, and all child nodes of a node have the same prefix, and the root node is an empty string.
Array of numbers
1, also known as the binary index tree, which is conceptually a tree, but implemented in an array, the subscript in the array represents the nodes in the tree, and the subscript of the parent or child node of each node can be obtained by operation. Each element in the array contains the sum of the pre-computed interval values, which are also updated during the entire tree update process.
2. time Complexity: Interval summation:o(log (n)), update:o(log (n ))
Segment Tree
1. The segment tree is a tree-shaped data structure for storing intervals and segments. It allows you to find the number of occurrences of a node in several segments.
2. Time complexity: Ibid.
Heap
1, Heap is a tree-based data structure that satisfies certain characteristics, and the key values of all parent-child nodes in the whole heap satisfy the same ordering criteria. The heap is divided into the largest heap and the smallest heap. In the maximum heap, the key value of the parent node is always greater than the key value of all child nodes, and the key value of the root node is the largest. In the smallest heap, the key value of the parent node is always less than the child node key value, and the key value of the root node is minimal.
2. time Complexity: Index lookup Insert Delete: ditto, delete max min:O(1)
Hash
1. Hashes are used to map data of any length to fixed-length data. The return value of a hash function is called a hash value hash code or hash. If a different primary key gets the same hash value, a conflict occurs.
2. Hash map:hashmap is a data structure that stores key-value relationships, andhashmap converts the key value into a bucket or subscript in a slot by hashing the function , This makes it easy to specify a value for the lookup.
3, conflict resolution: Chain Address Method: In the chain address method, each bucket is independent of each other, each index corresponds to a meta-element list. the time to process HashMap is the sum of the time it takes to find the bucket and the time to traverse the list element.
Open address Law: In open Address law, when inserting a new value, it will determine if the value corresponding to the hash bucket exists, if any, then select the next possible address according to an algorithm, until an unoccupied address is found. An open address that is the location of an element is not always determined by its hash value.
Figure
1, the figure is an ordered pair of g= (V,e) , which includes the vertex or node set V and the edge or arc set e, where e Packet consists of two elements from V .
2. graph: The adjacency matrix of the graph is symmetric, so if there is a node u to the edge of node v , that node v to The edge of the node u must also exist.
3, the graph: the adjacency matrix of the graph is asymmetric, so if there is ... Does not necessarily exist ...
Data structure and algorithmic basics points