Write a function that takes an array of numbers a
, and
returns an array with the elements of a
in reversed
order. Use only Array#length
and array indices for
array access. (In other words, no Array#reverse
,
Array#<<
, Array#pop
, etc!)
Reverse the array in O(1) (constant) space, that is, don't
use more than a fixed number of additional variables,
regardless of the length of a
.
Write a list_append
function, that takes a linked
list l1
and a linked list l2
and returns a
linked list with l2
appended to the end of l1
.
(Think l1
+ l2
).
Write a list_prepend
function, that takes a linked
list l1
and a linked list l2
and returns a
linked list with l2
prepended to the beginning of l1
.
(Think l2
+ l1
).
Write a method insert_after
that takes a linked list
l1
, a linked list l2
, and a value v
, and
inserts the list l2
after the first occurance of
the value v
in l1
.
Write a method insert_before
that takes a linked list
l1
, a linked list l2
, and a value v
, and
inserts the list l2
before the first occurance of
the value v
in l1
.