Data structure and algorithm interview summary

Source: Internet
Author: User

I. Basic concepts of the algorithm
The process of solving a computer problem is actually implementing some kind of algorithm, which is called computer algorithm.
1. Basic features of the algorithm: feasibility, certainty, poverty, and sufficient intelligence.
2. The basic elements of the algorithm: the arithmetic and operation of the data, the control structure of the algorithm.
3. The basic method of algorithm design: Enumeration method, inductive method, recursion, recursion, half recursive technique, backtracking method.
4. Algorithm design requirements: Correctness, readability, robustness, efficiency and low storage requirements
Two. Complexity of the algorithm
1. Algorithm time complexity: refers to the computational effort required to perform the algorithm
2. The spatial complexity of the algorithm: the memory space required to execute the algorithm
Three. Definition of data structure
1. Logical Structure of data: a representation of a collection of data elements that reflect the relationships between data elements. The logical structure of data includes four kinds, including collection, linear structure, tree structure and graphic structure.
2. Data storage structure: the logical structure of the data is stored in the storage space of the computer as the storage structure of the data. The commonly used storage structure has the order, the link, the index and so on storage structure.
Four. Graphical representation of the data structure:
In the data structure, there is no previous node called the root node, and the node with no post becomes the terminal node. Insertions and deletions are two basic operations on data structures. There are also search, classification, merging, decomposition, copying, and modification.
Five. Linear structure and nonlinear structure
According to the complexity of the relationship between the data elements and the structure, the structure is generally divided into two types: linear structure and nonlinear structure.
Linear structure: A non-empty data structure satisfies: There is only one root node; Each node has a maximum of one front piece and at most one rear piece. Nonlinear structure: If a data structure is not a linear structure, it is called a nonlinear structure.
Common linear structures: linear tables, stacks, queues
Six. Definition of a linear table
A linear table is a finite sequence of n elements (A1,a2,a3 ...). )。 Each of the data elements in the table, except for the first one, has and has only one preceding piece. Except for the last one, there is only one rear piece. That is, the linear table is an empty table, or can be represented as (A1,a2,...... an), where AI (i=1,2,...... N) is the element that belongs to the data object, and is often referred to as a node in a linear table.
The non-null linear table has some of the following characteristics:
(1) There is only one root node A1, it does not have the first piece;
(2) There is only one terminal junction an, it does not have any pieces;
(3) Root node and terminal node, all other nodes have only one front piece, and there is only one rear part. The number of nodes in a linear table is called the length of a linear table. When N=0 is called an empty table.
Seven. Sequential storage structure for linear tables
The sequential table of a linear table refers to the data elements of a linear table stored sequentially by a contiguous set of storage units.
The sequential storage structure of a linear table has the following two basic characteristics:
1. The storage space occupied by all the elements in the linear table is continuous;
2. Each data element in a linear table is stored in logical order in the storage space.
That is, the linear table logically adjacent, physical is also adjacent, it is known that the first element of the initial address and the number of bytes per element, you can be the first address of an element.
Assume that each element of a linear table occupies a K storage unit and that the storage address of the first cell is the storage location of the data element. The storage position of the i+1 data element in the linear table, loc (ai+1) and the storage location of the first Data element, LOC (AI), satisfies the following relationship:
LOC (ai+1) =loc (AI) +k
LOC (AI) =loc (A1) + (I-1) *k①
where LOC (A1) is the storage location of the first data element A1 of a linear table, usually called the starting position or base address of a linear table.
Because in the sequential storage structure, each data element address can be calculated by the formula ①, so the sequential storage structure of the linear table is the random access storage structure.
Under the sequential storage structure of a linear table, you can perform the following operations on a linear table:
Insert, Delete, find, sort, explode, merge, copy, reverse
Eight. Insert operations for sequential tables
The insertion operation of a linear table refers to inserting a new node X on the table I, making a linear table of length n (a1,a2 ... ai...an) into a linear table (a1,a2...x,ai...an) of length n+1.
The time of the algorithm is mainly spent in the loop of the node after the move statement, the number of executions is n-i+1.
When I=n+1, best case, Time complexity O (1) When I=1, worst case, time complexity O (n)
The average time complexity of the algorithm is O (n)
Nine. Delete Operations for sequential tables
The deletion operation of a linear table refers to the deletion of a new node x in the first position of the table, so that a linear table of length n (a1,a2 ... ai...an) becomes a linear table (a1,a2...ai-1,ai+1...an) of length n-1.
When i=n, Time complexity O (1), when I=1, time complexity O (n), average time complexity is O (n)
10. Stack and its basic operations
1. What is a stack? The stack is actually a linear table, but a special linear table. A stack is a linear table that inserts and deletes operations only at one end of the table, usually called inserting, deleting this end as the top of the stack (top), and the other end as the bottom of the stack (BOTTOM). The empty stack is called when there are no elements in the table. The top element of the stack is always the element that is inserted, and thus the first element to be deleted, and the bottom element is always the first element to be inserted, and thus the last element to be deleted.
Assuming that the stack s= (A1,a2,a3,...... an), then A1 is called the Stack-bottom element, an is called the top element of the stack. The elements in the stack are stacked in the order of A1,a2,a3......an, and the first element of the stack should be the top element of the stack. That is, last in, first out.
2. Sequential storage of stacks and their operations
Use S (1:m) as the sequential storage space for the stack. M is the maximum capacity of the stack.
The basic operation of the stack has three kinds: the stack, the stack and the top element of reading stack.
Into the stack operation: Insert a new element at the top of the stack.
First put the top pointer in one (TOP+1) and then insert the new element into the position where the top pointer of the stack is pointing.
Stack out: refers to the top element of the stack and assigns it to a specified variable.
First assign the top element of the stack to a specified variable, and then back up the top pointer (TOP-1)
Reads the top element of the stack: assigns the top element of the stack to a specified variable. The stack top pointer does not change.
11. Queues and their basic operations
1. What is a queue
The queue is only allowed at one end to be deleted, and the other end is inserted in the order table, allowing the deletion of the end to be called the opponent, allowing the inserted end to be called the tail.
The modification of the queue is FIFO. Insert an element into the end of the queue to become a queue operation. Removing an element from the opponent is called a fallback operation.
2. Cyclic queue and its operation
In practical applications, the sequential storage structure of queues is generally used in the form of circular queues. The so-called circular queue, that is, the last position of the queue storage space to the first position, the formation of a logical ring space. In the loop queue, the tail pointer of the rear points to the tail element in the queue, with the front pointer pointing to the previous position of the first line element, so that all elements are in the queue from the next position pointed to by the front pointer, until the position of the tail pointer rear points.
In the actual use of the loop queue, in order to be able to distinguish between the queue full or empty, usually need to add a flag s:
Queue is empty, then the s=0,rear=front=m queue is full, then s=1,rear=front=m
There are two basic operations of the cyclic queue: the queued operation and the retreating operation
N Queue operation
A new element is added at the end of the queue in the loop, first rear=rear+1, when Rear=m+1, rear=1, and then inserting the new element into the position where the tail of the team pointer points. When S=1,rear=front, it indicates that the queue is full and cannot be queued, called "overflow."
N Retreating team operations
Exits an element in the queue at the beginning of the loop and assigns it to the specified variable. First front=front+1, and when front=m+1, place the front=1, then assign the element that the first pointer points to to the specified variable. When the loop queue is empty s=0, the fallback operation cannot be performed, which becomes "underflow".
12. Structure and basic operation of linear single-link list
1. Basic concepts of linear single-link lists
A set of arbitrary storage units stores the data elements of a linear table, so in order to represent the logical relationship between each data element AI and its direct successor data element ai+1, for data element AI, in addition to storing its own information, it is necessary to store a direct successor information (that is, the direct successor storage location). These two pieces of information make up the storage image of the data element AI and become the node. It consists of two domains where the domain where data element information is stored is called the data domain, and the domain where the direct successor storage is stored is called the pointer field. The information stored in the pointer field is called a pointer or chain. n node chains form a linked list, which is a chain storage structure for linear tables (A1, A2,......, an). And because each node in this list contains only one pointer field, it is also called a linear list or a single linked list.
Sometimes we have a node that precedes the first node of a single-linked list, called the head node, which points to the first node in the table. The data field of the head node can store no information or store additional information such as the length of the linear table, and the pointer field of the head node stores the pointer to the first node (that is, where the first element node is stored).
In a single-linked list, the first data element to be obtained must be looked up from the pointer, so that the single-linked list is the form of a non-random-access storage structure list: unidirectional, bidirectional
2. Storage structure of linear single-linked list
3 with Chain
3. Stacks and queues with columns
The stack is also a linear table and can also be used as a chained storage structure.
A queue is also a linear table, or a chain-stored structure can be used.
13. Basic operations of Linear lists 1. Insertion of a linear list 2. The deletion of a linear list
14. Structure and basic operation of doubly linked list
There are two pointer fields in the nodes of the doubly linked list, one pointing to the direct successor and the other pointing to the direct precursor.
15. Structure and basic operation of circular chain list
is another form of chain storage structure, which is characterized by the pointer field of the last node in the table pointing to the head node, the entire list forms a ring. As a result, other nodes in the table can be found from any node in the table.
16. Definition of a tree
A tree is a simple nonlinear structure. The characteristics of the tree-type structure:
1. Each node has only one predecessor, called the parent node, and there is only one node with no preceding pieces, called the root node of the tree.
2. Each node can have multiple post-node nodes, called sub-nodes of the node. No post-node nodes are called leaf nodes.
3. The number of last pieces owned by a node is called the node degree of the tree
4. The maximum level of the tree is called the depth of the tree.
17. Definition of two-fork tree and its basic properties
1. Two tree is another tree structure, it is characterized by a node at most only two subtrees tree (that is, the binary tree does not exist in the degree of more than 2 nodes), and the subtree of the binary tree has left and right points, its order can not be arbitrarily reversed.
2. Basic properties of two-fork tree
① there are at most 2i-1 nodes on the first layer of the binary tree.
② two-tree with a depth of k up to 2k-1 nodes (k>=1)
③ in any binary tree, the nodes with a degree of 0 are always one more than the nodes with a degree of 2;
The ④ has a two-fork tree with n nodes, at a depth of at least [log2n]+1].
A two-fork tree with a depth of K and a 2k-1 node is called a full two-tree. The feature of this tree is that the nodes on each layer are the maximum node points.
3. Full two fork tree with complete binary tree
Full two forks: all nodes on each layer have two sub-nodes, except for the last layer. On the K-level of the two-fork tree, there are 2k-1 nodes, and the 2m-1 nodes with a depth of M are full two forks.
Complete binary tree: Except for the last layer, the number of nodes on each layer reaches the maximum; On the last layer, only a few nodes on the right are missing. The depth of a complete binary tree with n nodes is [log2n]+1
Complete binary tree summary points are N,
If n is an odd number, the leaf node number is (n+1)/2 if n is even, then the leaf knot point is N/2
4. Storage structure of two-fork tree
A binary tree typically uses a chain-based storage structure


