Data structure (1)

Source: Internet
Author: User
Q: How can I learn the data structure well? Answer 1:

The purpose of data storage is to facilitate data access. This relationship is the data structure.

Algorithms are computer-based models for solving problems: input, output, sequential execution, jump, loop, branch, finite steps

There are three logical structures: wired, tree, and graph, while computer storage uses sequential, chained, and mixed methods. The former is conceptual, and the latter is physical.

Linear Structure: An algorithm is an iterative algorithm. If you do not make any mistakes when the scale is the smallest, the algorithm generally does not make any mistakes.

Tree Structure: The algorithm is a recursive algorithm. You only need to use a recursive combination method to combine simple situations into complex situations. If simple situations do not cause errors, the algorithm generally does not make errors.

In simple cases, the algorithm generally does not go wrong.
Graph Structure: DFS: Tree StructureTo process and use recursive algorithms.
BFS: process the graph according to the linear structure of the chapter, and use IterationAlgorithm
The following algorithms must be used:
(Linear)
1. merge two ordered tables into one table. many variants of this algorithm can be linked lists., Sequence table. Involves set operations,
Merge Sorting, String processing.
2. Place an ordered tableTo the left and the right. Fast sortingReturns the inverse string of a string.
(Several tree trees) Note: Some can be implemented, and some cannot be implemented, so you can think about them.
3. pre-order clue, Recursive Implementation, stack simulation recursion, non-stack Iteration.
4. Sequencing, Recursive Implementation, stack simulation recursion, non-stack iteration implementation.
5. Post-order clue, Recursive Implementation, stack simulation recursion, non-stack iteration implementation.
(Graphics) Note: You can draw a table and write the algorithm step by step.
6. mst: Prim, Kruskal
7. Short Path: Dijkstra, Floyd
8. AOV: topological sortingDFS, BFs implementation
9. AOE: Key Path
How Should Yan Weimin learn the data structure.

Answer 2:

Google's answer to data structures and algorithms:

I have seen this situation many times during Google interviews or graduation recruitment: the method of learning data structures and algorithms-the most important course in the CS course-is very unscientific !!
It doesn't mean that the books or materials used by the teachers are incorrect, but that the students have a very poor understanding of these courses.

The key to laying a solid foundation for data structures and algorithms is not to have a detailed understanding of all data structures, but to remember every large O value or amortize cost ..((@_@;)? [Do not understand]).
If you have mastered this knowledge, it would be great and can be very impressive, but you basically don't need it!
In your career, you may never be asked to implement an algorithm for removing nodes from the red/black tree.! You must be able to easily identify when to use binary trees is simpler and more effective, because you need such skills.

Therefore, do not try to remember everything. Instead, start with the basics and do two things:

  • The first thing is to visualize the data structure in a graphical way. (I suddenly remembered what my high school competition teacher said: the combination of data and data is as good as a thousand. If you don't do anything, take a break! Just draw a picture! Intuitively feel what a data structure looks like. what is it like, abstraction, and concrete implementation. this is the most important thing. in addition, it is important and effective for simple queues, stacks, and day-killing balancing trees. you can figure out the data structure in your mind. In short, what you need to do is to intuitively understand the data structure.
  • The second thing. learn when to use data structures and algorithms. this is very difficult for students, and the teacher did not tell you what to do when you are doing homework. however, it does not matter. you need to realize that you may be able to master certain data structures, such as hash tables, when you are actually dealing with real problems. but even a student should know the practicality of the data structure: when do you need a hash table, when do you need a tree, and when do you need a heap? Instead of getting stuck in the pursuit of details at the beginning.

    During my Google interview, I often ask a question that can be solved by binary tree search. A good candidate can think of using a binary tree to solve the problem within a few minutes, and can solve other problems in about 10-15 minutes. of course, occasionally there will be a candidate who can intuitively understand the tree structure and visualize and graphically describe my problems. of course, he may not know much about the time complexity of some operations, but he can immediately respond to the problem because they have such a tree structure in their heads ~ So he can also get his job.

As for books, only one book is recommended --- <Introduction to algorithms>

If you want a Haru with many examples and language-related books, I recommend <algorithms in C ++> <Algorithms in Java> Of course, I still recommend <Introduction to algorithms>, but these are also good supplementary books ~

Answer 3:

Give a small suggestion:When learning data structures, do not fall into the C language thinking (of course, do not fall into the thinking of other languages)

  • First, forget the computer language you learned, and then use your imagination to visualize various data structures in your brain. At first, you don't have to pursue too much theoretical knowledge, do not care about rigor and pursue perceptual cognition;
  • When you can visually imagine a data structure, use the C language you learned to implement it. Remember, do not pursue complete functions. As long as you write the simplest implementation, pursuing perfection at the beginning is not a good learning process;
  • After writing, I will look back at those theoretical things and form a knowledge system;
  • Finally, if you still have the energy, re-write a more complete function implementation;

After learning from the above steps, you will have a good grasp of it. Even after a period of time, you will not forget to do everything yourself;

Answer 4:

For a data structure, several steps:
1. Understand the basic concepts of the data structure (definition and implementation)
2. Try to understand the meaning of this data structure (why is it invented)
3. Use this data structure to solve some corresponding examples (exercises in books and water problems in online judge)
4. Try to use this data structure to solve some problems that you previously solved with other data structures. Can you solve them? Why.
5. Try again to understand the meaning of this data structure
6. Try to change the data structure to cope with various practical problems (online judge's good question)
8. learn mathematics well.

Note: The above answers from zhihu: http://www.zhihu.com/question/19830721

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.