Review and collation of data structure
Review data "Data structure and algorithm JavaScript description" People's post and telecommunications publishing house
The number of data structures and algorithms can never be too much.
1, array: a linear set of stored elements that can be arbitrarily accessed by an index, usually a number, to calculate the offset of the storage location between elements. In addition to the usual methods, several iterations have been added to ES5, ForEach (), every () some (), reduce (), map (), filter ().
2. List: A set of ordered data. The data items are called elements. The containing attribute/method has Listsize,pos (current position), Length,clear (), toString (), getelement () gets the current position of the element, insert (), append (), remove (), front (), End (), Prev () moves forward one bit, next (), Cuurpos () returns the current position of the list, MoveTo () moves to the current position. Features: The order in which the data is stored is not important and the data cannot be searched. These stacks can be implemented.
3. Stack stack: is a special list, only by adding or removing elements from the top of the stack, which belongs to the data structure of the last-in, first-out (LIFO last), similar to a stack of dishes in a restaurant, the two methods used by the stack are push () into the stack, pop () out of the stack, and peek ( ) is used to return the top element of the stack, and there should also be a top property to represent the storage location of the element to be inserted. Application: The conversion between the two-way (the remainder is stored in the stack, after storage, through pop () back to the top of the stack and delete, until all elements are taken), determine whether the string is a palindrome (put the string into the stack, then pop (), and then determine whether the same), simulation recursion (such as factorial problem, A number is reduced by the cycle and pushed into the stack, after which pop () is fetched and multiplied).
4 queue: Also belongs to a list, the queue can only insert elements at the end of the team, the first team to delete elements, similar to queuing. A queue is a first-in, first-out (FIFO) data structure that is commonly used by the queued push (), which is used to implement the cardinality sort (sorted by single digit and then by 10-digit number)
5. List LinkedList: A linked list consists of a set of nodes, each of which points to its successor using an object reference, which is the chain. To add a new node to a table, you need to modify the node in front of it, point it to itself, and then point to the node that the previous node originally pointed to, delete the node, simply point the previous node directly to the node behind the deleted node.
6. Dictionary dictionary: A data structure that stores data in key-value form.
7. Hash table Hashtable: The length of the array in the hash table is predetermined, and all elements are stored at a specific position in the array based on the key corresponding to the element. This key is mapped to a number, and the number range is 0-the length of the hash table. The length of the array in the hash table should be a prime number. Inserting delete and fetch arrays on a hash list is very fast, but finding data is slow, such as checking the maximum minimum value. Handling collisions is the focus.
8. Set set: is a set of unordered but has a certain correlation between the members of the composition, each member in the structure appears only once. Operations on a collection have a set, intersection, and complement.
9. Two fork tree: A tree is a non-linear data structure that stores data in a hierarchical manner. A binary tree is a special tree with no more than two child nodes. Binary search tree (BST) is a special two-fork tree, and relatively small values are saved in the left node, which makes the search efficient. There are three ways to traverse: First order, middle sequence and post order. The middle sequence is implemented using recursion, first accessing the left tree, accessing the root node, and then the right subtree. The first order is to access the root node first, and then access the Saozi right subtree in the same way. The first step is to iterate through the child nodes, from the left tree to the right subtree, and then to the root node.
10. Graph graph: This is really a bit difficult. Learn later in the finishing.
Data structure and algorithm review