Data structures and algorithms (1)-Basic concepts

Source: Internet
Author: User
Tags abstract data structures
Basic Concepts

I. Data and structure

Data: All of the objects that can be entered into a computer and can be processed by a computer are collectively referred to as a specific symbolic representation of the information processed by the computer.

Data elements: An "individual" in the data, the basic unit discussed in the data element architect's structure, but not the smallest.

Data item: The smallest unit discussed in the data structure, and the collection of database element data items

For example: athlete (data Element)

Name Club Date of birth Date of participation Duties Performance
(Data item)

Data

A collection of data elements with structures

For example, a 12-bit decimal book can be represented in three 4-bit decimal digits

3210,7689,9021->A1 (3210), A2 (7689), A3 (9021)

A1, A2, A3 there is a "order" relationship between the order reversal of the unequal.

Another example, a two-dimensional array of 2 rows and 3 columns {A1,A2,A3,A4,A5,A6}

A1 A2 A3
A4 A5 A6
Order Relationship of rows:

Row={<a1,a2>,<a2,a3>,<a4,a5>,<a5,a6>}

Order Relationship of columns:

Col={<a1,a4>,<a2,a5>,<a3,a6>}

The logical structure of the data can be attributed to the following four classes:

Linear structure


Tree-shaped structure


Graphic structure


Collection structure


The form of the data structure is defined as:

Data structure a two-tuple

Data_structures = (d,s),

Where: D is a finite set of data elements, and S is a finite set of relationships on D.

Storage structure of data: the image of logical structure in memory

Image method of data element:

Data elements represented by a bit string of bits (bit)

Image method of the relationship set: (Means of <x,y>)

Sequential mappings: A constant c is the difference between the storage location and the storage location of the x, and C is an implied value, and the entire storage structure contains only the information of the data element itself.


Chain Image: The subsequent relationship with additional information (pointers)

You need to indicate where y is stored with an additional information of one and X in the first issue.


Data type

A data type is a collection of values and a generic term that defines a set of operations on this collection.

Abstract data type referred to as ADT

Refers to a mathematical model and a set of operations defined on this mathematical model.

ADT has two important characteristics:

Data abstraction: When using ADT to describe an entity handled by a program, the emphasis is on its intrinsic characteristics, its ability to function, and its interface with external users (that is, using his method for the world)

Data encapsulation: Separates the external characteristics of an entity from its internal implementation details and hides its internal implementation details from external users

Description of the abstract data type: Be familiar with that data type available (D,S,P) ternary representation. where d is the data object, S is the set of relationships on D, and P is the basic set of operations on D.

Representation and implementation of abstract data types: Abstract data types need to be implemented through intrinsic data types (data types implemented in the Advanced programming language).

Second, the measurement of algorithms and algorithms

Algorithm

An algorithm is a finite-length sequence of operations that is prescribed to solve a certain type of problem. An algorithm must meet the following five important characteristics:

1, Poor: Each step of the algorithm can be completed within a limited time;

2, certainty: the operation that should be performed in each case has the exact stipulation in the algorithm, so that the executor or reader of the algorithm can define its meaning and how to execute it. And under any conditions, the algorithm has only one execution path;

3, Feasibility: All operations in the algorithm must be basic enough, can be achieved through the implementation of the basic operation of a finite number of times;

4, with input

5, with output

Design principles:

Correctness, readability, robustness, high efficiency and low storage requirements

Algorithm efficiency measurement methods and guidelines:

Post-mortem statistical method

Pre-analysis and estimation method (selection strategy, problem size, programming language, the quality of the machine code generated by the compiler, and the speed of the computer execution instructions)

As the size of the problem increases, the growth rate of the algorithm execution time is the same as the growth rate of f (n), which can be recorded as

T (n) = O (f (n))

Called T (N) is the time complexity of the algorithm

Algorithm = control Structure + original operation (operation of the intrinsic data type)

Execution time of the algorithm =∑ (i) Execution time of the original operation (i) (The execution time of the algorithm is proportional to the sum of the number of executions of the original operation)

With the increase of the problem size n, the growth rate of the required storage of the algorithm is the same as that of G (N).

S (n) = O (g (n))

is called the space complexity of the S (n)-bit algorithm. (Space occupied by input data, space occupied by the program itself, space occupied by auxiliary variables)


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.