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
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
Get step-by-step solutions from verified subject matter experts
