What are data structures and algorithms?

Source: Internet
Author: User

The data structure is generally and the algorithm is said together, called data structure and algorithm. This knowledge is very good to understand, but some teachers every day XXX's simply unintelligible. So I want to write this simple tutorial, the knowledge is shallow, please forgive me.

  What is a data structure?

The data structure is a collection of related datasets, with sequential tables, linked lists, stacks, queues, trees, and graphs. Wait for these kinds of structures.

  What is an algorithm?

Algorithm is a way to solve the problem, there are many algorithms to solve a problem, but there is always an algorithm better than the other way, either save time, or high efficiency. For example, from 1 to 100, you can certainly come up with a for loop that loops 100 times. You can also use the Gauss Method (1+100) *50 to calculate, who is superior to the poor at a glance.

  Why learn data structures and algorithms?

If you want to work on and write code in the future, data structures and algorithms are the necessary technology, why? Let me give you an example. How do you meet a project to get it done? If you hadn't learned the data structure, would you think I used an array or if else? If you have learned the data structure, would you like me to use a stack or a binary tree and a graph? this exposes the first essence: the way to solve the problem. if else who will.

After finding a solution, the next question is what to do with the code. This is a very important problem, the way you solve the problem is the algorithm, why to learn the algorithm? Take the example from 1 to 100. The same problem,

According to Gauss classmate's algorithm, the time complexity is 1, according to the algorithm for the loop, the time complexity is 100. What if it's from 1 to 1000, 10,000, 100 million? The time complexity of his classmates is still 1, while the For loop is 1000, 10,000, 100 million ... this exposes the second essence: The problem-solving approach (algorithm) is good or bad if you don't mind the quality of the algorithm, you need several servers, and then your supervisor will hold the hair and say "Oh my God"

This is the essence of learning data structure and algorithm, the specific code how to play, see next time.

What are data structures and algorithms?

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.