Concept and classification of data structures

Source: Internet
Author: User

1.1 Basic Concepts
In the computer, data structure refers to the computer storage, the organization data Way
Describes the logical relationship between data elements and the computer
In the form of storage, there is one or more specific relationships with each other
The collection of data

The choice of data structure determines the time efficiency of program execution
and storage efficiency.

Computer program = data structure + algorithm

1.2 3 levels of data structures
(1) Logical Structure
-primarily describes the logical relationship between data elements

(2) Physical Structure
-primarily describes the positional relationships between data structure elements, which are
The form of storage in a computer

(3) Operation structure
-Main description of how data structures are implemented and common basic operations

1.3 Classification of logical structures
(1) Set structure
-Main description All data structure elements belong to a collection,
Do not emphasize the relationship between data elements
Such as:
Collectively referred to as a class
2 3 5 7 11 13 17 ... All belong to prime number/prime number

(2) Linear structure
-Primary description of a one-to-one relationship between all data elements
There must be a unique first element in the structure
There must be a unique trailing element in the structure
In addition to the first element, each element has and has only one forward element
In addition to the tail element, each element has and has only one successor element

Such as:
Waiting for the bus to row the team
Bracelet

(3) tree-shaped structure
-primarily describes a one-to-many parent-child relationship between data elements
The whole tree structure has only one element, called the root element.
The top element in the entire tree structure is called the leaf element.
In addition to the root element, all elements have and have only one pre-trend element
All elements except the leaf element can have multiple successive elements

Such as:
Tree
Genealogy

(4) mesh structure (graphic structure)
-Main description of multiple-to-many cross-mapping structures between data elements
Elements in the structure can have multiple pre-and multiple successor elements

Such as:
Spider web
Racket

1.4 Classification of physical structures
(1) sequential storage structure
-holding a contiguous set of storage units in turn to logically adjacent elements
If each element in the table has the same properties,
Then each element occupies the same storage unit
Described by the array type in C language

Thinking:
What are the advantages of sequential storage architecture and what are the drawbacks?
Advantages:
A. You only need to request storage space for the data element itself
No additional storage space is required to express the relationship between data elements
Thus saving more memory space
B. Support for subscript access, can achieve random access

Disadvantages:
A. Application storage space is the number of data elements that need to be specified beforehand to determine
The size of the storage space, if the storage space is too small, not enough, if
The space is too large to cause waste
B. Application of contiguous storage space results in low utilization of memory space
Because the memory space of the small block may not be used
C. Insert/delete element Yes, you may need to move a large number of elements


(2) chain-type storage structure
-Use a set of discontinuous storage units to store all the elements without requiring
Logically adjacent elements are also adjacent to each other in the physical location, but for each element
Constructs a separate storage unit called the node

Each node consists of two parts, each of which holds the data elements themselves and
Record the first address of the next node

There is no specific data type in the C language to describe the chain-store structure
Need our programmer to manually code the implementation

Advantages:
A. There is no need to pre-establish the number of data elements to determine the size of the storage space when requesting storage space
B. No need to apply for contiguous storage space Therefore, the utilization ratio of the storage space can be used scattered small block of memory
C. Inserting/deleting elements is convenient and does not need to move a large number of elements

Disadvantages:
A. When requesting memory space, in addition to requesting storage space for the data element itself,
Additional storage space is required to express the data
Elements, so you want to consume a larger amount of memory space
B. No support for subscript access, nor convenient for random access

1.5 Relationship of logical structure and physical structure
In general, what physical structure is used to implement the logical structure
There is no clear provision, usually based on the degree of ease of implementation,
And in terms of time complexity and space complexity,
To choose the right physical structure, and not to rule out a logical structure
The use of a variety of physical structures to achieve the situation

1.6 Arithmetic Structure
(1) Creation and destruction
Request storage Space = = Build data structure = free storage space = Destroy data structure

(2) Insert/delete
Insert-add Element
Delete-Reduce element

(3) Modify and find
Iterate through all the elements in the data structure
Modifies the specified element value

(4) Sort
Some common sorting algorithms and search algorithms are used

Concept and classification of data structures

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.