Data structures and algorithms

Source: Internet
Author: User

Chapter 1
I. Basic concepts of Algorithms
A computer is actually implementing an algorithm, which is called a computer algorithm.
1. Basic Features of the algorithm: feasibility, certainty, poverty, and sufficient intelligence.
2. Basic Elements of an algorithm: the calculation and operation of data in an algorithm and the control structure of an algorithm.
3. Basic Methods of Algorithm Design: column lift, induction, recursion, recursion, halving, and backtracking.
4. Requirements for Algorithm Design: correctness, readability, robustness, efficiency, and low storage capacity
Ii. complexity of Algorithms
1. algorithm time complexity: The computing workload required to execute the algorithm
2. space complexity of the algorithm: memory space required to execute the algorithm
Iii. data structure definition
1. Logical Structure of data: the representation of the data element set that reflects the relationship between data elements. The logical structure of data includes set, linear structure, tree structure, and graphic structure.
2. Data Storage Structure: the logical structure of data is stored in computer buckets. Common storage structures include storage structures such as order, link, and index.
4. graphical representation of the data structure:
In the data structure, a node without a front component is called a root node; a node without a back component becomes a terminal node. Insert and delete are two basic operations on the data structure. Search, category, merge, split, copy, and modify.
V. linear and nonlinear structures
According to the complexity of the relationship between front and back parts of each data element in the data structure, the data structure is generally divided into two types: linear structure and non-linear structure.
Linear structure: the non-empty Data Structure satisfies the following requirements: There is only one root node, and each node has one front and one back. Non-linear structure: If a data structure is not a linear structure, it is called a non-linear structure.
Common linear structures: Linear tables, stacks, and queues
6. Linear table definition
A linear table is a finite sequence (A1, A2, A3…) composed of n elements ......). Each data element in a table has only one front part except the first one. There is only one post except the last one. A linear table is an empty table, or can be expressed as (A1, A2 ,...... An), where Ai (I = 1, 2 ,...... N) is an element of a data object. It is usually called a node in a linear table.
Non-empty linear tables have the following features:
(1) There is only one root node A1, which has no front parts;
(2) There is only one terminal node, and there is no backend;
(3) Except for the root node and the terminal node, all other nodes have only one front and one back. The number n of nodes in a linear table is the length of a linear table. When n = 0, it is called an empty table.
VII. Sequential storage structure of linear tables
A sequential table stores the data elements of a linear table in sequence with a set of sequential storage units.
The sequential storage structure of a linear table has the following two basic features:
1. The storage space occupied by all elements in a linear table is continuous;
2. Data Elements in a linear table are stored in logical order in the bucket.
That is, a linear table is logically adjacent and physically adjacent. If the first address of the first element and the number of bytes occupied by each element are known, the first address of the element can be obtained.
Assume that each element of a linear table occupies K storage units and uses the storage address of the first unit as the storage location of the data element. The storage location of the I + 1 data element in a linear table LOC (AI + 1) and the storage location of the I Data Element LOC (AI) meet the following requirements:
LOC (AI + 1) = LOC (AI) + K
LOC (AI) = LOC (A1) + (I-1) * k ①
Here, loc (A1) is the storage location of the first data element A1 in a linear table. It is usually called the starting position or base address of a linear table.
In the ordered storage structure, each data element address can be obtained through formula ①. Therefore, the ordered storage structure of linear tables is a random storage structure.
In the ordered storage structure of a linear table, you can perform the following operations on the linear table:
Insert, delete, search, sort, decompose, merge, copy, and reverse
8. insert operations for sequence tables
The insert operation of a linear table refers to inserting a new node X at the position I of the table so that the linear table with a length of N (A1, A2... Ai... An) to a linear table with the length of N + 1 (A1, A2... X, AI... An ).
The time of this algorithm is mainly spent on the loop node move-back statement, and the number of executions is n-I + 1.
When I = n + 1, the best case, the time complexity O (1) When I = 1, the worst case, the time complexity O (N)
The average time complexity of the algorithm is O (n)
9. delete an ordered table
The delete operation of a linear table is to delete a new node X at the position I of the table so that the linear table with a length of N (A1, A2... Ai... An) to a linear table with the length of N-1 (A1, A2... Ai-1, AI + 1... An ).
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 stack? Stack is actually a linear table, but a special linear table. A stack is a linear table that can only be inserted and deleted at one end of the table. It is usually referred to as the top end of the stack and the bottom end of the stack as the bottom end of the stack ). When there are no elements in the table, it is called an empty stack. The top element of the stack is always the last element to be inserted, which is also the first element to be deleted; the bottom element of the stack is always the first element to be inserted, which is also the last element to be deleted.
Suppose stack S = (A1, A2, A3 ,...... An), A1 is called the bottom element of the stack, and an is called the top element of the stack. The elements in the stack Are A1, A2, A3 ...... The first element of the stack should be the top element of the stack. That is, after the first, and foremost.
2. Sequential storage of stacks and its operations
S (1: m) is used as the stack's sequential storage space. M is the maximum stack capacity.
There are three basic stack operations: the elements of the inbound stack, the rollback stack, and the read stack top.
Inbound operation: Insert a new element at the top of the stack.
First, add the top pointer to the stack (top + 1), and then insert the new element to the position pointed to by the top pointer of the stack.
Stack rollback: gets 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 return the top pointer of the stack to one (top-1)
Read stack top element: assigns the top element of the stack to a specified variable. The top pointer of the stack will not change.
11. queue and its basic operations
1. What is a queue?
A queue is an ordered table that can be inserted only at one end. The deleted end is called the opposite end, And the inserted end is called the opposite end.
The queue is first-in-first-out. Insert an element to the end of the team to become the calculation. Deleting an element from the opposite is called a backend operation.
2. cyclic queue and its operations
In practical applications, the ordered storage structure of queues is generally in the form of cyclic queues. The so-called cyclic queue is to round the last location of the queue storage space to the first location, forming a logical ring space. In the cyclic queue, use the team tail pointer rear to point to the team end element in the queue, and use the front pointer to point to the previous position of the queue element. Therefore, from the last position pointed by the front pointer to the end of the team until the position pointed by the rear pointer, all elements are elements in the queue.
To distinguish whether the queue is full or empty when a cyclic queue is used, a sign s is usually required:
If the queue is empty, S = 0, rear = front = m queue is full, S = 1, rear = front = m
The cyclic queue has two basic operations: the queuing operation and the backend operation.
N join operations
Add a new element to the end of the cyclic queue. First, rear = rear + 1. When rear = m + 1, set rear = 1, then Insert the new element to the position pointed by the Team's tail pointer. When S = 1, rear = front, it indicates that the queue is full and cannot be entered into the queue. This is called "overflow ".
N unteam operations
Exit an element and assign it to the specified variable at the beginning of the loop queue. First, the front = front + 1, and when the front = m + 1, set the front = 1, and then assign the element pointed by the header pointer to the specified variable. When the cyclic queue is empty, S = 0 cannot be dequeued. This situation becomes "underflow ".
12. structure and basic operations of a linear single-chain table
1. Basic concepts of a linear single-chain table
A group of arbitrary storage units stores the data elements of a linear table. Therefore, 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 also needs to store information indicating its direct successor (that is, the direct successor storage location ). These two pieces of information constitute the storage image of the data element AI and become a node. It includes two fields: the domain that stores the information of data elements is called the data domain, and the domain that stores the direct subsequent storage location is called the pointer domain. The information stored in the pointer domain is called a pointer or chain. N node chains form a linked list, which is a linear table (A1, A2 ,......, An. Because each node of the linked list contains only one pointer field, it is also called a linear linked list or a single-chain table.
Sometimes, we add a node before the first node of a single-chain table, which is called a header node and points to the first node in the table. The data field of the header node can store additional information such as the length of a linear table, without any information, the pointer field of the header node stores the pointer to the first node (that is, the storage location of the first element node ).
In a single-chain table, the first data element must be retrieved from the pointer. Therefore, a single-chain table is a non-random access storage structure linked list: one-way, two-way
2. Storage Structure of a linear single-chain table
3. blockchain
3. Stack and queue with columns
Stack is also a linear table and can also adopt a chained storage structure.
The queue is also a linear table and can also be stored in a chain structure.
13. Basic Calculation of Linear Linked List 1. insertion of Linear Linked List 2. Deletion of Linear Linked List
14. structure and basic operations of two-way linked list
There are two pointer fields in the node of the two-way linked list, one pointing to direct successor, and the other pointing to direct precursor.
15. Structure of cyclic linked list and its basic operations
Is another form of chained storage structure, which features the pointer field of the last node in the table pointing to the header node, and the entire linked list forms a ring. Therefore, other nodes in the table can be found from any node in the table.
16. Tree Definition
A tree is a simple nonlinear structure. Tree Structure Features:
1. Each node has only one front node, which is called the parent node. There is only one node without the front node, which is called the root node of the tree.
2. Each node can have multiple post-component nodes, called the Child Nodes of the node. A node without a post is called a leaf node.
3. The number of backparts owned by a node is called the node degree of the tree.
4. The maximum hierarchy of a tree is called the depth of the tree.
17. Definitions and basic properties of Binary Trees
1. A binary tree is another tree structure. It features that each node has at most two Subtrees (that is, a node with a degree of no presence greater than 2 in a binary tree, the subtree of a binary tree can be left or right, and its order cannot be reversed.
2. Basic Nature of Binary Trees
① There are at most 2i-1 nodes on the I layer of a binary tree.
② A binary tree with a depth of K has at most 2k-1 nodes (k> = 1)
③ In any binary tree, a node with a degree of 0 is always one more than a node with a degree of 2;
④ A binary tree with N nodes, with a depth of at least [log2n] + 1.
A binary tree with K depth and 2k-1 nodes is called a full binary tree. This tree features the maximum number of knots on each layer.
3. Full and full Binary Trees
Full Binary Tree: Except for the last layer, all nodes on each layer have two subnodes. On the K layer of the full binary tree, there are 2k-1 nodes, and the depth is M.
Complete Binary Tree: Except for the last layer, the number of knots on each layer reaches the maximum value. On the last layer, only a few knots on the right are missing. The depth of A Complete Binary Tree with N nodes is [log2n] + 1
The sum point of the Complete Binary Tree is n,
If n is an odd number, the number of leaf nodes is (n + 1)/2 If n is an even number, the number of leaf nodes is n/2
4. Binary Tree Storage Structure
Binary Tree uses a chain storage structure.

Binary trees have the following important features:

Property 1 has at most 2i-1 nodes (I ≥1) on the I layer of a binary tree ).

This property can be easily proved by induction.
When I = 1, there is only one root node. Obviously, 2i-1 = 20 = 1 is correct.
Now assume that the proposition is true for all J, 1 ≤ j <I, that is, layer J has at most 2 J-1 nodes. Then, it can be proved that the J = I proposition is also true.
Suppose that there are at most 2i-2 nodes on the I-1 layer. Because the degree of each node of the binary tree is mostly 2, the maximum number of knots on the I layer is twice the maximum number of knots on the I-1 layer, 2*2i-2 = 2i-1.

The binary tree with a depth of 2 K has at most 2k-1 nodes (k ≥ 1 ).

The property 1 shows that the maximum number of knots of a binary tree with a depth of K is
K
Σ (maximum number of nodes on layer I) = Σ 2i-1 = 2 k-1
I = 1 I = 1

For any binary tree T, if the number of terminal nodes is N0 and the number of nodes with the degree of 2 is N2, N0 = n2 + 1.

Set N1 to the number of knots where T is moderate to 1. Because the degree of all nodes in a binary tree is less than or equal to 2, the total number of nodes is

N = N0 + N1 + N2 (6-1)

Let's look at the number of branches in the binary tree. Except for the root node, all other nodes have a branch to enter. If B is set to the total number of branches, n = B + 1. Because these branches are shot from nodes with degrees 1 or 2, B = N1 + 2n2 is available.

N = N1 + 2 * N2 + 1 (6-2)

So we get N0 = n2 + 1 from formula (6-1) and (6-2 ).

18. binary tree traversal
It is to access all nodes in the binary tree in a certain order, so that each node is accessed only once. Generally, it is left first and right later.
1. traverse the DLR in the forward order first access the root node, then traverse the left subtree, and finally traverse the right subtree.
2. Traverse LDR in the middle order first, traverse the left subtree, then the root node, and finally the right subtree
3. Traverse LRD sequentially first, traverse the left subtree, then traverse the right subtree, and finally access the root node.
Nineteen. Sequential search and Binary Search
1. Sequential query can only be used for sequential query in two cases: a linear table is an ordered table with an unordered table or a chain storage structure.
2. Binary Search is only applicable to ordered tables stored in sequence (from small to large ).
For an ordered linear table with a length of N, in the worst case, the binary search only needs to compare the log2n times, and the sequential search needs to compare n times. Sorting: sorts an unordered sequence into an ordered sequence in a non-descending order of values.
20. Exchange sorting
Bubble sorting and quick sorting are the sorting methods of the exchange class.
1. the Bubble sorting method assumes that the length of a linear table is N, in the worst case, run sort requires n/2 times of scanning from the back to the back and n/2 times of scanning from the back to the back, the number of times required to compare N (N-1)/2
2. Quick sorting
21. Select class sorting method 1. Simple selection sorting method 2. Heap sorting method
23. Insert sort method 1. Simple insert sort method 2. Hill sort method
In the worst case, it is best to explain
Exchange sorting Bubble sorting n (n-1)/2 the simplest exchange sorting. The most efficient element sequence is to be sorted.
Fast sorting of N (n-1)/2 O (nlog2 N)
Insert sort simple insert sort N (n-1)/2 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 sorting O (nlog2n) is applicable to Large-Scale Linear tables.
Exercise:
1. The common feature of stack and queue is that (only elements can be inserted and deleted at the endpoint)
2. If the stack import sequence is E1, E2, E3, E4, the possible outbound stack sequence is (E2, E4, E3, E1)
3. elements A, B, C, and D are stored in sequence from the bottom of the stack to the top of the stack. Before the fifth element e is added to the stack, the elements in the stack can go out of the stack, the output stack sequence may be (dcbea)
4. The two storage structures used for stacks are (linear Storage Structure and linked list storage structure)
5. Which of the following statements about stack is true? (d)
A. Stack is a non-linear structure B. Stack is a tree structure C. Stack has the first-in-first-out feature d. Stack has the first-in-first-out feature
6. The chain table does not have the characteristics of (B) A. You do not have to estimate the storage space in advance B. You can randomly access any element.
C. insert and delete elements that do not need to be moved. D. the required space is proportional to the length of the linear table.
7. The advantage of using a linked list to represent a linear table is that it facilitates insertion and deletion operations)
8. In a single-chain table, the purpose of adding a header node is to facilitate the implementation of operations)
9. The main advantage of the circular linked list is that the entire linked list can be accessed from any node in the table)
10. Linear table L = (A1, A2, A3 ,...... AI ,...... An), which of the following statements is true? (d)
A. Each element has a direct front and a direct back. B. a linear table must contain at least one element.
C. The order of the elements in the table must be from small to large or from large to small.
D. Except for the first and last elements, each element has one and only one direct front and direct back
11. If a linear table uses a chained storage structure, the addresses of available storage units in the memory are required (d)
A. It must be continuous B. Some addresses must be continuous C. It must be discontinuous D. It can be continuous
12. The sequential storage structure of linear tables and the chain storage structure of linear tables are respectively (random access storage structure and sequential access storage structure)
13. A tree is a set of nodes. The number of root nodes is (and only 1)
14. In a full binary tree with a depth of 5, the number of leaf nodes is (31)
15. Binary Trees with three nodes (five forms)
16. If a binary tree has three leaf nodes and eight knots with a degree of 1, the total number of knots in the binary tree is (13)
17. It is known that the binary tree's post-order traversal sequence is dabec, the middle-order traversal sequence is debac, and its pre-order traversal sequence is (cedba)
18. If abdegcfh and dbgeachf are known as the forward and central traversal of a binary tree, the backward traversal of the binary tree is (dgebhfca)
19. If the sequential traversal access order of a binary tree is abdgcefh and the sequential traversal access order is dgbaechf, then the node access order of the sequential traversal is (gdbehfca)
20. database protection includes security control, Integrity Control, concurrency control, and data recovery.

