Solved–Assignment 06– Solution

$30.00 $19.00

Write and test a simple method everyNth that accepts a list L and a positive integer N and returns a list containing every Nth element of L, starting with the (N−1)st element, then the (2N−1)st element, and so on until L’s elements are exhausted so that the returned list’s size is ⌊L.size / N⌋ (where…

You’ll get a: . zip file solution

 

 

Description

5/5 – (2 votes)

Write and test a simple method everyNth that accepts a list L and a positive integer N and returns a list containing every Nth element of L, starting with the (N−1)st element, then the (2N−1)st element, and so on until L’s elements are exhausted so that the returned list’s size is ⌊L.size / N⌋ (where ⌊x⌋ is the floor of x). The method should accept a list of any type, should return a list of the same type, and should consume O(N) time and space. The returned value should be immutable; any later changes to the input list should not affect the output list.