Coder Social home page Coder Social logo

thealgorithms / c Goto Github PK

View Code? Open in Web Editor NEW
18.0K 515.0 4.2K 19.89 MB

Collection of various algorithms in mathematics, machine learning, computer science, physics, etc implemented in C for educational purposes.

Home Page: https://thealgorithms.github.io/C

License: GNU General Public License v3.0

C 96.74% Makefile 0.33% Dockerfile 0.02% CMake 2.38% Python 0.52%
algorithms data-structures datastructures c algorithm-challenges algorithm-competitions education learn-to-code interview-questions interview

c's Introduction

The Algorithms Official Website


This is a static Next.js site providing a searchable library of all the algorithms in The Algorithms. All the data about the algorithms gets scraped directly from the git repositories.

Translating the website

You can help us translate the TheAlgorithms website using Weblate here. There you can complete the translations for our current languages, or suggest something if you are unsure. Also feel free to add a new language. The current languages are:

Translation status by language

Getting Started

If you haven't installed it yet, install Node.js and yarn. Then, install all the dependencies:

yarn

After that, run the script that fetches all the algorithms from GitHub:

yarn fetch-algorithms

Finally, run the development server:

yarn dev

Open http://localhost:3000 with your browser to see the website.

Alternatively, you can also use the Ready-to-Code Gitpod and easily check how your deployment looks. It will automatically run the commands mentioned above on run.

Contributing

If you want to add a new feature or fix a bug, create a new branch or fork and commit there. Before opening a PR, be sure to

  • Run yarn lint and fix potential errors
  • Run yarn build to check if everything still builds successfully

Open the pull request against main. Vercel will automatically create a preview deployment, and the pull request will be squash merged after being reviewed by a member.

License

The source code of website itself (this repository) is licensed under MIT, while all the licenses for the code and explanations on the website can be found in the respective repositories.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Powered by Vercel

c's People

Contributors

alexpantyukhin avatar amitha-nayak avatar anupkumarpanwar avatar ashwek avatar ayaankhan98 avatar carloszoft avatar cclauss avatar christianbender avatar danghai avatar deadshotsb avatar dhruvpasricha avatar dsmurrow avatar dynamitechetan avatar harshildarji avatar ketan-lambat avatar koseokkyu avatar kvedala avatar northernsage avatar panquesito7 avatar r0hit-gupta avatar rachitbhalla avatar realduyuanchao avatar sachinarora707 avatar saurusxi avatar serturx avatar sh-ubh avatar shubhamsah avatar stepfenshawn avatar theycallmemac avatar yanglbme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

c's Issues

Jogo de adivinha qual número é maior

#include <stdio.h>
main (){
int num, num2, menor,maior;
printf("\n----------------------------------");
printf("\n| JOGO DO NÚMERO MAIOR OU MENOR |");
printf("\n----------------------------------");
printf("\n\nDigite o número 1: ");
scanf("%d",&num);
printf("\nDigite o número 2: ");
scanf("%d", &num2);
if (num > num2)
printf("\n\nNumero 1 é Maior que o Número 2");

    if (num < num2)
    printf("\n\nNumero 2 é Maior que o Número 1");
    
    else 
    printf("\n\nOs dois Números são iguais");

return (0);
}

Prime.c

I tested it with the lowest prime number but it tells me that it's actually not one.

Adding the following to isPrime function solved the issue for me
if (x == 2)
return 1;

[BUG] multikey_quick_sort.c - erroneous

erroneous code sequences

Description

  • line# 259 -> while loop has invalid termination condition because pp variable is not initialized and garbage value.

Expected Behavior

Actual Behavior

Possible Fix

Steps to Reproduce

Context

not working bubbleSort