1. in computers, algorithms refer to (accurate and complete descriptions of solutions)
2. Which of the following is NOT the basic feature (infinity) of an algorithm)
Note: The four basic features of an algorithm are feasibility, certainty, poverty, and sufficient intelligence.
3. Which control structures can be combined for algorithms (sequence, selection, and loop)
4. the time complexity of an algorithm refers to the number of basic operations required during Algorithm Execution)
5. The space complexity of an algorithm refers to the storage space required during execution)
6. The purpose of algorithm analysis is to analyze the efficiency of algorithms for improvement)
7. Which of the following statements is true? (c)
A. The algorithm execution efficiency is independent of the data storage structure.
B. The spatial complexity of an algorithm refers to the number of commands (or statements) in an algorithm program.
C. Poor algorithm means that the algorithm must be able to terminate after a limited number of steps are executed.
D. the time complexity of an algorithm is the time required to execute an algorithm program.
8. As a computer discipline, data structure mainly studies the logical structure of data, operations on various data structures, and (data storage structure)
9. In the data structure, data is irrelevant to the computer in use (c)
A. Storage Structure B. Physical Structure C. Logical Structure D. Physical and Storage Structure
10. Which of the following statements is false? (B)
A. The data storage structure is closely related to the efficiency of data processing
B. The data storage structure is independent of the data processing efficiency.
C. the space occupied by the data storage structure in the computer is not necessarily continuous.
D. A logical structure of data can have multiple storage structures
11. The data storage structure refers to the representation of the Data Logical Structure in the computer)
12. The logical structure of data refers to the data structure that reflects the logical relationship between data elements)
13. Data structures are generally divided into linear and non-linear structures based on the complexity of the relationship between the front and back parts of each data element in the data structure)
14. The following data structures with memory functions are (c) A. Queue B. cyclic queue C. Stack D. Sequence Table
15. Which of the following data structures organize data based on the principle of advanced and backward? (B)
A. Linear Linked List B. Stack C. Circular linked list D. Sequence Table
16. recursive algorithms are generally implemented using queues.
17. Which of the following statements about stacks are true? (d) A. data can only be inserted into stacks. B. data can only be deleted from stacks.
C. Stack is a first-in-first-out linear table D. Stack is a first-out linear table
18. elements A, B, C, and D are stored in sequence from the bottom of the stack to the top of the stack. Before the fifth element e is added to the stack, the elements in the stack can go out of the stack, the output stack sequence may be (dcbea)
19. If the stack import sequence is E1, E2, E3, E4, the possible outbound stack sequence is (E2, E4, E3, E1)
20. The benefit of sharing a bucket with two stacks is (saving storage space and reducing the possibility of overflow)
21. when an application needs to output data through a printer during execution, a print job is usually first formed and stored in a specified (Queue) in the hard disk. When the printer is idle, the job to be printed will be taken out of the service first.
22. which of the following statements about queues is true? (c). only data can be inserted in the queue. only data in the queue can be deleted. A queue is a first-in-first-out linear table D. A queue is an advanced linear table.
23. Which of the following statements is true? (d) A. The position of each element in the linear linked list in the bucket must be continuous.
B. the Header element in the linear linked list must be stored in front of other elements. the position of each element in the linear linked list in the bucket is not necessarily continuous, but the Header element must be stored before other elements. the position of each element in the linear linked list in the bucket is not necessarily continuous, and the storage order of each element is arbitrary.
24. Which of the following statements are true? (a) A. Linear table is a linear structure B. Stack and queue are non-linear structures
C. Linear Linked lists are non-linear structures D. Binary Trees are linear structures
25. Linear table L = (A1, A2, A3 ,...... AI ,...... An), which of the following statements is true? (d)
A. Each element has a direct front and a direct back. B. a linear table must contain at least one element.
C. the order of the elements in the table must be from small to large or from large to small D. except the first element and the last element, each other element has one and only one direct front and direct back
26. If a linear table uses a chained storage structure, the addresses of available storage units in the memory are required (continuous disconnections are acceptable)
27. The chain table does not have a feature (B) A. You do not have to estimate the storage space in advance B. You can randomly access any element.
C. insert and delete elements that do not need to be moved. D. the required space is proportional to the length of the linear table.
28. The End Node of the head of a non-empty cyclic single-chain table (pointed by P), meeting (p-> next = head)
29. Compared with a one-way linked list, one of the advantages of a two-way linked list is that it is easier to access adjacent nodes)
30. In (d), as long as you point out the location of any node in the table, you can access all the other nodes in the table from it. A. Linear Single-chain table B. Two-way linked list C. Linear Linked List D. Cyclic linked list
31. The following data structures are non-linear data structures (c) A. Queue B. Linear Table C. Binary Tree D. Stack
32. A tree is a set of nodes, and its root node number is (and only 1)
33. Binary Trees with three nodes (5 forms)
34. The maximum number of knots in layer 8th on a binary tree is (128). Note: 2k-1
35. In a full binary tree with a depth of 5, the number of leaf nodes is (16) Note: 2n-1
36. There are (31) nodes in the full binary tree with a depth of 5. Note: 2n-1
37. If a Complete Binary Tree has 699 nodes, the number of leaf nodes in the binary tree is (350)
Note: The sum points of a Complete Binary Tree are n. If n is an odd number, the number of leaf nodes is (n + 1)/2. If n is an even number, the number of leaf nodes is n/2.
38. The following binary tree is set. The result of sequential traversal of this binary tree is (B)
A. abcdef
B. dbeafc
C. abdecf
D. debfca
39. It is known that the binary tree's post-order traversal sequence is dabec, and the middle-order traversal sequence is debac, and its pre-order traversal sequence is (cedba)
40. If abdegcfh and dbgeachf are known as the forward and central traversal of a binary tree, the backward traversal of the binary tree is (dgebhfca)
41. If the sequential traversal access order of a binary tree is abdgcefh and the sequential traversal access order is dgbaechf, then the node access order of the sequential traversal is (gdbehfca)
42. The length of a string is (the number of characters contained in the string)
43. There are two strings p and q. Calculate the computation name (pattern matching) of the first position q appears in P)
44. The number of edges in the connected graph of N vertices is at least (N-1)
45. The number of edges of a strongly connected graph with n vertices must have at least (N)
46. Perform sequential search on the linear table with the length of n. In the worst case, the number of comparisons required is (n)
47. The simplest exchange sorting method is (Bubble Sorting)
48. Assume that the linear table length is N. In the worst case, the number of comparisons required for Bubble Sorting is (N (n-1)/2)
49. On the premise that the sequence of elements to be sorted is basically ordered, the most efficient sorting method is (Bubble Sorting)
50. In the worst case, the minimum time complexity of the following sequential methods is (heap sorting)
51. Hill sorting method (insert sort)
52. Heap sorting method (select class sorting)
53. Which of the following sorting methods requires the largest memory volume (Merge Sorting)
54. It is known that each element in data table A is not far from its final position. To save time, use (insert directly for sorting)
55. The basic features of an algorithm are feasibility, certainty, poverty, and sufficient intelligence.

