"Big Talk Data Structure" section reading notes

Source: Internet
Author: User

Chapter Notes
1. Data Structure Introduction
  1. Data structure: A collection of elements that exist in one or more specific relationships with each other.

  2. Data: Is the symbol that describes the objective thing, the object that the computer can manipulate, the symbol set.

  3. Data elements: are the basic units that make up the data and have a certain meaning, also known as records. Like people in the human race.

  4. Data item: A data element can consist of several data items. Like a person's eyes and ears. is the smallest unit that is indivisible.

  5. Data object: Is a collection of data elements of the same nature, and is a subset of the data. People have the same data items as names.

  6. Logical structure: Refers to the interrelationship between data elements in a data object. Contains collections (no associations), linear (one-to-one), tree (one-to-many-level relationships), graphics (many-to-many).

  7. Physical structure: Refers to the storage form of the logical structure of data in a computer. With sequential storage structure (address contiguous storage unit, logical relation of physical relationship consistent array), chained storage structure (stored in any unit, can be continuous or discontinuous, cannot reflect the logical relationship, need to hold the data element address).

  8. Data type: Refers to a set of values of the same nature and the assembly of some operations defined on this collection, such as integral type.

  9. Abstract data type: Refers to a mathematical model and a set of operations defined on the model, such as coordinate points, Mario (logical relationship between data elements, related operations, etc.).

  10. Data Items--data objects--data elements.

2. Algorithms
  1. Algorithm: is a finite sequence that solves a specific problem solving step description, which is represented as an instruction in a computer, and each instruction represents one or more operations.

  2. Algorithm features: input (0 or more), output (one or more), poor (no infinite loop), deterministic (precise), and feasibility (limited number of times completed).

  3. Algorithm requirements: Correctness, readability, robustness, high efficiency, low storage.

  4. Algorithm efficiency measurement method: Post-mortem method (test data), pre-Analysis estimation method (strategy, code quality, input scale, instruction speed).

  5. The run time of a program depends on the quality of the algorithm and the input scale of the problem, represented as a function of the input scale with the number of basic operations (e.g., 2 =n of F (n)).

  6. Function progressive growth: given 2 functions f (n) [2n^3+1] and G (n), if there is an integer n, so that for all n>n,f (n) is always greater than g (n), then it is said that f (n) growth is faster than g (n).

  7. When judging an algorithm's efficiency, constants and other minor items in a function can often be ignored, but should focus on the master item (the order of the highest order, X in N^x), and an algorithm that increases with n will be better or worse than the other.

  8. Time complexity Definition: The total number of executions of a statement T (n) is a function of the problem size n, and then the T (N) Order of magnitude is analyzed with n variation. The time complexity of the algorithm, that is, the time measurement of the algorithm, the block T (N) =o (f (n)). It indicates that the growth rate of the algorithm execution time is the same as the growth rate of f (n), which is called time complexity with the increase of the problem size n.

  9. The derivation of the large O-order method: 1. Replace all addition constants with 1; 2. In the modified run Count function, only the highest order is retained, 3. If not 1, the multiplication constant is removed. You can get the Big O-order.

  10. Constant order: does not change with N, and its time complexity is always O (1).

  11. Linear Order: Analyze the running situation in the loop structure, determine the number of times a particular statement or statement set runs, and if there is only one loop and the memory is O (1) complexity, then the algorithm has an O (n) time complexity;

  12. Logarithmic order: O (LOGN) indicates that log is a logarithmic sign ().

  13. Square Order: such as nested loops, such as the same number of internal and external cycles O (n^2), the number of internal and external cycles O (m*n).

  14. Commonly used time complexity from small to large ordering: O (1) constant order <o (LOGN) logarithmic order <o (n) Linear order <o (n^2) square order <o (n^3) cubic order <o (2^n) exponential order <o (n!) Factorial order <o (n^n).

  15. There are 2 methods for algorithm analysis: 1. Is the average of all cases, called the average time complexity, and 2. Is the worst-case complexity, known as the worst time complexity. Generally mean the worst time complexity.

  16. Algorithm space complexity: by calculating the required storage space for the algorithm, the computational formula for the spatial complexity of the algorithm is as follows: S (n) =o (f (n)), where n is the scale, and F (n) is the function of the statement about the storage space occupied by N.

