Git Product home page Git Product logo

thealgorithms / c-plus-plus Goto Github PK

View Code? Open in Web Editor NEW
29.2K 508.0 7.0K 109.06 MB

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

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

License: MIT License

C++ 98.62% Dockerfile 0.01% CMake 1.27% Python 0.09%
cpp algorithm algorithms-implemented data-structures algorithm-competitions algorithms interview-preparation interview-questions search sort

c-plus-plus's Issues

Implementation of algorithms as listed

I might add these in few days, I will list the problem or algorithm name (mostly advanced) -

  • Discrete Mathematics

    • [ ]
  • Automata Theory

    • [ ]
  • Statistics

    • [ ]
  • Number Theory

    • [ ]
  • Combinatorics

    • [ ]
  • Graph theory

    • [ ]
  • NP, NPC (Simulated Annealing, Brute Force, Genetic Algorithms)

    • [ ]
  • NN

    • ANN
      • [ ]
    • BNN
      • [ ]
    • DNN
      • [ ]
  • Algorithmic Trading

    • [ ]

Errors in Dijkstra.cpp

The C function malloc() is unknow. Missing stdlib.h.
The problem if you run the code it raises Segmentation fault.

Add bottom-up non-recursive merge sort

I have an implementation of bottom-up merge sort that I'd like to share with you. It has exactly the same space and time complexity of the regular algorithm, except it doesn't overwhelm the stack with recursion.
Furthermore, my code uses templates for generic sorting of any data structure and, it is well-documented and uses Doxygen in case a person would like to auto-generate documentation.

[FEATURE]

Detailed Description

Context

Possible Implementation

New directory proposal (Competitive-Coding)

I would like to propose an idea of adding a new directory for Competitive-Coding . This would help people who are new to programming implement those algo's .

I have been doing competitive coding from last 2 years on the platform's like Codechef, Codeforces, Top-coder, Hackerearth and would like to contribute my successfully submitted code to this repo.

Please assign me this task

Update README.md

Adding all links of algorithm which are implemented on README page.

Participar

Disculpa me gustira saber si puedo estudiar sus codigos en cpp y si puedo agregar mas archivos y editar los actuales ayudando a contribuir en un mejor desarrollo de el trabajo de OpenSource

ADD sort(arr,arr+n,comaprator) inbuilt c++ function

Detailed Description

Add a program of sorting using inbuilt c++ sort function

Context

  1. More will get to know about the comparator function.
  2. How comparator function sort in lexical order and how to improve it.

Possible Implementation

bool compare(string a, string b)
{
    cout << "Comparing " << a << " and " << b << endl;
    if (a.length() == b.length())
        return a < b;
    return a.length() < b.length();
}

sort(arr, arr + n, compare);

Threaded binary tree not present

`#include
using namespace std;

class node{
public:
int data;
int rbit,lbit; // rbit = 1 when right child is normal and 0 if right child is thread
// lbit = 1 when left child is normal and 0 if it is thread
node *left,*right;
};

class tree{
public:
node * insert(node *,int ); //to insert data
node * getnode(int ); //for allocation of memory and initializing the node
void inorder(node *);
node * inorderSuc(node *); //will return inorder successor
node * preorderSucc(node *);
void preorder(node *);
};

//to allocate and initialize the node
node * tree :: getnode(int d){
node * p = new node;
p->data = d;
p->left = p->right = NULL;
p->rbit = p->lbit = 0;
}

//insertion in tbt(double)
node * tree :: insert(node * a,int d){
node *p,*q,*r;
p = a;
q = a;
if(a == NULL){
a = getnode(d);
return a;
}
while(p!=NULL && q->data != d){
q = p;
if(q->data > d){
if(q->lbit == 1){
p = q->left;
}
else{
break;
}
}
else if(q->data < d){
if(q->rbit == 1){
p = q->right;
}
else{
break;
}
}
}
if(q->data == d){
cout << "TREE CANNOT HAVE DUPLICATE ELEMENTS\n";
return a;
}
else if(q->data > d){
r = getnode(d);
r->left = q->left;
q->lbit = 1; //now it has normal child
q->left = r;
r->right = q;
}
else{
r = getnode(d);
r->left = q;
q->rbit = 1; //now it has normal child
r->right = q->right;
q->right = r;
}
return a;
}

node * tree :: inorderSuc(node *r){
node *p = r;
if(p->rbit == 0){
return p->right;
}
p = p->right;
while(p->lbit == 1){
p = p->left;
}
return p;
}
// INORDER TRAVERSAL => (LEFT , ROOT , RIGHT)
void tree :: inorder(node *r){
/*as we can obtain the inorder successor using the above function we will travell to the left most
node of the tree and start printing the inorder successors */
node * p = r;
while(p->lbit == 1){ //continue untill thread comes
p = p->left;
}
while(p!=NULL){
cout << p->data << " " ;
p = inorderSuc(p);
}
}

int main(){
tree b;
node *root=NULL;
cout << "Data insertion in TBT\n" ;
root = b.insert(root,3);
root = b.insert(root,4);
root = b.insert(root,5);
root = b.insert(root,1);
root = b.insert(root,2);
cout << "Inorder traversal\n";
b.inorder(root);
return 0;
}`

