This is a set of simple C codes developed to study algorithms and concepts of computer science. It posseses the following characteristics:
- Developed with C11;
- This code uses some UNIX functions, so it is platform dependent (it was only tested on Linux);
- In this studies, I found this references to be very usefull:
- Implemented data structures:
- Linked list;
- Doubly linked list;
- XOR linked list;
- Dynamic array;
- Circular buffer;
- Binary tree (In order to study binary trees, a simple expression parser was developed, as an example);
- Implemented sorting algorithms:
- Implemented search algorithms:
- Implemented approximations for constants:
- Implemented scalar functions:
- Exponentiation by a integer positive number;
- Square root;
- N-th root;
- Exponential;
- Trigonometric functions: sine, cosine, tangent and arctangent functions;
- The atan2 function;
- Implemented operations with complex numbers:
- Sum andsubtraction of complex numbers;
- Multiplication and division of complex numbers;
- Inversion of complex numbers;
- Modulus and argument of complex numbers;
- Construction of complex numbers by its polar form;
- Complex conjugate;
- Exponentiation by a integer positive number;
- Implemented operations with vectors:
- Sum and subtraction of vectors;
- Multiplication of vectors by scalars;
- Dot product;
- Cross product;
- Euclidean norm;
- Implemented operations with polynomials:
- Addidtion and multiplication of polynomials;
- Differenctiation of polynomials;
- Evaluation with Horner's method;
- Division by a binomial using Ruffini's rule;
- Computation of polynomial root bounds;
- Polynomial root finding;
- Legendre polynomials;
- Chebyshev polynomials;
- Implemented operations with matrices:
- Sum and subtraction of matrices;
- Multiplication of matrices by scalars;
- Multiplication between matrices;
- Multiplication between matrices and vectors;
- Trace;
- Determinant;
- Transpose matrix;
- Symmetric matrix;
- Skew-symmetric matrix;
- LU decomposition;
- LU Crout decomposition;
- QR decomposition;
- Householder matrix computation;
- Hessenberg matrix computation;
- Schur decomposition using the QR algorithm;
- Eigenvalues computation;
- Cholesky decomposition;
- Greatest eigenvalue computation (and its eigenvector) using the power method;
- Lowest eigenvalue computation (and its eigenvector) using the inverse power method;
- Inverse matrix;
- Pseudo-inverse matrix;
- Jacobian matrix;
- Vandermonde matrix;
- Implemented algorithm for solving systems of linear equations:
- Gaussian elimination;
- Gauss-Jordan elimination;
- Solving linear equations using LU decomposition;
- Jacobi method;
- Gauss-Seidel method;
- Algorithm for solving tridiagonal systems;
- Implemented algorithms for finding roots of equations:
- Bisection method;
- Fake-position method;
- Newton-Raphson method;
- Secant method;
- Muller's method;
- Newton-Raphson method for multivariable systems;
- Broyden's method for multivariable systems;
- Implemented algorithms for curve-fitting:
- Polynomial interpolation;
- Lagrange interpolation;
- Gregory-Newton intepolation;
- Linear regression;
- Polynomail regression;
- Computation of Coefficient of determination for the polynomial regression;
- Cubic spline interpolation;
- Implemented algorithms for numerical integration:
- Implemented algorithms for solving Ordinary Differential Equations (ODE):
- Euler method;
- Heun's method;
- Third order Runge-Kutta method;
- Fourth order Runge-Kutta method;
- Butcher’s (1964) fifth-order RK method;
Download this project and compile it by typing the command make
in its folder. Next, just run one of the executables located in the bin
folder. Here is an example:
$ make
$ ./bin/binary-tree
In order to check if there is any memory leak, use the valgrind
command:
$ valgrind --tool=memcheck ./bin/binary-tree
To run all the tests, use the following command:
$ make test