Data structure note (Hao Bin presenter) (updated September 21)

Source: Internet
Author: User

Textbook-Extracurricular books recommended

Gao Yifan (pseudo algorithm → true code)

Data Structure Overview
Defined
How do we store large and complex problems in real life in a specific data type and a specific storage structure into the main memory (memory), and on this basis for the implementation of a function (such as finding an element, delete an element, sorting all elements), the corresponding operation is called the algorithm

Data structure = individual + individual relationship
Algorithm = operation on stored data

Algorithm
Methods and steps for solving problems

Criteria for measuring algorithms
1. Complexity of Time
The approximate number of times the program will be executed, not the time it takes to execute
2. Complexity of space
The maximum memory occupied by the algorithm during execution
3. Degree of difficulty

4. Robustness

The status of data structures
Data structure is the core course in software

Program = data storage + data manipulation + languages that can be executed by the computer

Last edited on August 18, 2015, 23:10:06


Pre-knowledge
Pointer
The importance of pointers:
Pointer is the soul of C language
Defined
Address
The address is the number of the memory unit
Non-negative integer starting at 0
Range: 0--ffffffff (0--4g-1)

Pointer:
The pointer is the address, the address is the pointer
A pointer variable is a variable that holds the address of a memory cell
The essence of a pointer is a non-negative integer with restricted operation

Classification:
1. Basic types of pointers

2. Pointer and array relationships

Last edited on August 19, 2015, 23:06:51

Structural body
Why is there a struct
In order to represent some complex data, the common basic type variable does not meet the requirements

What do you mean, structural body
Structs are composite data types that users define themselves according to their needs

How to use the structure body
Two different ways
struct Student st = {, "Zhangsan", 20};

struct Student * PST;

1.
St.sid
2.
Pst->sid
This member of the SID in the struct variable that the PST points to

Precautions
struct variables cannot be subtraction, but can be assigned to each other
Common structure variables and structure pointer variables as function-parameter-transfer problems

Use memory---across functions to implement with dynamic memory allocation
In general, the memory is freed after the custom function ends, and only the dynamically allocated memory does not meet the free function, and the custom function ends, but the memory still exists.

Last edited on August 20, 2015, 23:00:44

Module one: linear structure [put all the nodes in a straight line]
continuous storage [Array]
1. What do you call an array
Same element type, same size
2. Advantages and disadvantages of arrays


discrete storage [Linked list]
Defined:
N Nodes Discrete distribution
Connect to each other by pointers
Each node has only one precursor node, and each node has only one subsequent node
The first node has no precursor, and the tail node has no subsequent nodes.

Professional terminology:
First node:
First valid node
Tail Node:
Last valid node
Head node:
The head node is the same as the data type and the first node type.
The node before the first valid node
The head node does not hold valid data.
The main purpose of the head node is to facilitate the operation of the linked list.
Head pointer:
Pointer variable pointing to the head node
Tail Hands:
Pointer variable pointing to tail node

If you want to work with a linked list through a function, we need to accept at least what information is linked to the list:
Only one parameter is required: the head pointer
Because we can figure out all the other information in the list through the head pointer.



single-linked list
doubly linked list:

Circular link List
Can find all the other nodes through any node.
Non-circular linked list
Algorithm:
Traverse
Find
Empty
Destroyed
Request length
Sort
Delete a node
Inserting nodes
Algorithm:
The narrow algorithm is closely related to how data is stored.
The generalized algorithm is independent of the way data is stored
Generic type:
The effect of using a technology is: different storage methods, the same operation is performed

Chain list sorting algorithm

1  for(i=0,p=phead->pnext; i<len-1; ++i,p=p->pnext)2     {3          for(j=i+1,q=p->pnext; j<len; ++j,q=q->pnext)4         {5             if(P->data > Q->data)//similar to a[i in arrays] > A[j]6             {7t = p->data;//similar to the array: t = a[i];8P->data = q->data;//similar to the array: a[i] = a[j];9Q->data = t;//similar to a[j in an array] = t;Ten             } One         } A}

List of advantages and disadvantages:

One of two common applications for linear structures stack

Two common applications of linear structures in the second queue


Data structure note (Hao Bin presenter) (updated September 21)

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.