C:\Users\Marcel\Desktop\Projekte\C-Projekte\Bubblesort_Github\cmake-build-debug\Bubblesort_Github.exe
Enter the value number 1
2
2
would you enter an other value (1:Continue/0:Sort the actual array)?
1
1
Enter the value number 2
3
3
would you enter an other value (1:Continue/0:Sort the actual array)?
1
1
Enter the value number 3
4
4
would you enter an other value (1:Continue/0:Sort the actual array)?
1
1
Enter the value number 4
1
1
would you enter an other value (1:Continue/0:Sort the actual array)?
0
0
1, 2, 3, 1811939332,
Process finished with exit code 0

[BUG] Unhandled Exception in Tic-tack-toe-game

Tick-Tack-Toe game is not working for exception part

Description

Else part on line 247 takes you to infinite loop on getting any char value as input for position.

Expected Behavior

It should give the option to enter value again

Actual Behavior

Infite Loop with print value - Invalid value

Counting Sort

The counting sort code here is not well formatted. I would like to re-format it, adding useful comments and proper indentation to make it more understandable. @danghai

[BUG]

Description

Expected Behavior

Actual Behavior

Possible Fix

Steps to Reproduce

Context

Implimentation for the Trie data structure

In the data structure section there doesn't have Trie data structure. A Trie is a special data structure used to store strings that can be visualized like a graph.That is mostly used in Search Engines, Genome Analysis, Data Analytics. So I would like to implement Trie using C.

[BUG] Logical error fixed in conversions/c_atoi_str_to_integer.c

Description

Expected Behavior

Program should pass all the assertions.

Actual Behavior

Program failed to pass all the assertions.

Possible Fix

Improve the logic of the prgram to fix the error.

Steps to Reproduce

just compile and execute the program as it is.

Context

Logical Error Fixed

Description

Bug fixed in conversions/c_atoi_str_to_integer.c & formatting
Logical error fixed in conversions/c_atoi_str_to_integer.c

Expected Behavior

Should succesfully pass all assertions

Actual Behavior

Fails to pass all assertions.

Possible Fix

Steps to Reproduce

Compile & Execute Code.

Context

Failed to assert all the checks.

Compilation Error otherBinarySearch

gcc -Wall -Werror otherBinarySearch.c -o otherBinarySearch
otherBinarySearch.c:3:13: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
 #define len 5
             ^
otherBinarySearch.c:5:36: note: in expansion of macro ‘len’
 int binarySearch(int array[] , int len , int searchX)
                                    ^~~

This is because pre-processor is replacing len with 5 in the function prototype.
https://stackoverflow.com/a/7103183

the getMax function in binary search tree may not work correctly

Hi there,
I am learning data structure. it's really helpful to find such a excellent project. Thanks for the excellent work.

However, I found this code may not work correctly.

root->right = getMax(root->right);

let's say we have a tree like this
node *root = NULL;
root = insert(root, 100);
root = insert(root, 50);
root = insert(root, 25);
root = insert(root, 12);
root = insert(root, 35);
root = insert(root, 75);
root = insert(root, 58);
root = insert(root, 87);
root = insert(root, 150);
root = insert(root, 125);
root = insert(root, 175);
root = insert(root, 168);
root = insert(root, 180);

When I want to delete 50 from this tree, getMax function returns 25 for the max data of the left subtree of node 50, which should have to be 35. And after I delete 50 from this tree, I used inOrder function to check the updated tree. I got this:

[ 12 ] [ 35 ] [ 25 ] [ 58 ] [ 75 ] [ 87 ] [ 100 ] [ 125 ] [ 150 ] [ 168 ] [ 175 ] [ 180 ]

As you can see, the sequence is not correctly ordered.

I think the correct code for getMax should be:

node *getMax(node *root)
{
// If there's no leaf to the right, then this is the maximum key value
if (root->right == NULL)
return root;
else
// root->right = getMax(root->right);
return getMax(root->right);
}

Correct me if I was wrong, please.

Add more solution for Leetcode algorithm.

I create leetcode directory. You can contribute solution for Leetcode algorithm by C language.
Good practice coding :)
Please put some comment for explanation. It helps other people understand your algorithm better

Two Sort folder

There are 2 Sort folder: Sorts and sorting.
Which one should I contribute to?

