Question: Suppose you are given an array, A, of n positive integers. Describe an O(n) algorithm for removing all the even numbers from A. That is,

Suppose you are given an array, A, of n positive integers. Describe an O(n) algorithm for removing all the even numbers from A. That is, if A has m odd numbers, then, after you are done, these odd numbers should occupy the first m cells of A in the same relative order they were in originally.

Step by Step Solution

3.34 Rating (163 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

For this problem we are going to use two variables count ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Data Structures Algorithms Questions!