2, the list
2,1, problem-solving skills
- Using the pointer speed (sometimes need to use three pointers)
- Flip the list
- Looking penultimate k elements
- Looking in the middle of the list elements
- Determining whether a cycloalkyl list
- Construction of a false list head
- Two sorted lists, sorting integration
- The parity sequence originally isolated in the list, generate the first half of an odd number, the latter part of an even number
2.2, how to train the skills
In the process of the mutual relationship between the class of white paper or draw the modified node shown
Figment of the imagination is more difficult
Painted in white class, will make the interviewer clearly see ideas
3. Stack
3.1, the characteristics of the stack
- LIFO
3.2, the basic idea of the algorithm
- Can be achieved with a single linked list
- Only care about the last operation
- After a post-processing operation, the more can be found in the previous operation O (1) time
4, queue
4.1, queuing features
- FIFO
4.2, commonly used scenes
- Breadth search
5, deque
5.1, commonly used scenes
A dynamic change in length of the window or continuum
6, the tree (master key)
6.1 commonality, tree
- Intuitive structure
- To examine the recursive algorithm mastered by tree problem proficiency
The nature of the tree, often requires that each node must meet
- When you define a binary search tree, no node must be a binary search tree
- Seeking depth binary tree
6.2, the shape of the tree have often test interview
- Ordinary binary tree
- Balanced binary tree
- Complete binary tree
- Binary search tree
Special tree: red-black tree (do not understand)
6.3, often test
Traversal (recursive and non-recursive writing)
- Preorder traversal (search tree, and create a new number to use)
- Traversal sequence (
二叉搜索树
the sequence at this time is the access to the order of elements)- Postorder (when the need to modify the left and right child nodes, the leaf node modified information collected from the bottom to the heel)
7, priority queue
(More complicated to achieve, in solving problems in the interview Oh, you can implement ism)
Nature
Binary heap structure, using an array of binary tree structure to achieve complete
Basic Operations
- Screening Up
- Screening down
`Time complexity: O (logk)
Another important time complexity: Priority Queue initialization time complexityo(n)
Feature
The difference between ordinary queue
Taken to ensure that each element is the highest priority queue
Priority can be customized
The most commonly used scenes
From the data in the chaotic (or priority) of data in a certain order filter
* 给定一个数组,找到前k个大的数
* 求前k个高频元素
* 关键如何定义优先级