Java data structure and algorithm (1)-java Data Structure

Source: Internet
Author: User

Java data structure and algorithm (1)-java Data Structure

In this article, we will not talk about technology. We will talk about the odd relationship between technology and popularity, as well as driving force learning.


1) technology and popularity

In the university, Yan Weimin's data structure is not thick and rich in content. However, there is little space to explain complicated problems, which is hard to understand. c is not very good at either, however, there are still some basic ideas.

Simple linked list, array, stack, queue, graph, and several sorting algorithms.


Later I saw Zhi Hu Tao Wu's answer, which was very shocking at the time. Here I will cite his answer:


If Java is an automatic car, C is a manual jeep. What about the data structure? Is the working principle of the gearbox. Without knowing how the Gearbox works, you can drive the automatic car from A to B, and it may not be slower than people you know. Writing a program is similar to driving a car. Experience can play a major role, but if you don't know how the bottom layer works, you can only drive a car, neither repairing a car nor building a car. If you are not interested in either of these two things, you just need to know how to use the data structure. However, if you still have a higher pursuit in the programming field, the data structure will not be around.

Java has done too many things for you, so many still support fan-type container classes, coupled with garbage collection, will make you feel that programming is very easy. But have you ever wondered how the container classes come from and what they mean? The shortest, such as the ArrayList class, has you ever wondered how much benefit it has? An array that can be accessed randomly and automatically increase the capacity. C does not have this kind of thing, implement it by yourself. But how to implement it? If you are interested in this issue, the data structure must be viewed. Even the object-oriented programming paradigm itself is a data structure problem: how can we encapsulate data and operation data methods to create a class/prototype?

In addition, it is very important that the data structure is also the cornerstone of various practical algorithms, so learning the data structure is to improve the internal force.


Anyway, I feel like I have a strong sense of programming and how I feel like I can die in the data structure.


In fact, it takes a lot of effort to tell people who do not understand a difficult technology, including the article C and pointer I wrote earlier, he wrote some answers to the C language. I admire such a person.


So when you can clearly explain something to others, just like the debugging method of the Rubber Duck mentioned in the previous articles, you can understand and understand it. Explain in technical languages with a technician, and explain in non-professional languages.


Of course, the premise must be accumulated. For details, refer to the CSDN interview on Luo shengyang --

Interview with Luo shengyang: Rolo's Android journey

At that time, I was shocked. I thought I was at the same age as Lao Luo. Later I found a young man who had accumulated and gradually accumulated.



2) Driving Force Learning

When you see that Mario you have played can be written by yourself, isn't it exciting? Is there a drive for learning? I want to do something like this and start learning until I finish it myself.


At that time, I was calculating in college. According to my learning speed, 10 years later, it would be awesome. Why did some people fail to improve their technology? A few years later, because of the driving force, I stopped for a while and almost all Java was finished. Why?


Because I have done a lot of things from J2SE to EE, and then there is a period of confusion, and the driving force is gone. Later I realized that I was too superficial, and there were some other popular frameworks that were useless. Did you write the best Singleton? Did you go deep into the virtual machine? Did you still find many classic books in Java?

It is also possible to learn new knowledge as the driving force. It is a sense of accomplishment and excited to learn new knowledge without stopping it. It turns out to be xx.


There is also a kind of thing-target-driven. At that time, we wanted to do something related to the network-and thought about crawlers. Then, we wanted to collect data and read others' code for the purpose of making this thing, this kind of driving force learning is also possible. During work, if the goal is only for the work project, and every project has new things in it, you can learn things. If it remains the same, you can only explore it by yourself.

Otherwise, there will be one who learns to stay in the middle of the night-Interview with Lei guoguo: the five-year growth path of a programmer from K to 18 K.


I want to learn Python. After learning it, I will find that it was really awesome. I can try to use Python to write a crawler, GoAgent, and so on. This is progress.



If you do not want to use Java as the xx system, you only need to know how to use the container and never know what it is like. These are the foundations of understanding, others are also studious.


Back to the data structure, Why do many students want to sleep during lectures, xx linked list, two-way linked list, and I have N sorting types? the student's idea is that I don't know how to use it, let me talk about the linked list. I will implement it once.


However, when programming problems in your life need to be solved, you will find that data structures are everywhere. For example, if a fund is bought, isn't it a queue; it's like simply saving the data of a class student. Isn't it possible to use an array to solve it? Isn't it a graphic problem with complicated game routes; if Java contains the word Tree, isn't the principle of Tree actually used?


After all, you will find that the actual problems and the encapsulation in the language are related to them. Whenever you learn one, you will suddenly realize that, this is not the feeling of Xia Yuhe on the West Lake River. Students will not consider what they mentioned before they think about these problems and do not actually use encapsulation classes in these languages.


Therefore, it is normal for a large group of students to sleep and play with their mobile phones.


After I realized it, I immediately bought "Java data structures and algorithms" and did not learn or understand it.


Programmers who do not want to learn the basics well are not good programmers.


Java data structures and algorithms

Public static void main (String [] args ){
// Define the current value as 10
Int I = 10;
System. out. println ("current number:" + getNum (I ));
System. out. println ("the next number is:" + getNext (I ));
}
/**
* The tree after the index is obtained
* @ Param index
* @ Return
*/

Public static int getNext (int index ){
If (index <0 ){
Return 0;
}
Return 3 * (index + 1) + 1;
}

/**
* Obtain the index number
* @ Param index
* @ Return
*/
Public static int getNum (int index ){
If (index <0 ){
Return 0;
}
Return 3 * index + 1;
}

It is recommended that you learn about the typical java data structures and algorithms.

Data structures and algorithms are irrelevant to programming languages. Whether you learn C, C ++, or java, data structures and algorithms are the same. There are a lot of books on The market on The data structure, and there are basically no big areas in The same way. Just pick up what is written in Tsinghua. The best algorithm is The introduction of algorithm. however, there are only photocopies on the market without translation. The cs Department of Nanjing University has its own internal translation. If you have any, lend it.
The typical Java book is basically "java programming ideology" (Thinking in Java) and "java core technology" JavaCore. It is quite appropriate to start from the first volume of javacore.

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.