MindMap Gallery Data structure course framework
I reviewed the map created by the data structure. I hope it can help everyone~ It summarizes in detail the knowledge content of the data structure search, graph, tree, sorting, and linear table test points.
Edited at 2021-12-10 20:35:35One Hundred Years of Solitude is the masterpiece of Gabriel Garcia Marquez. Reading this book begins with making sense of the characters' relationships, which are centered on the Buendía family and tells the story of the family's prosperity and decline, internal relationships and political struggles, self-mixing and rebirth over the course of a hundred years.
One Hundred Years of Solitude is the masterpiece of Gabriel Garcia Marquez. Reading this book begins with making sense of the characters' relationships, which are centered on the Buendía family and tells the story of the family's prosperity and decline, internal relationships and political struggles, self-mixing and rebirth over the course of a hundred years.
Project management is the process of applying specialized knowledge, skills, tools, and methods to project activities so that the project can achieve or exceed the set needs and expectations within the constraints of limited resources. This diagram provides a comprehensive overview of the 8 components of the project management process and can be used as a generic template for direct application.
One Hundred Years of Solitude is the masterpiece of Gabriel Garcia Marquez. Reading this book begins with making sense of the characters' relationships, which are centered on the Buendía family and tells the story of the family's prosperity and decline, internal relationships and political struggles, self-mixing and rebirth over the course of a hundred years.
One Hundred Years of Solitude is the masterpiece of Gabriel Garcia Marquez. Reading this book begins with making sense of the characters' relationships, which are centered on the Buendía family and tells the story of the family's prosperity and decline, internal relationships and political struggles, self-mixing and rebirth over the course of a hundred years.
Project management is the process of applying specialized knowledge, skills, tools, and methods to project activities so that the project can achieve or exceed the set needs and expectations within the constraints of limited resources. This diagram provides a comprehensive overview of the 8 components of the project management process and can be used as a generic template for direct application.
Data structure review
linear table
Linear storage
merge
Pay attention to the final judgment of whether the two tables are empty or not.
Find
time complexity:
insert
time complexity:
delete
time complexity:
Application of linear tables - in-place inversion
Continuously swap the front and last elements of a linear list
chain storage
Insertion into singly linked list
Pay attention to the order of the code
Deletion of singly linked list
Pay attention to the code order
In-place inversion of singly linked list
Constantly doing head deletion, head insertion
Single circular linked list
Doubly linked list
stacks and queues
stack
The stack is a special linear list (first in, last out, last in, first out)
An empty stack cannot be taken out, and a full stack cannot be entered.
The stack is implemented with a linear table. The top pointer (actually a number) of the stack is -1, which means an empty stack, and top=MAX-1, which means a full stack.
When the stack is full, it becomes an overflow; when the stack is empty, it becomes an underflow.
queue
The queue can only be deleted at the front of the queue (front) and can only be inserted at the rear of the queue (rear).
Initial front=rear=-1
False overflow of queue
The solution is to build a circular queue (front=(front 1)%MAX), rear=(rear 1)%MAX
Judgment of full and empty queues: front=rear
Solution 1: Set a flag to determine whether the last operation was pushed or popped from the stack
Solution 2: Set a number to record the number of elements in the queue
Solution 3: Sacrifice a storage space (rear 1)%MAX==front
Queue chain storage structure
array
Several special matrices
upper and lower triangular matrix
Symmetric matrix
tridiagonal matrix
sparse matrix
triple table storage
chain storage
Tree
Binary tree definition
A binary tree is either an empty tree or a root node plus two disjoint binary trees that become the left subtree and the right subtree respectively.
special binary tree
full binary tree
complete binary tree
Properties of binary trees
The i-th level of the binary tree has at most
A k-level binary tree has at most
For any binary tree, assuming the number of leaf nodes is n0 and the number of secondary nodes is n2, then n0=n2 1
Number the binary tree in hierarchical order. The left child node of the node numbered i is 2i, and the right child node is 2i 1.
Sequential storage of binary trees
Only store complete binary trees, leaving space 0 free, see Property 4
Linked storage of binary trees - binary linked list
Three-way linked list (each node stores its parent node)
Binary tree traversal
Preorder traversal, inorder traversal, postorder traversal
level-order traversal
Using a queue, each time a node is visited, its left and right children are queued.
non-recursive traversal
Applications of binary trees
Find the depth of a binary tree
Find the number of leaves of a binary tree
trees and forest
Tree children brother representation
special binary tree
clue binary tree
Regulation: If there is a left subtree, then lchild points to its left subtree, otherwise it points to its predecessor. If there is a right subtree, then rchild points to its right subtree, otherwise it points to its successor.
Binary sorting tree
A binary sorting tree is either an empty tree or has the following properties. If its left subtree is not empty, then all node values on the left subtree are less than the value of the root node. If its right subtree is not empty, then the right subtree The values of all nodes in the subtree are greater than the value of the root node. The left and right subtrees are both sorted binary trees.
Find
BST search is a process of constant comparison and branching
structure
The construction of BST is a process of continuously finding and adding leaf nodes.
delete
Delete leaf nodes, delete them directly
Delete the node with degree 1 and replace it with its non-empty child node
Delete the node with degree 2 and replace it with its predecessor.
Find performance analysis
The concept of average search length
balanced binary tree
A balanced binary tree is first of all a sorted binary tree. Its left and right subtrees are both balanced binary trees, and the difference in depth between the left and right subtrees does not exceed 1.
Balanced binary trees are constructed using balanced rotation techniques
optimal binary tree
The tree with the shortest weighted path length
Greedy algorithm to construct Huffman tree
Four steps for transmitting messages
1. Count the frequency of character occurrences
2. Construct Huffman tree
3. Formulate Huffman code table
4. Translate characters
Heap
A stacked tree is a complete binary tree. The value of the parent node of a large top heap is greater than its child node, and the value of the parent node of a small top heap is smaller than its child node.
combing the pile
Heap sort
TopK problem of massive elements
picture
diagram concept
directed graph
Directed complete graph (a directed graph with n (n-1) edges)
Links are called arcs
Undirected graph
Undirected complete graph (the number of edges is half that of directed complete graph)
links become edges
right
net
degree of vertex
The concept of connected graph
connected components
The maximal connected subgraph in an undirected graph is called a connected component
A maximal strongly connected subgraph in a directed graph is called a strongly connected component
subplot
A graph whose vertex set is a subset of the parent graph and whose edge set is also a subset of the parent graph becomes a subgraph of the parent graph.
spanning tree
For a graph with n vertices, its spanning tree is a connected subgraph with n vertices and n-1 edges.
adjacencies of vertices in a graph
If there is an edge connecting two vertices in an undirected graph, then the two vertices are adjacent to each other.
If there is an arc in the directed graph, the receiver is adjacent to the sender
Graph storage
adjacency matrix
adjacency list
It is easy to find the degree of exit, but it is difficult to find the degree of entry.
It is easy to find the entry degree of the inverse adjacency list, but it is difficult to find the degree.
cross linked list
It is easier to find the in-degree and out-degree
Graph traversal
depth first search
breadth first search
graph algorithm
Find the minimum spanning tree for an undirected graph
Prim's algorithm
Mainly connected, select the connected edge with the smallest weight each time
Algorithmic complexity
Kruskal algorithm
Focusing on the minimum cost, select the edge with the smallest weight each time to see if it can be added to the minimum spanning tree.
Algorithmic complexity
Checking Rings—Topological Sorting
Continuously delete vertices with indegree 0
Topological sorting cannot proceed, indicating that the graph contains cycles.
Directed acyclic graph (AOV) network - critical path algorithm
Labeling method, the maximum sum in the forward direction, the minimum difference in the reverse direction, the node with equal forward and reverse directions is the key node
shortest path algorithm
Unit Dijikstra's Algorithm
dynamic programming
All-source Floyd algorithm
Matrix multiplication
Find
Find categories
static search
dynamic search
Keywords
If a keyword can represent a unique element, it is called a primary keyword.
If it can only represent a few elements, it is called a secondary keyword.
Search on linear table
sequential search
Average comparison required when checking hits
If the check fails, it needs to be compared n times.
half search
When the search fails, high and low are interleaved.
The maximum number of successful checks is logn and the minimum number is 1.
If the check fails, it needs to be compared logn times.
Index lookup
The search process is divided into two parts - sequential search between blocks and sequential search within blocks.
Assuming that n is the table length and each block contains s data, the average search length is
Lookup in hash table (hash lookup)
Hash function construction method
direct hash function method
Take the keyword itself or a linear function of the keyword as the hash address
digital analytics
H(key)=s digits evenly distributed in the key
Square-Medium Method
H(key)=the middle digits of key2
folding method
Divide the keyword into several parts, and use the sum of the several parts as a hash address
divide and leave remainder method
Take a certain prime number that is not larger than the length, and remove the remainder of the prime number as the hash address.
random number method
H(key)=random(key)
conflict resolution methods
open address law
squared probing and hashing
Linear probing and then hashing
Random probing and then hashing
rehash
Hash again with a different hash function
chain address method
Store all values with the same hash address in a linked list
public area overflow method
Create an overflow table
Average lookup length of hash table
The ASL of a hash table is a function of the fill factor rather than a function of n
sort
Insert class
direct insertion sort
half insertion sort
Half search in sorted sequence
Hill sort
The time complexity is between
Select class
Simple selection sort
Select the smallest one from the unordered data and add it to the ordered sequence each time
Heap sort
Use a large top heap, continuously delete the top elements and filter them
exchange class
Bubble Sort
Quick sort
Quick sort and divide once: find a record as the pivot, move everything smaller than it to the front, and move everything larger than it to the back
Quicksort is a recursive program
Improvement of quick sorting, select the middle one among the first element, last element, and middle element as the pivot to avoid performance deterioration
Space complexity is mainly reflected in recursion
Merge class
Two-way merge sort
Comparison of stability
Compare time complexity and space complexity with n squared (simple selection sort is a special case)
Unstable sorting
Heap sort, quick sort, Hill sort, simple selection sort
stable sorting
Bubble sort, direct insertion sort, half insertion sort, two-way merge sort