1. An algorithm is usually composed of two basic elements: calculation and operation of data objects, and control structure of algorithms.
1. The complexity of algorithms mainly includes time complexity and space complexity.
2. The number of storage units required to implement the algorithm and the workload of the algorithm are called the space complexity and time complexity of the algorithm respectively.
3. Data Processing refers to operations on each element in a dataset in various ways, including insert, delete, search, and change operations, as well as analysis of data elements.
4. Data structure refers to a set of correlated data elements.
5. Data structures are divided into logical and storage structures. Linear Linked lists are storage structures.
6. The data structure includes the logical structure of the data and the storage structure of the data.
7. The data structure includes the logical structure of the data, the storage structure of the data, and Operation operations on the data.
8. Any relationship between data elements can be described by the forward and subsequent relationships.
9. The logical structures of data are linear and nonlinear.
10. Common storage structures include sequential, Link, index, and other storage structures.
11. The sequential storage method stores logically adjacent nodes in storage units adjacent to physical locations.
12. There are three basic stack operations: the elements of the inbound stack, the rollback stack, and the read stack top.
13. There are two basic operations for a queue: The queuing operation and the backend operation.
14. In practical applications, a stack with a chain can be used to collect all idle storage nodes in a computer storage space. A stack with a chain is called a usable stack.
15. The storage structure of stacks and queues is chained storage and sequential storage.
16. When a linear table uses a sequential storage structure for storage, its main feature is that adjacent nodes in the logical structure are still adjacent in the storage structure.
17. There are two basic operations for cyclic queue: queuing and unqueuing. Each time you perform the calculation, the team's tail pointer enters 1.
18. When the cyclic queue is not empty and the tail pointer is the opposite pointer, it indicates that the cyclic queue is full and cannot be entered into the queue. This situation is called overflow.
19. When the cyclic queue is empty, it cannot be dequeued. This is called underflow.
20. In a 25-type cyclic queue, if the first pointer is front = 16 and the last pointer is rear = 9, there are 18 elements in the cyclic queue. Note: When rear <front, the number of elements = total capacity-(Front-rear );
When rear> front, the number of elements = rear-front.
21. In a 15-node cyclic queue, if the first pointer is front = 6 and the last pointer is rear = 9, there are three elements in the cyclic queue.
22. Sequential search is generally used to find the specified element in a linear table.
23. The simplest method for storing linear tables in a computer is sequential storage.
24. In programming languages, a one-dimensional array is usually defined to represent the sequential storage space of a linear table.
25. In the chained storage mode, each node is composed of two parts: one is used to store the data element value, which is called the data field, and the other is used to store the pointer, which is called the pointer field. The pointer is used to point to the first or last node of the node (that is, the front or back part ).
26. In a linear single-chain table, each node has only one pointer field, and the pointer can only find the successor node, but cannot find the precursor node.
27. To insert a new element into a linear linked list, you must first assign a new node to the element to store the value of the element.
28. After deleting an element in a linear linked list, you only need to change the pointer field of the previous node of the deleted element.
29. Using a linked list to represent a linear table is advantageous in facilitating insertion and deletion.
30. In the tree structure, the root node does not have the front part.
31. In the tree structure, the number of subsequent parts owned by a node is called the degree of the node. The leaf node degree is 0.
32. If a binary tree contains three leaf nodes and eight knots with a degree of 1, the total number of knots in the binary tree is 13.
33. If a Complete Binary Tree has 739 nodes, There are 370 leaf nodes in the binary tree.
34. If a Complete Binary Tree has 700 nodes, There are 350 leaf nodes in the binary tree.
35. Based on the principle of first left and right, based on the order of access to the root node, binary tree traversal can be divided into three types: pre-order traversal, middle-order traversal and post-order traversal.
36. If the string S = "program", the number of its substrings is 29. Note: n (n + 1)/2 + 1
37. If the string S = "mathtypes", the number of its substrings is 46.
38. when inserting a new element or deleting an element to a linear table with a length of N, the number of comparisons required in the worst case is N.
39. Perform sequential search in an ordered linear table with a length of N. In the worst case, the number of comparisons is N.
40. Perform binary search in an ordered linear table with a length of N. In the worst case, the number of comparisons is log2n.
41. In an ordered linear table with a length of N, when the probability of inserting an element at any position is equal, the average number of moving elements required for inserting an element is n/2.
42. Sorting is an important operation in computer programming. Common sorting methods include insert sorting, exchange sorting, and selection sorting.
43. Quick sorting can eliminate multiple reverse orders through one exchange.
44. The key to quick sorting is to split linear tables.
45. The number of element exchanges in the best case of the Bubble Sorting Algorithm is 0.
46. In the worst case, the time complexity of Bubble Sorting is n (n-1)/2.
47. For linear tables with a length of N, in the worst case, the number of comparisons required for quick sorting is n (n-1)/2.
48. In the worst case, the number of comparisons required for simple insertion sorting is n (n-1)/2.
49. In the worst case, the number of times that the hill sort needs to be compared is O (n1.5 ). Note: The brackets are the 1.5 power of N.
50. In the worst case, simply select the number of times to be compared for sorting as N (n-1)/2.
51. In the worst case, the number of heap sorting times to be compared is O (nlog2n ).
52. The average time complexity of a fast Sorting Algorithm with N input is O (nlog2 N ).

 

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.