3. Linear table
  1. Linear table: A finite sequence of 0 or more data elements, the first element has no precursor, the last element has no successor, and the intermediate elements are known to be precursors and successors. The number n (n>=0) of a linear table is defined as the length of a linear table, which is called an empty table when n=0.

  2. Linear table Production operations: Initialize empty tables, determine whether null, empty, get the specified position element, find out whether the element exists, insert, delete, return the number of elements.

  3. The sequential storage structure of linear table refers to the data element of linear table stored sequentially by a contiguous storage unit, in fact, the position, the maximum capacity, the current length.

  4. The length of the array is the length of the storage space that holds the linear table, immutable. The length of the linear table is the number of elements, variable.

  5. LOC represents a function to obtain storage location, the performance of a random storage structure is O (1)

  6. The sequential storage structure of linear tables reads, writes the complexity of O (1), inserts or Deletes O (n). Advantages: No additional space, fast access; Disadvantage: Insert Delete to move a large number of elements, when the length of large changes in the size of the space is difficult to determine, resulting in storage space fragmentation.

  7. Single linked list: The storage image contains data fields and pointers (or chains) indicating the location of the successor information, and the links of N nodes (the storage image of a subscript i) Form a linked list, which is the chain storage structure of the linear table, because each node contains only one pointer field, so it is called a single-linked list. Single-linked lists are more efficient than linear tables for frequently inserted or deleted data operations.

  8. The head pointer is the first pointer to the list, and the head node is the node that precedes the first element node (optional, which facilitates uniform operation on the first node).

  9. Single-linked list insert Delete: From the first node to find, when to the specified location, the node pointer to follow the subsequent or new node address, and then take the value to free memory.

  10. Single-linked list with head interpolation and tail interpolation, delete the first to start by assigning the next object to a temporary variable, then releasing the object and then continuing with the next next delete.

  11. Linear table is divided into sequential storage structure can be random access array by subscript to get the value is called the sequential table, the chain-stored linear table called the single-linked list is sequential access, because the pointer field to find the next element.

  12. If the number of elements is known, and the insertion and deletion of fewer application order structure, if the frequent additions and deletions and the number of unknown, apply chain structure.

  13. A linked list, described in arrays, is called a static list (a way to implement a single-list capability for a high-level language design that cannot manipulate pointers). Advantages: Only the cursor needs to be modified when inserting and deleting, disadvantage: No random reading and the length is difficult to determine.

  14. Circular linked list: The pointer of the end node in the single-linked list is driven by to the head node (optional head node), and a ring is called a single-loop linked list.

  15. Doubly linked list: In each node of a single-linked list, set a pointer field to its predecessor node.

4. Stacks and queues
    1. A stack is a linear table (magazine) that restricts insertions and deletions only at the end of the footer, and the queue is a linear table that allows only one end of the insert operation, while the other end is a delete operation.

    2. The one end of the Allow insertion and deletion is called the top of the stack, and the other end is called the bottom of the stack (bottom), and the stack is called the LIFO linear table LIFO structure. Insert (push) is known as stack, stack, delete (pop) called Make stack, stack.

    3. The order of the stack is stored O (1): The sequence stack will be subscript 0 of the end as the bottom of the stack, if the stack length is stacksize, the top must be less than he, empty stack to determine the condition is top equals-1.

    4. If one end increases one end, the stack can be horizontally combined to share space.

    5. The chain storage structure of the stack O (1): Chain stack, no head node, top=null is empty stack, stack top placed on the single-linked list head, there is no stack full condition.

    6. If the stack is in use the element changes unpredictably best with the chain stack, if the change in the controllable range is used in the sequential stack.

    7. Stack applications: 1. Recursion (Fibonacci sequence, front 2 number and next number), 2. Arithmetic (1. Symbol in the middle of the angular infix expression; 2. Operator after 2 number of angular suffix expression, inverse Poland).

