To learn algorithms, you need to master these programming basics (including JAVA and C ++)

Foreword

Good friends! The lovely editor is here again. The winter vacation has recently taken place, and I believe that all your friends have made a full plan to overtake the curve during the winter vacation.

Such a beautiful long vacation, it is too violent to not use it for learning!

In addition, there are often small friends to ask the editor, what programming languages ​​need to master the learning algorithm? How hard is it to learn code? Is it better to learn Python or matlab?

There is really no way to answer these questions one by one, so today we will talk about what kind of programming knowledge you need to learn algorithms ~

It is worth noting that the object of this article is the learning group of algorithms, including heuristic algorithms and precise algorithms on the public account. Therefore, we only emphasize " enough " in programming knowledge , so that we can focus more on algorithm design and optimization .

Java basics

The core principle of basic knowledge is "useful". After learning the basics, you should be able to quickly write some simple algorithms . To learn knowledge, please refer to the roadmap given by @ 沈世钧:

Of course, you can adjust the learning time according to your learning ability. Normally, it should be no problem to complete this part within 6 weeks . A month of strong ability can quickly get this basic knowledge.

In the process of learning java, there are many videos on the Internet that you can refer to. There are indeed a lot of books, but they are also very complicated. Here, the editor recommends a "Java Core Technology Volume I" . One book is enough to eat.

After learning the basics, you can try to do a small project yourself to consolidate the programming ability, while grasping the relatively large-scale program development . **** You can make a small game and the like , here is a small game that I have done before:

Portal: Sharing | The big ball eating small ball game implemented by Java

However, the code framework of the program may not be so beautiful, interested friends can refactor it.

C ++ basics

Noted that I put C ++ behind Java, because to be honest, C ++ is a little harder for Java than novice. The content of C ++ is too much, too much ... There have been circulated on the Internet a 21-day cheat for mastering C ++:

Therefore, it is recommended that you can learn the basics of C ++ first. Just like java, you can query after you have learned the basics.

The first is the basic part of C : data types, variables, memory layout, pointer basis; string, one-dimensional array, two-dimensional array; first-level pointer, second-level pointer, pointer array and array pointer; use of structures, files, etc. .

Then there is the C ++ part: object-oriented programming ideas; class encapsulation, construction and destruction, static members, object management; class construction (parametric constructor, no parameter construction, copy construction, default constructor) and destructor; objects Dynamic management, friend function, friend class, operator overloading;

Dynamic management of class objects (new / delete); friend functions and friend classes; operator overloading; class inheritance, multiple inheritance and its ambiguity, virtual inheritance; polymorphism; virtual functions, pure virtual functions, abstract classes ( (Oriented to the abstract class programming thinking case); function template, class template, template inheritance;

C ++ type conversion; C ++ input and output stream (standard I / O file I / O character stream I / O); C ++ exception handling (exception mechanism, exception type, exception variable, exception hierarchy, standard exception library).

After learning these basics, I believe you have become immortal , um, yes! Then you can strengthen it by writing a small game, such as a small game of AI greedy snakes written by Xiaobian:

Portal: 10 minutes to teach you to write a greedy snake with AI function in C ++ (with source code explanation and download)

Of course, the program is not so perfect, and interested friends can still reconstruct it.

data structure

The importance of data structures is self-evident. This is the most important part of all programming languages. One of the foundations of program composition is an indispensable part of algorithms.

Including: sequential storage, chained storage, circular linked list; doubly linked list, stack (sequential and chained), queue (sequential and chained); stack application, basic tree concepts and traversal, binary tree; sorting algorithm, Merge algorithm, selection, insertion, fast, Hill, etc.

Of course, I recommend Cheng Jie's "Big Data Structure", although this book has been misrepresented by many people on the Internet.

But from the editor's point of view, this book is still very friendly to novice friends, at least it can still be learned. Basic students can also look at the data structure of Grandma Yan, but this is really boring.

Use of IDE

What is an IDE? It is an integrated development environment, on which you can code as you like, so it is quite important to configure a good development environment.

For Java, eclipse is the most famous. The biggest advantage of eclipse is that it is free (I do n’t know later). Of course, there are also many small partners who are using IntelliJ IDEA. This is a fee, and it is much easier to use, but I have not used it yet ~ see everyone ’s preference.

For C ++, you can choose the VC series of the Windows platform: such as Visual Studio2013, Visual Studio2015, Visual Studio2017, Visual Studio2019. Now Visual Studio has a community version, which is the free version . It is not an exaggeration to say that it is the strongest IDE in the universe. The debugging function is really too powerful . I remembered the various situations in which I was writing projects to debug bugs. It was really tearful.

There are also some senior editors can choose choose Notepad ++, EditPlus, vs code and so on . Of course, this is a standard coder.

Advanced algorithm

With the above programming foundation, you can already deal with most of the algorithm scenarios, and then you can start learning some commonly used algorithms. Then you can get started with the project and the thesis. Learning content reference:

Dry goods | Want to learn optimization algorithms, I do not know where to start?

Dry goods | Where does operations research start? How to quickly get started with operations research algorithms?

Dry goods | Public number "Data Magician" algorithm code sorting: Show you the code!

One more word at the end

As for why I chose C ++ and java instead of Python or matlab, I have explained it many times. Is it ok to learn C ++ or Java? The reason why the editor recommends grasping with both hands is because C ++ and Java have very significant advantages.

For C ++, the speed is quite fast, so fast that you doubt life. There may be readers who have doubts at this time. The editors deceive people, and sometimes they feel that C ++ is ridiculously slow. That is because the compilation mode of your IDE is debug, and the compilation is not optimized.

For example, in visual studio, select the release mode:

Optimization options choose speed priority:

Another example is to choose in devC ++:

Then you will find that the program is faster than N times.

For java, the biggest advantage is the balance between speed and ease of use. The speed is generally on the order of C ++, but after all, it is still no better than the abnormal C ++.

But java is very convenient to use. For example, to call cplex, you only need to import a jar package and configure the dll to do whatever you want. C ++ has to import headers and link libraries again, which is a nightmare for Xiaobai, such as:

And java one class per file, unlike C ++ one class has one header file and one CPP file, I am really big. For the large algorithms that Java and C ++ editors have used to develop more than 10,000 lines of code, so the advantages and disadvantages between them are well understood, and they are by no means empty-mouthed.

Finally, it is worth noting the difference between the memory management methods of C ++ and java. Concepts such as shallow copy should be familiar , otherwise it will really get crazy (got crazy!).

In the end, I wish you all success in the new year **** and I wish the editor a lot of luck, I wish everything is done, hey!

Guess you like

Origin www.cnblogs.com/dengfaheng/p/12672774.html