Data Structure 1 Introduction / summary

introduction

1. The basic concept of a data structure

1. The data elements are the basic units of data
2. Data item data is the smallest unit
3. Data objects: a set of data elements of the same nature

4. Data type
abstract data types in a data structure, a data object, data relationships, the basic operation of three parts

The logical structure of the data
(1) linear structure: linear form, limited linear table: Stack / Queue
wherein: one data element

(2) non-linear structure: Tree / FIG
wherein: many data elements

6. The physical structure of the data
(1) sequential storage method

(2) the chain storage method: list

(3) The method of storing index

(4) storing a hash method (the Hash)
test sites: a hash table is a table in order to expand the
logic table element is not present 2.hash

Test sites:
independent data storage structure and is 1 (logical structure is a)
a stack (logical structure)
doubly linked list (Storage Structure)
hash table (the expanding sequence table)
trail tree (Storage Structure)
sequence list (sequential storage structure)


2. The basic concepts of algorithm

1. Algorithms: Solving the Problem Steps sequence (not the program)
and the program have different meanings (even with solving a problem)

2. The computer algorithm characteristic
finite resistance (after the end of a limited step)
deterministic (unambiguous)
enforceable (perform basic operations completed within a limited time)
input and output

3. algorithm design goals
correctness, readability, robustness, high efficiency and low memory requirements

Test sites:
a calculation amount of size: 1. algorithmic complexity
initial state 2. The time complexity of the algorithm depends on the scale of the problem ① ② data to be processed
3. Work place: the ancillary space is constant (independent of the problem size n )
4.


3. bytes, characters, a storage unit

Byte (Byte) ⇒ a memory unit (8-bit binary)

Characters (Chinese English) ASCII code, an English one byte characters, a Chinese two-byte


4. Storage

(1) sequential storage
order storage may store not only a linear structure (tree, etc. may also be stored)

(2) a chain storage

Test sites

(1) no matter how complex data structures are stored, and the total structure can order chain structure is configured to achieve


Algorithm / Code summary

A. Familiar (Code fill in the blank)

1. A polynomial addition (CD 43)

2. insert a doubly linked list

2. Hill sorting (trip)

3. Heap Sort (14 years)



II. Master (writing the code)

1. The structure is defined

Circular queue type definitions (94)



2. Algorithms

(1) linear table
will not lead single chain reversal node (97)

(1) stacks and queues
circular queue deletion, insertion algorithm

(2) Tree and FIG
print all paths from the root node to the leaf node (94)

Print all ancestor node (data field value of x) of the node data field (96)

(3) Find

(4) Sorting
quicksort (14)


III. Had over-the-test algorithm textbooks

1. Fibonacci

2. sibling child list structure tree, the tree recursively height
(max {left subtree height, the height of the right subtree} +1)

3. Non-recursive quicksort (familiar?)

4. Insert the stack algorithm (95)

Time Complexity summary

A. Tree-related

Basics:
(rounding log₂ (n) at) (1) complete binary tree of height 1, or (log₂ rounding the (n + 1))

(2) binary search tree determines the final shape will be appreciated that one leaf node is a complete binary tree irregular distribution
⇒① complete binary tree with the same depth
⇒② complete binary tree search is successful and the same number of times (the last leaf node distribution layer does not affect Find the number of successes)


1. The complete binary tree algorithm is mainly (or leaf nodes distributed arbitrary determination binary search tree) to the leaf nodes from one node operation
⇒ time complexity is considered to be 0 (log₂n)

need not be strictly considered starting from the root node, or from the middle of a node (Tianqin 247)

(1) the complexity of insertion sort binary insertion time is preferably
positive, only to find the insertion position determination ⇔ binary search tree from the node to a leaf node Operation ⇒0 (nlog₂n)

(2) heapsort



II. Figure relevant

1.KMP time complexity of the algorithm is 0 (m + n)
text string of length n, the pattern string length m, the string matching

1. The minimum spanning Prim: O (n²), only the relevant apex (FIG suitable dense) and FIG.

2. Kruskal minimum spanning tree: O (elog₂e), is determined by the number of edges in the graph (FIG adapted sparse)


Published 46 original articles · won praise 15 · views 30000 +

Guess you like

Origin blog.csdn.net/qq_41850194/article/details/102457972