Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here we will combine the familiar task of constructing arrays with the new ideas of functions and conditional statements. Write a function named array _

Here we will combine the familiar task of constructing arrays with the new ideas of functions and conditional statements.
Write a function named array_builder that takes two inputs, positive integers i and n, and outputs a vector v. The output v should depend on i and n as follows:
If i=1, return a vector v=[1,2,3,dots,n]
If i=2, return a vector v=[n,n-1,n-2,dots,1]
If i=3, return a vector v=[1,-1,1,-1,dots]$ (total length n).
If i=4, return a vector v=[12,32,52,dots,(2n+1)2]
If i=5, return a vector v=[n,n-1,dots,1,0,1,dots,n-1,n]
If i=6, return a vector v=[2,11,101,1001,10001,dots](total length n)
If i=7, return a vector v=[2,7,12,17,dots](last value not exceeding n).
If i=8, return a vector v=[1,-5,9,-13,17,-21,25,dots](total length n)
If i=9, return a vector v=[0,0,1,0,0,1,dots,0,0,1](total length 3n)
You can assume that i is one of these values.
Function
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions