Question: a. Describe an O(n) algorithm to remove all the even numbers from an array which contains n positive integers. Odd numbers should preserve the same

a. Describe an O(n) algorithm to remove all the even numbers from an array which contains n positive integers. Odd numbers should preserve the same relative order they were in originally.

b. Given an infinite sorted array consisting 0s and 1s. Write an efficient algorithm to find the index of first 1 in that array. Derive the time complexity of the algorithm.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a Algorithm to Remove All Even Numbers from an Array in On Time To remove all even numbers from an array of n positive integers and preserve the relat... 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 Databases Questions!