Coder Social home page Coder Social logo

dsa-arrays's Introduction

DSA-Arrays

What is the length, capacity and memory address of your array?

  • for arr.push(3)

    length: 1, _capacity: 0, ptr: 0

  • for all pushes

    length: 6, _capacity: 0, ptr: 15

Explain the result of your program after adding the new lines of code.

Seems to show the length of the array as well as the total space allocated (ptr). The _capacity is unchanged as it was never used.

the ptr is the sum of the oldPtr and the array length

What is the length, capacity, and address of your array?

length: 3, _capacity: 0, ptr: 15

Explain the result of your program after adding the new lines of code.

The array length decreased to 3 and values removed. The allocated space has stayed the same.

Print the 1st item in the array arr

Its 0. After printing out the entire array it seems that very few values are something other than 0 and they don't seem to correspond to the values pushed in.

Empty the array and add just 1 item: arr.push("tauhida");

length: 1, _capacity: 0, ptr: 0 Looks like the array has one value but no allocated space? Not sure of the signifigance but if you muliply the org length and the new length, you get the ptr.

What is the purpose of the _resize() function in your Array class?

I'm not sure. From what I can see it is determining whether or not there is space available but beyond that I'm not certain. It seems to be clearing the oldPtr space but keeping a record of the oldPtr along with the current ptr and the current length in the copy method.

dsa-arrays's People

Contributors

joshrlear avatar

Watchers

 avatar  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.