The binary tree has the following important characteristics:


Property 1 There are at most 2i-1 nodes (i≥1) on the first layer of a binary tree.


It is easy to use inductive method to testify this nature.
I=1, there is only one root node. Obviously, 2i-1=20=1 is right.
Now assume that for all j,1≤j<i, the proposition is set up, that is, at most 2j-1 nodes on level J. Then, can prove j=i when the proposition is also set up.
By inductive hypothesis: The I-1 layer has at most 2i-2 nodes. Since the degree of each node of the binary tree is at most 2, the maximum node number on layer I is twice times the maximum node number on the i-1 layer, i.e. 2*2i-2=2i-1.


A two-tree with a 2 depth of K has a maximum of 2k-1 nodes, (k≥1).


The maximum number of nodes of a two-fork tree with a depth of k is visible by the nature 1.
K K
∑ (maximum number of nodes on layer i) =∑2i-1=2k-1
I=1 I=1


Property 3 to any binary tree T, if its terminal node number is n0, the degree of 2 of the node is N2, then n0=n2+1.


Set the number of nodes with a n1 of two fork tree T with a medium degree of 1. Because all nodes in the binary tree are less than or equal to 2, the total number of nodes is


N=N0+N1+N2 (6-1)
Then look at the number of branches in the binary tree. In addition to the root node, the remaining nodes have a branch entry, set B as the total number of branches, then n=b+1. Since these branches are burst out of a junction of 1 or 2, there are b=n1+ 2n2.


