Reprint: http://blog.csdn.net/jie1991liu/article/details/8167194
I. Data Structure section
1. The difference between an array and a linked list:
The C + + language can handle a set of data of the same data type with an array, but does not allow the size of the array to be dynamically defined, that is, the size of the array must be determined before the array is used. And in practical applications,
, the user can sometimes not accurately determine the size of the array before using the array, only to define the array to a sufficient size, so that some space in the array may not be used, resulting in a waste of memory space
。 A linked list is a common form of data organization, which is implemented by dynamically allocating memory. You can allocate memory space with new when you need it, freeing allocated space without the need for delete, without causing wasted memory space.
From the logical structure: the array must define a fixed length (number of elements) in advance, not adapt to the situation where the data changes dynamically, that is, the size of the array cannot be changed once it is defined.
When the data increases, it may exceed the number of elements originally defined, and when the data is reduced, the memory is wasted, and the list is dynamically stored and allocated, which can adapt to the dynamic increase or decrease of the data.
And it is easy to insert and delete data items. (When you insert or delete data items in an array, you need to move other data items).
From memory storage: (static) arrays allocate space from the stack (in the heap created with new), which is quick and easy for programmers, but small in degrees of freedom, and the list allocates space from the heap, but the application management is cumbersome.
From the access point of view: The array in memory is continuously stored, so you can use the subscript index for random access, the linked list is a chain storage structure, when accessing the element can only be accessed in a linear way from pre-to-post sequential access,
So the access efficiency is lower than the array.
2. Linked list of some operations, such as the reversal of the list, linked list of the existence of loop judgment (fast and slow pointer), doubly linked list, circular linked list related operations.
3. Queue (special such as priority queue), the application of the stack. (for example, queues are used in message queues, stacks are used in recursive calls)
4. Basic operation of two-fork tree
The three traversal modes of binary tree (pre-order, middle order, post-sequence) and their recursive and non-recursive implementations, and the main applications of three traversal methods (such as suffix expressions, etc.). The time complexity of the associated operation.
5. String-related
Conversion between integers, floating-point numbers, and strings (Atoi,atof,itoa)
String copy Note exception checking, such as null pointers, string overlaps, self-assignment, string Terminator '/0 ', etc.
Two. Algorithm section
1. Sorting algorithm:
Sorting can be regarded as the most basic, most commonly used algorithm, is also the most often examined in the written interview algorithm. The most basic bubble sort, select sort, insert sort to be quickly implemented in code,
These mainly examine your actual coding capabilities. Heap sort, merge sort, fast sort, these algorithms need to be familiar with the main ideas, and need attention to the details of the place. Need to be familiar with the time and space complexity of common sorting algorithms.
Summary of the scope of use of various sorting algorithms:
(1) When the data size is small, you can use simple sorting algorithms such as direct insertion or direct selection of sorting.
(2) When the initial state of the file has been basically ordered, you can use the direct insertion sort or bubble sort.
(3) When the data size is large, the application of fast sorting algorithm. You can consider using a quick sort. When the records are randomly distributed, the average time of the fast-track is the shortest, but the worst can happen.
The time complexity is O (n^2), and the recursive depth is n, and the required stack space is asked O (n).
(4) Heap sorting does not have a worst-case scenario such as a fast row, and heap ordering requires less secondary space than a fast row. But neither of these algorithms is stable,
If the order is stable, you can consider using merge sort. (5) Merge sort can be used to sort within, or can be used for sorting outside. When you sort outside, you usually use a multi-way merge,
And by solving the merging of Changshun string, the long initial string is generated, and the parallel capability of the host and peripherals is improved to reduce the number of accesses external memory and improve the efficiency of the external sequencing.
2, the search algorithm can be proficient in writing or the computer code out two points to find the program.
3.hash algorithm
4. Some algorithmic design ideas.
Greedy algorithm, divide and conquer algorithm, dynamic programming algorithm, randomization algorithm, backtracking algorithm and so on. These can be reviewed according to the specific example procedure.
5.STL
STL (Standard Template Library) is a C + + domain, using template technology to implement the data structure and algorithm library, has been included in the C + + standards Library.
The structure of vecor,list,stack,queue is not only more powerful, but also has higher security. In addition to the data structure, the STL also contains a generalized iterator,
and the various practical algorithms that run on the iterator. These are not too high performance requirements, but do not want to implement the algorithm from the bottom of the application is still very tempting.
Summary of four data structures and algorithms (i.)