Home > Algorithms
Algorithm requested (Posted on 2013-12-18) |
|
Given an array with random odd and even integers. Please suggest the most efficient algorithm to put all even numbers on one side and all odd numbers on the other side in this array.
Source: Got an Email from an unknown person.
|
Submitted by Ady TZIDON
|
Rating: 4.0000 (1 votes)
|
|
Solution:
|
(Hide)
|
Larry's way(reworded):
(1) convert each number to base 2,then reverse its
digits.
(2) sort all the numbers from smallest to largest.
(3) reverse the digits in each number and convert each to base 10.
The new array starts with all even numbers.
|
Comments: (
You must be logged in to post comments.)
|
|
Please log in:
Forums (0)
Newest Problems
Random Problem
FAQ |
About This Site
Site Statistics
New Comments (5)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On
Chatterbox:
|