Giter Site home page Giter Site logo

doccompare's Introduction

Welcome!

David J DeBonis

doccompare's People

Contributors

djdebonis avatar

Watchers

 avatar

doccompare's Issues

algorithm analysis of functions and reducing iteration costs

We are working with extremely expensive functions, especially when we are working with large sets of data. Thus it's important for us to do a bit of algorithm analysis and to determine whether can reduce iteration costs with some steps. Here is the initial function:

def getIntersect(set1, set2):

    intersectSet = []

    for index,ngram in enumerate(set1):
        if ngram not in intersectSet:
            if ngram in set2:
                intersectSet.append(ngram)
 
    return(intersectSet)
        

so here in the first loop we have iteration 1, which we will call n1 of len(set1)

then we have line 2: this iteration size changes as the program progresses, but we know that it cannot iterate more than len(set1) + len(set2) because due to the lines below it is not possible to exceed this because it accounts for all unique values between both. So, let's set n2 = len(set2) and so n3 will be (n1 + n2)

the third line iterates through set2, which we previously decided was the length of n2.

and so our final length is equal to n1 * (n1 + n2) * n2. if n4 is max([len(set1), len(set2)]), then big-oh is O(n4^3)

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.