N=n1+2*n2+1 (6-2)
So the formula (6-1) and (6-2) are n0=n2+1.


18. Two cross-tree traversal
is to follow a certain order and access all the nodes in the binary tree so that each node is accessed only once. Usually first left and right.
1. The pre-order traversal DLR accesses the root node first, then traverses the left subtree, and finally traverses the right subtree.
2. The middle sequence Traversal LDR first traverses the left subtree, then the root node, the last right subtree
3. Post-order traversal LRD first traverses the left subtree, then traverses the right subtree, and finally accesses the root node.
19. Sequential Lookup and binary search
1. Sequential lookups can only be found in order in two cases: the linear table is unordered table, the chain storage structure of the ordered table
2. Two points find only for sequential tables (small to large) that are stored sequentially.
For ordered linear tables of length n, in the worst case, binary lookups only need to compare log2n times, while sequential lookups are compared to n times. Sort: An ordered sequence that arranges an unordered sequence into non-descending order by value.
20. Exchange Class Sorting method
Bubble sort and quick sort method belong to the sorting method of Exchange class
1. The bubble sort method assumes that the linear table has a length of N, then in the worst case, the run-in sequence needs to pass through the N/2 of the previous scan and N/2 the backward scan, the number of comparisons required is n (N-1)/2
2. Quick Sort Method
21. Select Class Sort Method 1. Simple selection sorting Method 2. Heap Sorting method
23. Insert class Sort Method 1. Simple insertion sorting Method 2. Hill Sort method
Worst case Scenario Best case description
Exchange Sort bubble sort N (n-1)/2 The simplest interchange sort. The most efficient is the sequence of elements to be ordered.
Quick Sort N (n-1)/2 O (Nlog2 N)
Insert sort Simple Insert sort n (n-1)/2 applicable when each element is not far from its final position
Hill sort O (n1.5)
Select sort Simple Select sort N (n-1)/2
Heap sort O (nlog2n) for larger-scale linear tables
Practice:
1. The common feature of stacks and queues is (only allow inserting and deleting elements at the end point)
2. If the input stack sequence is e1,e2,e3,e4, then the possible stack sequence is (E2,E4,E3,E1)
3. Stack bottom to the top of the stack to store elements a, B, C, D, in the Fifth Element e before the stack, the stack of elements can be out of the stack, the stack sequence may be (DCBEA)
4. The two storage structures typically used in stacks are (linear storage structures and linked list storage structures)
5. The following description of the stack is correct (D)
A. Stack is a non-linear structure B. Stack is a tree structure c. Stack with first-in, FIFO features D. Stack with LIFO feature
6. The list does not have the characteristics of (b) a. No prior estimation of storage space B. Random access to any element
C. Insert Delete No need to move element D. The required space is proportional to the linear table length
7. The advantage of using a linked list to represent a linear table is (easy to insert and delete operations)
8. In a single-linked list, the purpose of adding a head node is (to facilitate the implementation of the operation)
9. The main advantage of the circular list is that the entire list can be accessed from any node in the table.
10. Linear table l= (a1,a2,a3,...... ai,...... an), the following statement is correct (D)
A. Each element has a direct front and a direct back B. There must be at least one element in the linear table
C. The order of elements in the table must be from small to large or from large to small
D. In addition to the first and last elements, each of the remaining elements has one and only one direct front and a direct back
11. If the linear table uses a chained storage structure, the address of the memory available storage unit (D) is required
A. must be continuous B. Part of the address must be continuous C. Must be discontinuous D. Continuous discontinuity can be
12. The sequential storage structure of linear table and the chain storage structure of linear table are (random access storage structure, sequential access storage structure)
13. The tree is a collection of nodes, its root node number is (and only 1)
14. In a full two-fork tree with a depth of 5, the number of leaf nodes is (31)
15. Two-fork tree with 3 nodes (5 forms)
16. Set a binary tree with 3 leaf nodes with 8 degrees 1 nodes, then the total number of nodes in the two fork tree is (13)
17. It is known that the sequential traversal sequence of a binary tree is Dabec, and the sequence traversal is DEBAC, and its sequence of sequential traversal is (CEDBA)
18. It is known that a binary tree pre-sequence traversal and a middle sequence traverse are ABDEGCFH and DBGEACHF respectively, then the post-order traversal of the two-tree is (DGEBHFCA)
19. If a binary tree's pre-order traversal Access order is ABDGCEFH, the sequence traversal access order is DGBAECHF, then its post-order traversal of the node access sequence is (GDBEHFCA)
20. Database protection is divided into: security control, Integrity control, concurrency control and data recovery.


