Data structure, algorithms, personal understanding

Source: Internet
Author: User

Also in a netizen discussion process to understand, has been on the data structure and algorithm is the soul of the program does not understand the sentence.

Data structures and algorithms so important, how can I not feel it? How to think this sentence, all feel is fart words, and did not say the same.

These problems occur because:

One is because they usually write the program relatively low-end, subtraction, if else switch to solve the problem, the fundamental design of data structures and algorithms to explore.

Two are data structures and algorithms that are understood separately.

For example, I can understand the importance of the data structure for the program, forget the file in which to see, the data structure is our real life needs to solve the problem of the abstract.

A class of students, each got how many points, I can use the number and score, two-dimensional array to represent.

What is the name of the student, gender, married or not, score, the type of data after more, you can use the structure to express.

The core of the problem we are trying to solve is the abstract data extracted from real life. arrays, structures, can participate in, help me record.

But this is a hairy relationship with the algorithm?

At most I look for, modify these data, I feel these simple operation is not called Algorithm it???

What is the algorithm?? In the end, WTF

I also used the algorithm alone, such as in the 12864 LCD screen, there is a point algorithm, called Bresenham.

Through the understanding of this algorithm, also know that, well, this algorithm is really cow ah.

Draw a straight line, I am sure to draw a point, where is the next point to draw? Lippy's idea is to get the starting point and end point, by getting the first equation of the line, to the coordinates of each point (x, y)

But this algorithm hanging ah, the concrete realization forgot, good early things before the amount. Without complicated operations, you can get the coordinates of the next point based on a point.

Oh, yes, there are various sorting algorithms that have been learned, what bitmap algorithms,

Always feel that the algorithm this thing is not generally able to use, are for specific occasions used.

So understand that this is not the program can leave the algorithm exist?

Can the algorithm and data structure be separated, who say they must be together??! Ah, there's no good explanation in the textbook.

So the time is a year past, I do not know how to fat four.

Until one day ...

The Netizen discussed a problem of color recognition.

A program, color recognition, is the camera to take a picture, where a point taken out of the color value of the 8*3 bit, every 8 bits represents one of the RGB.

Then set the standard color, and the color value of this point to calculate the deviation from the standard color of the smallest deviation, it is considered which color.

According to reason, I think this program is OK, can use.

But the Netizen said:

1. First RGB color is a vector, directly calculated with a scalar, is wrong

2. More seriously, this algorithm can run on the premise that the ambient light does not change, the camera is not replaced, the camera exposure rate is unchanged.

So the environment light changes, this algorithm is powerless, this set of code is too bad!

The words are amazing, I realized what the algorithm is.

Algorithm is, a kind of idea, according to this idea to write out of code.

And this code can complete the problem we want to solve, the popular saying is to run, can get the results we want.

This code can be very elegant, like the above mentioned Bresenham Ah, quick sort, bubble sort,

can also be very simple, very beggar, we usually write code, although what if else switch, but this is also a problem-solving ideas, and this idea is the algorithm of the program!

I suddenly realized that the algorithm is not what advanced things, he is we use the program to describe, solve the problem of ideas!!! With the implementation of this algorithm, write code complex or not, elegant or not a half-penny relationship!!!

When we come up with a thought to solve the problem, we must combine the data structure that we abstracted from the reality to get the complete program.

such as lighting.

Data structure: Bit LED

Algorithm: The level change of the PIN is generated by modifying the register.

Finish

Data structure, algorithms, personal understanding

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.