Algorithms in C

What is the best place or link for learning algorithms in C? How do you know when and where to use the implementation of algorithms just by studying problems?

+5
c algorithm
Jul 06 '09 at 8:33
source share
12 answers

Algorithms are not necessarily tied to a specific language, just to clarify, so any book of algorithms will work perfectly if you understand the concept as a data structure / algorithm.

However, this seems like a good choice: Algorithms in C. I have the C ++ equivalent on my shelf.

There is also a book that seems agnostic of the language (correct me if I am wrong), called Data Structures and Algorithm , although I hear this a little outdated, so you will skip later structures.

Remember that a lot of information is available on the Internet . However, books are usually better for such things. This is due to the fact that Internet resources are usually focused on one thing at a time. For example, you need to understand what Big-O notation is before you can understand what it means when we say that List has O (1) [constant time].

The book will cover these things in the correct order, but the Internet resource will focus either on the notation or on the Big-O data structure, but often it will not be easy to connect them.




When it comes to using it, you will basically establish a connection when it comes to what you will do with the data.

For example, you might need vector (array) if you just need ordered elements, but if you need ordered elements and deletion from any (but can sacrifice random access), then list would be more appropriate due to its constant removal of time.

+12
Jul 06 '09 at 8:41
source share

For a reasonable (albeit far from ideal) book on implementing commonly used algorithms in C, try Sedgewick Algorithms in C. Note that, as with any technical subject, a paper book is probably far superior to any web resource.

As for how to know when to use a particular algorithm, I am afraid that this is not so.

+5
Jul 06 '09 at 8:37
source share

For algortihms Cormen, Leiserson, and Rivest, “Introduction to Algorithms” is a good start. Pseudo-code implementations are easy to translate to C. Two web resources with many links to documentation about algorithms and example implementations:

+5
Jul 06 '09 at 9:16
source share

Sedgewick's C algorithms are a great place to start an investigation. Once you know which algorithms are available and what are the performance characteristics of each of them, you can find out where to use them.

+4
Jul 06 '09 at 8:36
source share

This is my collection of mostly math-related algorithms:

List of algorithms

FXT ( math related)

Numerical methods

Numerical Recipes in C

+4
Jul 06 '09 at 9:09
source share

How to find out when and where to use the implementation of algorithms just by studying problems

It is called "pattern matching" as soon as you see and solve many problems that you begin to recognize common things, and you can reuse your previous knowledge.

By the way, I would recommend you before a good book on algorithms only, before starting with C algorithms that are more difficult to implement and more error prone than in a higher level language, and once you are very confident in the general procedures that you can start tune and optimize in C.
+2
Jul 06 '09 at 8:44
source share

Many useful resources have already been named, so I will not repeat them here.

How to find out which algorithm to use when?

  • You should have a fairly large set of tools that you will get sitting and falling through a long list of basic (and more esoteric) data structures and algorithms. You should try to get all the basics, but in fact you only need a sample from a more specialized one.

  • You need to understand what trade-offs are available to you (time, code complexity, memory, single or multiple passes, in-place versus copy, stable and unstable varieties, etc. ad nauseum), and how the algorithms you are learning doing on each of them. Again, this is just a case of much study. Big-O is the place to start, but it’s not the end, and all that.

  • You need to understand what are the real limits that you encounter when presenting a problem, and how to express them in terms of the tradeoffs of the algorithms mentioned above. This requires a certain degree of intuition and is usually studied by practice over time.

  • It is worthwhile to implement some things in more than one way, when you go ahead, learn in your gut what works and what doesn't.

  • It is worth reading the code written by people more experienced than yourself to see how they think.

Good luck.

+2
Jul 6 '09 at 16:19
source share

Wikipedia List of Algorithms is also a very handy link.
And, if you want to go deeper - The Art of Computer Programming ( wikipedia ref ).
Preferably, the book of Robert Sedgewick has already been mentioned in several answers.

+1
Jul 06 '09 at 8:53
source share

I recently read Pointers to C Kenneth Reek. I thought I was very good at C, but this book gave me some insights, even though they were aimed at beginners. Code examples are beauty things (but not the fastest code on an x86-like processor). It provides good implementations of many of the most common algorithms and data structures that are used, with excellent explanations of why they are implemented at will (and sometimes code or suggestions for alternative implementations).

On the same page as your question: templates for creating reusable code in C (this is what we all want, right?), C Interfaces and Implementations: Methods for creating reusable software , David R. Hanson. It has been several years since I read it, and I don’t have a copy to check that I remember correctly, but if I remember correctly, it concerns how to create a good C API: s for data structures and algorithms, as well as examples of the implementation of some of the most common algorithms.

From the topic: Since I mainly wrote programs for throwing in C for personal use, this helped me to get rid of some bad coding habits, as well as to become an excellent link to C: C: Reference Guide . Reminds me that I have to buy this one.

+1
Jul 12 2018-11-11T00:
source share

You need to know which set of algorithms to use for a particular problem. Setting a goal will help. Speed, memory, reliability, quality of the solution ... all the factors in determining which algorithms to use. We could develop different solutions to the same problem, taking into account various factors and scenarios.

+1
Dec 09 '11 at 16:52
source share
0
Jul 06 '09 at 9:10
source share

A simple method for learning algorithms is to use the Wiki page, which is dedicated to some “classic” algorithms, such as search or sorting algorithms. Algorithm designs are based on the ability to use different data structures, for example, linked lists or C. Therefore, first try to implement different data structures, such as a simple linked list or a binary tree, and after trying to use different algorithms that are related to real life problems.

0
Dec 27 '12 at 18:09
source share



All Articles