1. In a computer, the algorithm refers to (an accurate and complete description of the solution to the problem)
2. In the following options, which is not an algorithm should generally have the basic characteristics (infinity)
Description: The four basic features of the algorithm are: feasibility, certainty, poverty, and sufficient intelligence.
3. The algorithm generally can be composed of which control structure (order, selection, cycle)
4. The time complexity of the algorithm refers to (the number of basic operations required during the execution of the algorithm)
5. The spatial complexity of the algorithm refers to (the amount of storage space required during execution)
6. The purpose of the algorithm analysis is to (analyze the efficiency of the algorithm to improve)
7. The following statements are correct (C)
A The execution efficiency of the algorithm is independent of the storage structure of the data
B The spatial complexity of the algorithm refers to the number of instructions (or statements) in the algorithm program.
C The poor nature of the algorithm means that the algorithm must be able to terminate after a finite number of steps have been performed
D The time complexity of the algorithm refers to the time required to execute the algorithm program.
8. Data structure as a subject of computer, mainly study the logical structure of data, the operation of various data structures, and (data storage structure)
9. Data structure, which is not related to the computer used (C)
A Storage structure B. Physical Structure C. Logical Structure D. Physical and storage structures
10. In the following narrative, the error is (B)
A The storage structure of data is closely related to the efficiency of processing
B The storage structure of the data is independent of the efficiency of processing
C The storage structure of the data is not necessarily contiguous in the computer space.
D A logical structure of data can have a variety of storage structures
11. The storage structure of the data refers to (the logical structure of the data is represented in the computer)
12. The logical structure of the data refers to (data structures that reflect the logical relationships between data elements)
13. According to the complexity of the relationship between the data elements and the structure, it is generally divided into (linear structure and nonlinear structure).
14. The following data structures have a memory function of (C) a. Queue B. Loop Queue C. Stack d. Sequential table
15. In the following data structures, the data is organized according to the Advanced post-principle (B)
A Linear link List B. Stack C. Circular link Table D. Sequential table
16. Recursive algorithms generally need to be implemented using (queues).
17. The following description of the stack is correct (D) a. Only data B can be inserted in the stack. Only data can be deleted from the stack
C The stack is a FIFO linear table D. The stack is a linear table after the advanced
18. Stack bottom to the top of the stack to store elements a, B, C, D, in the Fifth Element e before the stack, the stack of elements can be out of the stack, the stack sequence may be (DCBEA)
19. If the input stack sequence is e1,e2,e3,e4, then the possible stack sequence is (E2,E4,E3,E1)
20. The benefit of sharing one storage space from two stacks is (saving storage space, reducing the chance of overflow occurrence)
21. During the execution of the application, when the data needs to be output through the printer, a print job is usually formed, which is stored in a specified (queue) on the hard disk, and when the printer is idle, the job to be printed is removed from the first-come-first-served basis.
22. The following description of the queue is correct (C) a. Only data B can be inserted in the queue. Only data C can be deleted in the queue. The queue is a FIFO linear table D. The queue is an advanced, out-of-Line table
23. In the following narrative, it is correct that (D) A. The position of each element in the linear list must be contiguous in the storage space
B The table header elements in a linear list must be stored in front of the other elements C. The position of each element in a linear list is not necessarily contiguous in the storage space, but the header element must be stored in front of the other element, D. The positions of elements in a linear list are not necessarily contiguous in the storage space, and the order in which the elements are stored is arbitrary.
24. (a) A is correct in the following narrative. A linear table is a linear structure B. Stack and queue are nonlinear structures
C Linear linked list is a nonlinear structure D. Binary tree is a linear structure
25. Linear table l= (a1,a2,a3,...... ai,...... an), the following statement is correct (D)
A Each element has a direct front and a direct back piece B. There must be at least one element in the linear table
C The order of elements in a table must be from small to large or from large to small d. In addition to the first element and the last element, each of the remaining elements has one and only one direct front and a direct back
26. If the linear table uses a chained storage structure, the address of the memory available storage unit (continuous discontinuity can be required)
27. The list does not have the characteristics of (B) a. You do not have to estimate storage B beforehand. Random access to any element
C Insert Delete does not need to move element D. The required space is proportional to the linear table length
28. Non-empty circular single-linked list head end node (pointed by P), meet (P->next=head)
29. One of the advantages of a doubly linked list compared to a one-way list is (easier access to neighboring nodes)
30. In (D), whenever you indicate the location of any of the nodes in the table, you can access all the other nodes in the table in turn. A Linear single-link list B. Doubly linked list C. Linear linked list D. Circular link List
31. The following data structures belong to nonlinear data structures (C) A. Queue B. Linear Table C. Binary Tree D. Stack
32. The tree is a collection of nodes, its root node number is (and only 1)
33. Two-fork tree with 3 nodes (5 forms)
34. The number of nodes on the 8th layer on a binary tree is (128) Note: 2k-1
35. In a full two-fork tree with a depth of 5, the number of leaf nodes is (16) Note: 2n-1
36. In a full two-fork tree with a depth of 5, there is a total of (31) nodes. Note: 2n-1
37. Set a complete binary tree total of 699 nodes, then the number of leaves in the two-fork tree knot Point is (350)
Description: Complete binary tree summary points are N, if n is odd, then the leaf node number is (n+1)/2; If n is even, the leaf node is N/2.
38. With the following two-fork tree, the result of the sequential traversal of this binary tree is (B)
A ABCDEF
B Dbeafc
C Abdecf
D Debfca
39. It is known that the sequential traversal sequence of a binary tree is Dabec, and the sequence of sequential traversal sequences is DEBAC, and its pre-sequence traversal sequence is (CEDBA)
40. It is known that a binary tree pre-sequence traversal and a middle sequence traverse are ABDEGCFH and DBGEACHF respectively, then the post-order traversal of the two-tree is (DGEBHFCA)
41. If a binary tree's pre-order traversal Access order is ABDGCEFH, the sequence traversal access order is DGBAECHF, then its post-order traversal of the node access sequence is (GDBEHFCA)
42. The length of the string is (the number of characters contained in the string)
43. With two strings p and Q, ask Q for the first occurrence of position in P operation (pattern matching)
The number of edges in a connected graph of N vertices is at least (N-1)
The number of edges of a strongly connected graph of 45.N vertices has at least (N)
46. Sequential lookup of a linear table of length n, in the worst case, the number of comparisons required is (n)
47. The simplest way to exchange sorting is (bubble sort)
48. Assuming that the linear table has a length of N, in the worst case, the number of comparisons required for the bubble sort is (n (n-1)/2)
49. The most efficient sorting method is (bubble sort), in order to order the sequence of elements to be sorted basically.
50. In the worst case scenario, the least time complexity in the following sequential methods is (heap sort)
51. The Hill Sort method belongs (Insert class sort)
52. Heap sorting method belongs to (select Class sort)
53. The maximum amount of memory required in the following sorting methods is (merge sort)
54. It is known that each element in data table A is not far from its final position, to save time, should be used (direct insertion sort)
55. The basic characteristics of the algorithm are feasibility, certainty, poverty and sufficient intelligence.