I wanna contribute this, will be adding other traversals and deletion of nodes in tree.so Please tell how should I contribute

Error in Circular queue operations

This is regarding an error in the file having path Operations on Datastructures/Circular Linked List.cpp
The Print option in the menu shows the last element entered as Not Found.
result
I would like to resolve this issue.

[FEATURE] Addition of statistical and probability distribution functions

Addition of statistical and probability distribution functions

Detailed Description

I saw the Probability file in the repository and only basic operations (addition rule) to calculate probability was given. Addition to this function, we can add statistical distribution functions like Gaussian Normalization, Binomial Distribution, etc classes and provide some addition functions to incorporate the changes in basic statistical features (mean , variance, standard deviation) for each distribution.

Context

The observation of distribution functions are very much helpful in case of statistical calculations which is more advanced in case of Python but is lagging in C++.

Possible Implementation

Using basic class concept with inheritance we can easily add different distribution features and effectively calculate the statistical features using them.

Add format for PR and contribution guide?

We should add a format for PR description to keep the PR in same format easy to read, and some more detailed contribution guide and Welcome bot for betterment and encouragement?

Please advice. @AnupKumarPanwar

Once you advice please assign it back to me.

-Thanks.

Suggestion - use modern c++

Maybe try rewrite the code in more modern c++ (or make another repository for this).
I didn't look through all the files but it seems that you are using c++98 and its very old c++ standart (try using at least c++11)

Paranthesis Matching.cpp

C-Plus-Plus/Others/ParanthesisMatching.cpp is not correct. It is not giving correct output for ( ] or [ }.

[FEATURE] How should we standardize testing of our algorithms?

As discussed at #721 (comment), should we require (or at least encourage) tests with new submission to this repo? Other TheAlgorithms repos require tests. For example, the Python repo runs >520 tests on every pull request. DOing this would give reviewer confidence in the submission, would teach contributors how to do test driven development and would demonstrate to readers how to call the algorithm in a broader context.

Today we already lint our submissions in GitHub Actions but should we go beyond that basic hygiene?

Detailed Description

Context

Possible Implementation

Suggestion:To reorder program files

To add all the cpp program file either in their respective directories or make a misc folder and add them there to reduce chaos in main folder and make them organized like other repositories.

Add Randomized-Quicksort.cpp

Using randomize partition to avoid the basically ordered sequences in the quicksorts.
And I will update a fork and pull a new request about it.

Convert data structures to templates

It seems like the data structures have been designed to store data of just one type. Wouldn't it be better to implement them as templates?

That reduces the effort/time needed to reuse these structures for something else.

I'm ready to take on this task. So if you like this idea, assign this issue to me

Implementing different hash collision resolution strategies

Would there be interest in implementing more hashtables? Currently there is only a hashtable implemented using separate chaining. I would be interested in implementing other resolution styles.

(Some) Unimplemented Collision Resolution Forms

  • Linear Probing
  • Quadratic Probing
  • Double Hashing

Can you do Korean annotation?

Thank you for revealing software that is generally neat and has many features.
However, this data is not easily accessible to Korean users, so is it OK to add Korean annotations?

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.