Skip to content

Latest commit

 

History

History
182 lines (143 loc) · 3.9 KB

CONTRIBUTING.md

File metadata and controls

182 lines (143 loc) · 3.9 KB

How to contribute an implementation (code/documentation)?

  • Have a look at open issues. They contain the list of algorithms/DS we plan to be implemented. Pick an unassigned issue.
  • You can also create a new issue for an algorithm that is not in the list.
  • Make sure you are assigned for the issue.
  • Code the algorithm/DS following the style guide defined below.
  • Send a PR.
  • Be sure to not include any compiled binaries in the patch.
  • While sending a PR make sure you follow one issue per PR rule.

Suggesting an algorithm / DS

  • First make sure you are not suggesting a duplicate.
  • If not, proceed and create the issue. Make sure, you specify only one language in an issue. Create multiple issues for different languages.
  • Title of issue should be of the following format -
        [Algorithm/DS Name] in [Language]
    
    eg:- Binary Sort in Java
  • Please try to include at least one external link for the algorithm/DS in the issue's body for each issue. The link should explain the algorithm/problem/DS in detail.

Code Style Guide

  • All the implementations should be independent and don't use global variables.
  • You can't create new folders. But you can create new files with the correct naming convention.
    1. UpperCamel/Pascal Notation -> Java, C#
      eg:- BubbleSort.java
      
    2. Simple-case letters & Underscore -> C, CPP, JavaScript, TypeScript, Golang, Python2, Python3
      eg:- bubble_sort.c
      
  • Use meaningful variable, method and function names and comments.
  • Should pass all the build and validation checks for the acceptance of your implementation.
  • No profanity.
  • Use external libraries only when no other solution is possible/plausible.
  • We have defined skeleton codes for some popular languages below. Please follow them whenever possible.

Improving an implementation

  • If you feel you can improve upon an implementation, feel free to open an issue discussing the improvements.

Samples

C

void quicksort(int ar_size, int *ar) {
    /*
        Your implementation here...
    */
}

int main() {
	int ar_size = 4, i;
	int a[4] = {2, 3, 0, 4};
	quicksort(ar_size, a);

	for (i=0; i<ar_size; i++){
		printf("%d\n", a[i]);
	}
	return 0;
}

Python

def quicksort(arr):
    #
    # Your implementation here...
    #


def main():
    arr = [2, 3, 0, 4]
    sorted_arr = quicksort(arr)
    print(sorted_arr)

    
if __name__ == '__main__':
    main()

Java

public class QuickSort {
    
    static void quickSort(int[] a) {
        /*
            Your implementation here...
        */
    }
    
    public static void main(String[] args) {
        int[] arr = new int[] {2, 3, 0, 4};
        quickSort(arr);
        for(int element: arr) {
            System.out.println(element);
        }
    }
}

Golang

package main

import "fmt"

// QuickSort sorts an array using QuickSort algorithm
func QuickSort(array []int) []int {
    // Your implementation here
    return array
}

func main() {
    array := []int{2, 3, 0, 4}
    sortedArray := QuickSort(array)
    fmt.Println(sortedArray)
}

JavaScript

function quickSort (arr) {
	/*
	Your implementation here
	*/
}

function main () {
	let input = [2, 3, 0, 4];
	quickSort(input);
	for (let x in input) {
        // relevant implementations
	}
}

main();

C#

using System;

public class QuickSort
{  
    public static void DoQuickSort(int[] a)
    {
        /*
            Your implementation here...
        */
    }
    
    public static void Main()
    {
        int[] arr = new int[] {2, 3, 0, 4};
        DoQuickSort(arr);
        foreach(int element in arr)
        {
            Console.Write(element + " ");
        }
        Console.WriteLine("");
    }
}