hello ppl. please help me solve these two questions. i need them ASAP please. i also need to know, how do u calculate them, specially the second one (No 4)

Thank you for helping me(Rofl)

Printable View

- Sep 21st 2008, 06:45 PMnarbeAlgorithm and Integers problem
hello ppl. please help me solve these two questions. i need them ASAP please. i also need to know, how do u calculate them, specially the second one (No 4)

Thank you for helping me(Rofl) - Sep 21st 2008, 06:51 PMJhevon
for (4)

do you realize that by successive squaring you are multiplying the power of x by 2 each time, while if you take the approach of multiplying x by itself, you are adding 1 to the power each time? in the first approach, how many time would you have to square then? will it be faster than adding 1 each time? - Sep 21st 2008, 07:33 PMjbpellerin
for the first question

linear

go to the first element, it is not 7, keep going, second element, not 7, keep going... until you reach an element larger than 7, then you know 7 is not in this sequence (since it is sorted)

binary

go to the middle element, it is smaller then seven, so use the right subset

go to the middle of this subset, it is larger than 7 so use the left subset of this

and so on, i think you get what i'm saying