1. An algorithm is usually composed of two basic elements: one is the operation and manipulation of the data object, and the other is the control structure of the algorithm.
1. The complexity of the algorithm mainly includes time complexity and space complexity.
2. The number of storage units required to implement the algorithm and the size of the algorithm are called the spatial complexity and time complexity of the algorithm, respectively.
3. The so-called data processing refers to the various elements of the dataset in a variety of ways to perform operations, including INSERT, delete, find, change and other operations, including the analysis of data elements.
4. The data structure refers to a collection of interrelated elements.
5. Data structure is divided into logical structure and storage structure, and linear list belongs to storage structure.
6. The data structure includes the logical structure and the storage structure of the data.
7. The data structure includes the logical structure, the storage structure of the data and the operation of the data.
8. Any relationship between the data elements can be described by a pre-trend and subsequent relationship.
9. The logical structure of data has two kinds of linear structure and nonlinear structure.
10. The commonly used storage structure has the order, the link, the index and so on storage structure.
11. The sequential storage method is to store logically adjacent nodes in a storage unit adjacent to the physical location.
12. The basic operation of the stack has three kinds: the stack, the stack and the top element of the reading stack.
13. There are two main types of operations in the queue: the queued operation and the withdrawal operation.
14. In practical applications, a chain stack can be used to collect all the idle storage nodes in the computer's storage space, which is called the available stack.
15. The storage structure typically used by stacks and queues is chain-stored and sequential storage.
16. When the linear table uses sequential storage structure to implement storage, its main feature is that the adjacent nodes in the logical structure are still adjacent in the storage structure.
17. There are two basic operations of the cyclic queue: the queued operation and the retreating operation. Each time the queue operation, the end of the pointer in 1.
18. When the loop queue is not empty and the tail pointer equals the head pointer, the circular queue is full and cannot be queued. This condition is called overflow.
19. When the loop queue is empty, you cannot perform a fallback operation, which is called underflow.
20. In a circular queue with a capacity of 25, if the head pointer front=16 and the tail pointer rear=9, there are 18 elements in the loop queue. Note: When Rear<front, the number of elements = Total capacity-(front-rear);
When Rear>front, the number of elements is =rear-front.
21. In a circular queue with a capacity of 15, if the head pointer front=6 and the tail pointer rear=9, there are 3 elements in the loop queue.
22. Sequential lookups generally refer to finding the specified element in a linear table.
23. One of the simplest methods of storing linear tables in a computer is sequential storage.
24. In a programming language, a one-dimensional array is typically defined to represent the sequential storage space of a linear table.
25. In chained storage, each node is required to consist of two parts: a part for storing data element values, called data fields, and another part for holding pointers, called pointer fields. Where the pointer is used to point to the previous or next node of the node (that is, the front or back).
26. In a linear single-linked list, each node has only one pointer field, the pointer can only find the successor node, but cannot find the precursor node.
27. In order to insert a new element into a linear list, first assign the element a new node, which is used to store the value of the element.
28. After you delete an element in a linear list, you only need to change the pointer field of the previous node of the node where the element was deleted.
29. The prominent advantage of using a linked list to represent a linear table is the ease of insertion and deletion.
30. In the tree structure, the root node has no previous pieces.
31. In a tree structure, the number of subsequent pieces owned by a node is called the degree of the node. The degree of Leaf junction is 0.
32. Set up a binary tree with 3 leaf nodes, 8 degrees 1 nodes, then the total number of nodes in the two fork tree is 13.
33. With a total of 739 nodes in a fully binary tree, there are 370 leaf nodes in the two-fork tree.
34. With a total of 700 nodes in a fully binary tree, there are 350 leaf nodes in the two-fork tree.
35. Under the principle of left and right, according to the order of Access root node, the traversal of binary tree can be divided into three kinds: pre-sequence traversal, middle sequence traversal and post-order traversal.
36. If the string s= "program", then the number of its substrings is 29. Note: N (n+1)/2+1
37. If the string s= "Mathtypes", then the number of its substrings is 46.
38. When inserting a new element into a linear table of length n or deleting an element, the worst-case scenario requires a number of comparisons of N.
39. Sequential lookup in an ordered linear table of length n. In the worst case, the number of comparisons required is n.
40. Binary lookup in an ordered linear table of length n. In the worst case, the number of comparisons required is log2n.
41. In sequential storage linear table of length n, when the probability of inserting an element is equal at any position, the average number of moving elements required to insert an element is N/2.
42. Sorting is an important operation in computer programming, and the common sorting methods are inserting sort, exchanging sort and selecting sort.
43. The Quick Sort method can be used to eliminate multiple reverse orders through a single exchange.
44. The key to the fast sorting method is to split the linear table.
45. The bubble sorting algorithm has the best possible element exchange number of 0.
46. In the worst case scenario, the time complexity of the bubble sort is n (n-1)/2.
47. For linear tables of length n, in the worst case, the number of comparisons required for fast sorting is n (n-1)/2.
48. In the worst case, a simple insert sort requires a comparison of n (n-1)/2.
49. In the worst case, the number of times the hill sort needs to be compared is O (n1.5). Note: The parentheses are 1.5 times the N.
50. In the worst case, the simple choice of sorting requires a comparison of n (n-1)/2.
51. In the worst case scenario, the heap sort needs to be compared in the number of O (nlog2n).
52. The average time complexity for the fast sorting algorithm with the number of inputs n is O (Nlog2 N).

Data structure and algorithm interview summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.