--------------------------------------------------------------------------------------

    1. The queue is a first-in, FIFO linear table, short ( First in first Out,fifo), allows one end of the insertion to be the end of the queue, allowing the deletion of the team header.

    2. Queue storage: Sequential storage Each time an element is deleted, all subsequent elements are moved forward, False overflow may occur if you use 2 pointers to point to the tail of the team head.

    3. Queue-ordered stored circular queue: In order to resolve false overflow, the sequential storage structure of the queue's tail-to-toe is called the cyclic queue.

    4. Queue full condition (front points to the team head pointer, rear points to the next available location pointer): (rear-front+ Queuesize)%queuesize==front, (rear may be larger than front, or smaller than front).

    5. Chain queue: The chain storage structure of a queue is actually a single-linked list of linear tables, except that it only has a tail-in header.

    6. It is recommended to use a circular queue if the maximum queue length can be determined, otherwise the chain queue is used.

    7. Stacks: sequential stacks (two stacks of shared space), chain stacks, queues: sequential queues, circular queues, chain queues.

5. String
  1. String: String is a finite sequence of 0 or more characters, also called a string.

  2. ASCII is a 8-bit binary representation of a total of 256 characters, can meet English, Unicode 16-bit 650,000 characters including the ethnic characters.

  3. The elements in a string consist only of one character, and the neighboring elements have precursors and successors.

  4. Sequential storage structure of strings: the sequence of characters in a string is stored in a contiguous set of storage units, usually defined by a fixed-length array.

  5. Chained storage structure: one node stores multiple characters, and the last node does not fill with special characters, and the whole is inferior to sequential storage.

  6. Simple pattern matching algorithm: The locating operation of a substring is often called a pattern match of a string. Worst-Case Complexity O ((n-m+1) *m).

  7. KMP (Knut, Morris, Pratt) pattern matching algorithm: Automatically skips the position of a matched main string based on the substring repetition.

6. Tree
  1. Trees: The tree is a finite set of n (n>=0) nodes. N=0 is called an empty tree. In any non-empty tree: 1. There is only one specific node called root (Root); 2. When n>1, the remaining nodes can be divided into m (m>0) disjoint finite set T1, T2, where each set itself is a tree, and is called the root of the subtree (subtree).

9. Sort
  1. Sequencing Stability: If the pre-R1 leading R2, if the R1 is still the leading R2 is stable, the reverse order method is not stable.

  2. Sort: All records are placed in memory; out of order: multiple data exchange outside memory. The

  3. Bubble sort, simple selection sort, and direct insert sort are simple algorithms, while Hill sort, heap sort, merge sort, quick sort are improved algorithms.

  4. Bubble sort: 22 compares the keywords of adjacent records if the reverse order is exchanged until there are no reversed records. The Minimum order table O (n) the largest inverse table O (n^2);

  5. Simple selection sorting algorithm: Is the n-i of the key words between the comparison, from N-i+1 records to select the minimum number of records, and I (1<=i<=n) records Exchange. The complexity is O (n^2), which outperforms the bubbling algorithm in performance.

  6. Inserts the sort directly: Inserts a record into an ordered table that is already sorted, resulting in a new, sequential table with a 1 increase in the number of records. Performance is better than bubbling and simple selection of sorting performance.

  7. Hill sort algorithm: Groups the elements according to one increment, inserts the grouping into the sort, and then merges the groupings before inserting the sort. The

  8. Heap is a complete binary tree with the following properties: The value of each node is greater than or equal to the value of its left and right children, called the Big Top heap, or the value of each node is less than or equal to the value of its left and right child nodes, and becomes a small top heap.

  9. Merge algorithm: 22 groups synthesize ordered tables, and then combine them with other sibling tables until they are merged into an ordered table.

  10. Quick sort: Divides the records to be sorted into separate two parts by a single pass, while some of the recorded keywords are smaller than those of the other record, then the two parts of the records can be sorted separately to achieve the order of the whole sequence.

"Big Talk Data Structure" section reading notes

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.