Coder Social home page Coder Social logo

laba.solvd-week2's Introduction

Week 2 Homework

Laba.Solvd Nodejs Course

About


Assignment

  1. Write a function that adds a number passed to it to an internal sum and returns itself with its internal sum set to the new value, so it can be chained in a functional manner. Example of usage:

    sum(1) //1
    sum(1)(2) //2
    sum(1)(2)(3)(4)(5)(6)(7) //28
    
  2. Write a realisation of a debounce function, here is the specification:

    debounce(func, [wait=0])
    

    Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked. The func is invoked with the last arguments provided to the debounced function. Subsequent calls to the debounced function return the result of the last func invocation.

  3. Found length of array on which QuickSort starts working faster then BubbleSort

    You should implement sorts by your own

    For sorting use 3 types of arrays

    • Sorted
    • Sorted Backward
    • With random placement of element

    You can start with 2 elements and than increment number of element When you reach result, run it few times to check different random on arrays After you found result you can check few more length to compare how fast time growth on BubbleSort comparing to QuickSort

  4. For the following Θ-difficulties, write strict and non-strict O-limits and, optionally, strict and non-strict Ω-limits (provided that they exist).

    1. Θ( 1 )
    2. Θ( √n )
    3. Θ( n )
    4. Θ( n^2 )
    5. Θ( n^3 )

Getting Started


Prerequisites

npm install npm@latest -g

Installation

  1. Clone the repo

    git clone https://github.com/Cmoros/laba.solvd-week2.git
  2. Go to the project folder

    cd laba.solvd-week2
  3. Install NPM packages

    npm install

Usage


To Test All (if it fails, consider reading below the comparing part):

npm t
  • Testing sum:

    npm run test:sum
    
  • Testing bounce: npm run test:bounce

  • Testing quicksort:

    npm run test:quicksort
    
  • Testing bubblesort:

    npm run test:bubblesort
    
  • Testing all comparisson between QuickSort and BubbleSort. Considerar that if some test fails, it is because the tests assume that bubblesort is father than quicksort in range of 2 to 5, if that doesn't happen, then the test fails, meaning that in that specific sorted array, that assumption doesn't happen.

    npm run test:comparing
    

    Testing in particular:

    • Sorted Arrays:

      npm run test:sorted
      
    • Sorted Backward Arrays:

      npm run test:backward
      
    • Sorted Random Arrays:

      npm run test:random
      

Comparing Results

Consider tests are done in a range of up to 50 elements in an Array, and each number of the array is in range of 0 to 1000 produced randomly with Math.random()

Sorted Array

QuickSort never gets to beat bubbleSort at any length.

SortedBackward

In these tests, quicksort often get to beat bubblesort at 2 elements, then it doesn't beat bubblesort until 36-39 range, for that reason, first test with npm run test:backward or the test that involves sorted backward with npm run test:comparing can fail. It also gets differente results with a different NUMBER_OF_TESTS

Random

Quick gets to beat bubbleSort in 9-11 range.

laba.solvd-week2's People

Contributors

cmoros avatar

Watchers

 avatar

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.