Business Programming

Course announcements for INFS1609 and INFS2609

Business Programming random header image

Lab Week 5 – Algorithms

Posted by on August 9th, 2012 · Labs

If you did not finish all the exercises from last week’s lab, try to finish them off this week. If you have already completed those exercises, try these ones.

Exercise 1. Write a method that accepts two arguments, an integer and an array of integers. Assume that the numbers in the array are sorted in ascending order. Your method should return a new array that is one element longer than the first array and with the first argument inserted into the array, in the correct position.

Exercise 2. Now suppose that we want to insert the number into the same array, rather than creating a new one. Assume that the array is long enough to accommodate the extra element. What would you have to do? What complications arise in this version and how would you handle them?

No Comments so far ↓

Comments are closed.