Skip List[FEATURE]

Detailed Description

I can't find Skip List implementation

Context

Possible Implementation

I can contribute if it's possible

Felicitaciones

Me gusto mucho la forma de tratar con los datos obtenidos hacia la estructura, hace un buen manejo de las pilas y las colas bueno formación en cuanto a las posibilidades de como recibir los datos me gusto tu estilo de programación en este código espero ver muy pronto otro código y aprender de vos

Solutions for Project Euler should be deleted

Publishing the solutions destroys the Project Euler's intent.
Quoted from the site:

Q: ”I learned so much solving problem XXX so is it okay to publish my solution elsewhere?”
A: “It appears that you have answered your own question. There is nothing quite like that "Aha!" moment when you finally beat a problem which you have been working on for some time. It is often through the best of intentions in wishing to share our insights so that others can enjoy that moment too. Sadly, however, that will not be the case for your readers. Real learning is an active process and seeing how it is done is a long way from experiencing that epiphany of discovery. Please do not deny others what you have so richly valued yourself."

"Members have generally taken pride in showing their achievements. The obvious place to do so is the forum that is set up for each problem. However the increasing popularity has also been attracting people with a different agenda. With so many internet sites publishing answers for the PE problems instead of using the forum on this site, some people now seem to take pride in gathering and submitting those answers for whatever reason.

It is humanly impossible for Project Euler, or indeed any member, to reliably differentiate those people from members that have solved the problems under their own steam. The ranking lists on Project Euler should be interpreted for what they are: an indication of the number of correct answers submitted by the member in question and validated by our answer checker. Individual members themselves know best what they have achieved on their own. Laying too much stress on competition might spoil the fun of problem solving which is one of the purposes of Project Euler. Also, any claim from a member about his own achievement cannot be supported as trustworthy by Project Euler. If critical, other means from third parties would be required to verify such claims."

Link: https://projecteuler.net/

Hacktoberfest 2020 - Implement C algorithms or data structures, fix existing ones and more!

The annual Hacktoberfest is around the corner! Register on Hacktoberfest's website and open 4 pull requests during October 2020 to receive the swags (if you're the first 70,000 participants)!

In our C repository, there are currently several open issues:

What's more, you can also fix an existing bugs, improve any documentation and provide better implementations for certain algorithms! Feel free to inform the community by filling an issue and start hacking! If you're new to contributing code, please read our Contribution Guidelines for an overall understanding and ask questions on the internet - Google, StackOverflow or our Gitter.

TheAlgorithms has repositories in other programming languages, so find your language and start coding there!

What you can do to participate

  1. Read our Contribution Guidelines
  2. Comment below or open an issue (for big ideas you may want the community to know) on your new implementations, fixes or functionalities
  3. Start hacking!
  4. Open a pull request for your contribution
  5. Label your pull requests with hacktoberfest
  6. Wait until your pull requests get reviewed or merged! In the meantime, you can review someone else's pull requests too

Useful links

Remarks

  • Please observe Hacktoberfest's rules, terms and FAQ. If a pull request is marked invalid or spam it would not be counted and the person may be disqualified for the swags.
  • Hacktoberfest 2020 is an event presented by DigitalOcean, Intel and DEV.

2 Search folders

There are 2 separate folders in the repo for searching algorithms. Merge them.

Make code more modular in nature

Presently, each algorithm implementation requires implementation of each underlying data structure from scratch. This is a hassle, as more than often the implementations of underlying data structures increases the code size unnecessarily.
For example, while implementing graph algorithms if we have to reimplement graph ADT again it will meaningless. Instead it would be good idea to implement a header file alongside, which could be used as includes later in other algorithms.
This issue aims to provide such modular nature in the present existing files.

[FEATURE]

Detailed Description

Context

Possible Implementation

a bug

C/data_structures/stack.c

I think there is a bug !

the node->next always equal to NULL

Translation of README.md

You think is a good idea to add translations of the README.md?
I can write the spanish version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.