Giter Site home page Giter Site logo

goeunpark / restricted-arrays-part1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ada-c10/restricted-arrays-part1

0.0 1.0 0.0 10 KB

Assignment to work with array data structure or restricted arrays (as compared to Ruby Array class).

Ruby 100.00%

restricted-arrays-part1's Introduction

Restricted-Array

Assignment: Develop common methods on data structure using a restricted array. restricted_array.rb provides the RestrictedArray class to be used. RestrictedArray allows you to:

  1. Create an integer array of default size (i.e. 20) or of the size provided in the parameter. All integer values are randomly initialized in the range of 1-221.
  2. Get the value at a given index using array[index] format.
  3. Update the value at a given index using array[index] format. None of the other methods available in the Ruby Array class are available in the RestrictedArray class.

Exercise

Implement the methods in using_restricted_array.rb. Methods to implement are:

  • length - which calculates the length of the integer array and returns it. Note: The restricted_array is terminated by nil i.e. array[length] = nil
  • print_array - which prints each integer value separated by space on the same line
  • reverse - which reverses the values in the array in place
  • search - which looks for a given integer value in the array. Returns true if found, false otherwise. Note: do not assume that the array is sorted.
  • binary_search - which looks for a given integer value in the array. Returns true if found, false otherwise. Note: Assume that the array is sorted in ascending order.
  • find_largest - Finds and returns the largest value element in the integer array.
  • find_smallest - Finds and returns the smallest value element in the integer array.

restricted-arrays-part1's People

Contributors

shrutivanw avatar goeunpark avatar

Watchers

James Cloos 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.