1 int A =-1;
Unsigned int B =;
Cout <B;
During operation of the signed and unsigned types, the values are converted to the unsigned type.-1 indicates that all values are 1 in the memory as a complement, then it becomes unsigned, that is, 2 ^ 32-1.
Many traps are set in the conversion of signed and unsigned types, including the value assignment method and Relational operators.
Extended: the largest positive number plus 1 becomes the smallest negative number, and the smallest negative number minus 1 becomes the largest positive number.
Complement Subtraction
The subtraction of the complement code is the addition of the opposite number of this number.
For example, 7-6 is equal to 7 + (-6 ).
The 000001116 complement is 00000110.
The opposite number of 6 is 11111010, and the number of signs is equal to 00000001.
2. Why memory alignment?
1. Platform reason (reason for transplantation): Not all hardware platforms can access any data on any address. Some hardware platforms can only retrieve certain types of data at some addresses, otherwise, a hardware exception is thrown.
2. Performance reasons: Data Structures (especially stacks) should be aligned on natural boundaries as much as possible. The reason is that in order to access non-alignment memory, the processor needs to perform two memory accesses, while alignment memory access only needs one access.
Each compiler on a specific platform has its own default "alignment coefficient" (also called alignment modulus ). Programmers can use the pre-compiled command # pragma pack (N), n =, and 16 to change this coefficient. n is the alignment coefficient you want to specify ".
3 C ++ manages the memory through new and delete. If a new object contains a member variable or an object, when the object is deleted, do I still need to operate on member objects?
A: No, because each class has an destructor. If the class contains other class objects, the member's destructor will be called before the current object's destructor. The member constructor is also called during construction.
4 database index http://baike.baidu.com/view/2079871.htm
A structure for sorting values of one or more columns in a database table. You can use indexes to quickly access specific information in the database table.
Index classificationClustered IndexAndNon-clustered IndexTwo types: clustered indexes are stored in the order of physical locations, but not clustered indexes. Clustered indexes can speed up multi-row search, instead of clustered indexes, a single row is quickly searched.
The data structure used in the lower layer is B-tree http://www.cnblogs.com/oldhorse/archive/2009/11/16/1604009.html
B treeThat is, the binary search tree:
1. All non-leaf nodes have at most two sons (left and right );
2. All nodes store a keyword;
3. The left pointer of a non-leaf node points to the subtree smaller than its keyword, And the right Pointer Points to the subtree larger than its keyword;
B-Tree
Is a multi-path search tree (not binary ):
1. Define any non-leaf node with a maximum of M sons; and M> 2;
2. The number of sons at the root node is [2, m].
3. The number of non-leaf nodes except the root node is [m/2, m];
4. Each node holds at least m/2-1 (rounded up) and at most M-1 keywords; (at least 2 keywords)
5. Number of keywords for non-leaf nodes = number of pointers to Son-1;
6. Non-leaf node keywords: K [1], K [2],…, K [M-1]; and K [I] <K [I + 1];
7. Non-leaf node pointer: P [1], p [2],…, P [m]; where P [1] points to
Subtree, P [m] pointing to a subtree with a keyword greater than K [M-1], other P [I] pointing to a keyword belonging to (k [I-1], K [I]) child tree;
8. All leaf nodes are on the same layer;
B-Tree features:
1. The set of keywords is distributed in the entire tree;
2. Any keyword appears only in one node;
3. The search may end at a non-leaf node;
4. The search performance is equivalent to performing a binary search in the complete set of keywords;
5. Automatic hierarchical control;
B + tree
The B + tree is a variant of the B-tree and also a multi-path Search Tree:
1. Its definition is basically the same as that of B-tree,:
2. The number of subtree pointers and keywords for non-leaf nodes is the same;
3. Non-leaf node subtree pointer P [I], pointing to the subtree whose key value belongs to [K [I], K [I + 1 ])
(B-the tree is an open interval );
5. Add a chain pointer to all leaf nodes;
6. All keywords appear at the leaf node;
Features of B +:
1. All keywords appear in the linked list of leaf nodes (dense index), and the keywords in the linked list are exactly
Is ordered;
2. It is impossible to hit non-leaf nodes;
3. Non-leaf nodes are equivalent to leaf node indexes (sparse indexes), and leaf nodes are equivalent to storage.
(Keyword) data layer;
4. More suitable for file index systems;