Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 3 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 27 Aug 2017 My Price 10.00

RUBY PROGRAMMING LANGUAGE

USE RUBY PROGRAMMING LANGUAGE FOR THE SOLUTION
Problem 1

Where a is an array, a.delete(obj) deletes every item from a that is equal to obj:

>> a

=> [1, 2, 1, 3, 1, 4, 2, 5]

>> a.delete(1)

=> 1

>> a

=> [2, 3, 4, 2, 5]

Write the function delete_first(a, obj) that deletes from a only its first item that is equal to obj, if any. The function returns the modified array.

>> a

=> [1, 2, 1, 3, 1, 4, 2, 5]

>> delete_first(a, 1)

=> [2, 1, 3, 1, 4, 2, 5]

>> a

=> [2, 1, 3, 1, 4, 2, 5]

>> delete_first(a, 1)

=> [2, 3, 1, 4, 2, 5]

>> a

=> [2, 3, 1, 4, 2, 5]

>> delete_first(a, 18)

=> [2, 3, 1, 4, 2, 5]

>> a

=> [2, 3, 1, 4, 2, 5]

 

Problem 2

The Fibonacci sequence fib is defined thus: fib(1) = fib(2) = 1, and fib(n) = fib(n-1)+fib(n-2) for n>2. Write a function fib_array(n) that returns an array containing the first n values of the Fibonacci sequence. For example:

print fib_array(1)

# [1]

print fib_array(2)

# [1, 1]

print fib_array(10)

# [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

 

Problem 3

 

Write a function fib(n) that returns the n’th Fibonacci value:

print fib(10)

# 55

print fib(100)

# 354224848179261915075

Answers

(5)
Status NEW Posted 27 Aug 2017 09:08 AM My Price 10.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)