Giter VIP home page Giter VIP logo

algorithmssedgewick's Introduction

The following data files are missing from this repository, due to their large size:

File                Size     Used by
-------------   --------     ---------------------
leipzig1M.txt   129.6 MB     3-Searching
UPC.csv          48.1 MB     3-Searching
largeUF.txt      25.8 MB     1-Fundamentals
largeT.txt        7.0 MB     1-Fundamentals
largeW.txt        7.0 MB     1-Fundamentals
movies.txt        3.4 MB     3-Searching, 4-Graphs
mobydick.txt      1.2 MB     6-Context
DJIA.csv          1.1 MB     3-Searching

An archive that contains these data files (as well as all the other ones used in the book) can be found at:
http://algs4.cs.princeton.edu/code/algs4-data.zip

algorithmssedgewick's People

Contributors

aistrate 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

algorithmssedgewick's Issues

Why use the c.incremen(); in the Ex_1_1_27a.java?

In the Ex_1_1_27a.java binomial() function, I test the code,but there is a error :

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method incremen() is undefined for the type Counter

In your program, the incremen() is undefined, so, how can the this program run successfully?

I know the Counter c is used to cumulative the number of recursive calls, but can't understand why use the function c.incremen().

I think now that c is used to cumulative the number of recursive calls, I use this program:

public static double binomial( int n, int k, double p, int c) {
        if ( n == 0 && k == 0) {
            return 1.0;
        }
        if ( n < 0 || k < 0) {
            return 0.0;
        }

        c++;  

        return (1.0 - p) * binomial( n - 1, k, p, c) + p * binomial( n - 1, k - 1, p, c);
    }
    public static void main(String[] args) {
        int n = Integer.parseInt(args[0]),
            k = Integer.parseInt(args[1]);
        double p = Double.parseDouble(args[2]);

        int c = 0;

        double b = binomial(n, k, p, c);

        StdOut.println(b);
        StdOut.println(c);
    }

I test 10 5 0.5, but I get the result: 0.24609375 0.

I hope to help me Solve this doubt,thanks a lot !

Implementation of Heap sort

private static void exch(Object[] pq, int i, int j) {

Thanks for your work on this. I'm currently going over the book and I have been a little off by the section on Heapsort. One of the things that I was confused about was dealing with the index 1 to N in the sorting method. I noticed from your implementation that you use -1 in the swap and in the less but have you tested?

class Heap
  # Trickledown
  def sink(a, k, n)
    while 2 * k <= n
      j = 2 * k # child

      if !a[j + 1].nil? # check if there is a right child
        j += 1 if j > 1 && less(a, j, j + 1) # if left child less than right child
      end

      break if !less(a, k, j) # If parent greater than child break

      swap(a, k, j)
      k = j
    end
  end

  def sort(a)
    n = a.length
    k = n / 2

    while k >= 1
      sink(a, k, n)
      k -= 1
    end

    while n > 1
      swap(a, 1, n)
      n -= 1
      sink(a, 1, n)
    end
    a
  end

  def less(pq, i, j)
    pq[i - 1] < pq[j - 1]
  end

  def swap(a, i, j)
    temp = a[i - 1]
    a[i - 1] = a[j - 1]
    a[j - 1] = temp
  end
end

When I do your implementation in Ruby I get the error for as the answer ["A", "M", "E", "L", "E", "O", "P", "R", "S", "T", "X"] and I haven't been able to figure out why.

I created the following post on Stackoverflow
https://stackoverflow.com/questions/63634906/ruby-heapsort-sink-undefined-method-for-nilnilclass

trying to figure out where am I off.

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.