Giter Club home page Giter Club logo

algorithms's Introduction

Algorithms QA check

This repository contains my solution for common algorithms. I've created this repository to learn about algorithms and improve solutions to common computer science problems. I'll try to add more solutions if I have time. :)

Each solution has a Java program and is tested. Some problems contain multiple solutions with different implementations.

You can check the solution executing tests inside tests directory. Some problems were resolved using TDD.

Problems

Trees

Linked List

Strings

Binary Numbers and bits operators

Math Operations

Sequences

Arrays

Sorting Algorithms

Misc

Developed By

Follow me on Twitter Add me to Linkedin

License

Copyright 2014 Pedro Vicente Gómez Sánchez

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

algorithms's People

Contributors

ajinkyakolhe112 avatar alaztetik avatar azizurice avatar bigscorpions avatar bryanchan777 avatar contextshuffling avatar hearen avatar isaaccisneros avatar java-codehunger avatar lprone avatar luzmane avatar nlucian avatar pedrovgs avatar pengood avatar tm4s avatar youremai avatar zephyrjung 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

algorithms's Issues

May I add Karatsuba?

It would be helpful for you to add Karatsuba as it is used to get fastest multiplication.

Package names are not descriptive: "package com.github.pedrovgs.problem65"

I guess package names should not contain anything as meaningless as "problem65". The greatest virtue of today's world is a code reuse. I would like to import code from something with a descriptive name so as not to confuse my followers.

Why isn't it called package com.github.pedrovgs.algorithms.IsTreeBalanced?

AreAnagrams

int[] lettersA = getLettersAsArray(a);
int[] lettersB = getLettersAsArray(b);

lettersA and lettersB must have the same content. not same count.

Contribute?

Can i contribute to this repo? E.G add more sorting algorithms etc?

Question about problem44 test

https://github.com/pedrovgs/Algorithms/blob/master/src/test/java/com/github/pedrovgs/problem44/FindMinNumberAtPositionTest.java#L47

Why it should cause a exception when there is a element in the tree and the position is 1?
it should return the element whose index is position-1, isn't it?
https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem44/FindMinNumberAtPosition.java#L52
I think this line should be:

if (position > orderedElements.size()) {

or you can't get the last element in the tree

AreAnagrams is wrong

The Anagrams algorithm is wrong. Consider the following test case:

public class AreAnagramsTest {
    @Test
    public void check() throws Exception {
        AreAnagrams areAnagrams = new AreAnagrams();
        assertFalse(areAnagrams.check("abc", "efg"));
    }
}

You cannot use sums of the values. You need to compare whether you have enough characters in each array one by one.

Can I contribute ?

In the sorting quick sort is not there.So can I send PR.
Is there any coding style to follow?

problem23 / FakeFile getLine() ?

Hi,

Is there really a class "FakeFile" ? Because File has not getLine() method ?

That's for RemoveComments.java / line 46 and 65 ?

I want add Chinese comments to this project

I'm a senior student from China and i'm learning Java in recent days.I think your project is cool,so I wanna to add some comments in chinese to improve my schoolmates and myself.

Update readme.md file

I just happen here in your repo and work is pretty much nice.
Can I give one suggestion about content structure readme file?

  • Add one table of contents.
  • Path of link look like bad can just update like

Why don't you have a main?

Disclaimer: noob

When I type javac Trie.java I get this output

Trie.java:5: error: package com.jwetherell.algorithms.data_structures.interfaces does not exist
import com.jwetherell.algorithms.data_structures.interfaces.ITree

I am confused about the bubble sort.

I read your code and I don't think the bubble sort is like what I read from the algorithm books. I don't get it. The comment says 'compares each pair of adjacent items and swaps them if they are in the wrong order',but it is not. The code is compare the elment to the others every step(not adjacent ones). It works but it is not as the comment says.

80 quicksort is into infinite loop

Please have a try with the following test using JUnit, it will fail with timeout.

Please hold a sec, I am starting a PR for this along with tests later (today).

public class QuickSortGitTest {
    private static final int[] unorderedIntegerArrayThree = {12, -37, -5, 43, 62, 45, -95, -70, -55, -62, -24, -14,
            -75, 43, 9, 58, -62, -22, -55};

    private static void quickSort(int[] numbers, int left, int right) {
        if (left < right) {
            int pivotIndex = partition(numbers, left, right);
            quickSort(numbers, left, pivotIndex - 1);  //sort left of pivot
            quickSort(numbers, pivotIndex, right);  //sort right of pivot
        }
    }

//    private static int partition(int[] array, int low, int high) {
//        int pivot = array[high];
//        int i = low - 1;
//        for (int j = low; j <= high - 1; j++)
//            if (array[j] <= pivot)
//                swap(array, ++i, j);
//
//        swap(array, i + 1, high);
//        return i + 1;
//    }
//
//    private static void swap(int[] array, int i, int j) {
//        int temp;
//        temp = array[i];
//        array[i] = array[j];
//        array[j] = temp;
//    }

    private static int partition(int[] numbers, int left, int right) {
        int pivot = numbers[right];
        while (left < right) {
            while (numbers[left] < pivot) {
                left++;
            }
            while (numbers[right] > pivot) {
                right--;
            }
            if (left <= right) {
                int temp = numbers[left];
                numbers[left] = numbers[right];
                numbers[right] = temp;
            }
        }
        return left; //pivot index
    }

    @Test(timeout = 5 * 1000)
    public void testRecursionZero() {
        quickSort(unorderedIntegerArrayThree, 0, unorderedIntegerArrayThree.length - 1);
    }
}

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.