{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

sec7 - CS100M Section Exercise 7 1 Examining a...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CS100M Section Exercise 7 1 Examining a subarray [From Lab Exercise 6] Write a function vectorQuery(v,n,r) to determine whether the number r appears in the first n cells of vector v . The function returns 1 if r is in the first n cells of v and 0 otherwise. Your function assumes that v is a vector of numbers, n is a positive integer, and r is a number. Use a loop to do the search. Make sure that the loop index doesn’t go “out of bounds” (if n is greater than the length of vector v ). 2 Concatenating arrays [From Lab Exercise 6] Write a function sequence(m) that generates a sequence of random integer numbers between 1 and m , inclusive, stopping when a value is repeated for the first time. The function returns an array containing all the numbers generated (in the order in which they were generated) except for the last value that is a repeated occurrence. Example: If the generated sequence is 3 1 9 5 7 2 5, the array to be returned should be 3 1 9 5 7 2.
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern