I am new for this codecall. I need your help. I understand above pseudocode.
Can u help me to writer the pseudcode for below questions?
1.Multiple by 8 without using multiplication or addition.
2. Suppose you have an array of 1000 integers. The integers are in random order, but you know each of the integers is between 1 and 5000 (inclusive). In addition, each number appears only once in the array. Assume that you can access each element of the array only once. Describe an algorithm to sort it.
3. If you used auxiliary storage in your algorithm, can you find an algorithm that remains O(n) space complexity?
Thank you very much for your time. I look forward from you.
Pls help me to write Pseudocode for below my question
Started by abisiva, Aug 25 2010 07:36 PM
1 reply to this topic
#1
Posted 25 August 2010 - 07:36 PM
|
|
|
#2
Posted 26 August 2010 - 03:52 AM
1.Multiple by 8 without using multiplication or addition.
(Shift bits 3 times to left)
2. Create a new boolean array of 5000, iterate over old array and for every found integer, raise a flag in the boolean array at the index, which equals to the found integer. After that you can iterate over the new array and place the indexes, which are "flagged" to random integer array. (Algorithm requires 1 iteration over the old array, and 1 iteration over the new array)
3. Algorithm described above is O(n)
(Shift bits 3 times to left)
2. Create a new boolean array of 5000, iterate over old array and for every found integer, raise a flag in the boolean array at the index, which equals to the found integer. After that you can iterate over the new array and place the indexes, which are "flagged" to random integer array. (Algorithm requires 1 iteration over the old array, and 1 iteration over the new array)
3. Algorithm described above is O(n)


Sign In
Create Account

Back to top









