Algorithm changes the world--the beauty of algorithm--the principle behind the data structure (c + + edition)

Source: Internet
Author: User

The so-called algorithm, which is hidden behind the data structure of the principle, in the development of a good algorithm can reduce the complexity of time to improve the reusability. The beauty of the algorithm-the principle behind the data structure (c + +) A book around the topic of algorithms and data structure, with the Hanoi Tower problem and eight queen problems, such as 22 classic algorithm problems gradually, easy to introduce the modern computer technology commonly used in 45 classic algorithms. After reading let people clairvoyant, enlightened, and feel brief encounter.

The sixth chapter of the book, "recursion--the old monk tells the story" is very good, first introduced the concept of recursion, and then use the Hanoi tower problem, infectious diseases and eight queen problems respectively elaborated and practice the two ideas of recursion-division and backtracking.

I am an Android engineer who will not use the NDK, C + + level laughed at generous, but the idea of the algorithm is figured out, I read the left teacher on the recursive insight after feeling clairvoyant, bluntness, immediately wrote a traverse the entire interface and cancel all RadioButton Click event Method:

private void Banclickable (ViewGroup radiogroup) {
for (int i = 0;i<radiogroup.getchildcount (); i++) {
View v = radiogroup.getchildat (i);
if (v instanceof RadioButton) {
V.setenabled (FALSE);
}
if (v instanceof viewgroup) {
Banclickable ((ViewGroup) v);
}
}
}

It takes only a minute to remove each of the click events in this 15 RadioButton interface, and it takes 10 minutes to write this method. But if RadioButton is enough, the beauty of the algorithm-the principle behind the hidden data structure (c + +)-teaches me that the recursive algorithm is as efficient as engraving and printing, and can greatly reduce the amount of code and increase maintainability.

I also have an algorithmic book The beauty of programming, both of which have a number of algorithmic cases. The difference is that the beauty of programming focuses on the characteristics of C and handwritten pseudo-code on the Whiteboard (interview algorithm), while the beauty of algorithms contains a large number of C + + examples that can be rewritten into Java to improve the programming ability of the reader in the actual work.


Algorithm changes the world--the beauty of algorithm--the principle behind the data structure (c + + edition)

Related Article

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.