Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411528 Posts in 69382 Topics- by 58437 Members - Latest Member: isabel.adojo

May 02, 2024, 07:42:27 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)searching for an algorithm
Pages: [1]
Print
Author Topic: searching for an algorithm  (Read 2886 times)
allan
Guest
« on: February 05, 2010, 03:04:44 AM »

Hello everyone
Am searching for a simple example algorithm that is suitable to be amended according to the
constant execution time paradigm.

and also a proposal to rewrite the algorithm so that the variation in execution time will
be reduced.

Is it possible?
Thanks to you
Logged
Rob Lach
Level 10
*****



View Profile WWW
« Reply #1 on: February 05, 2010, 05:28:34 AM »

Uhhh.... what?
Logged

moi
Level 10
*****


DILF SANTA


View Profile WWW
« Reply #2 on: February 05, 2010, 05:38:42 AM »


Is it possible?

no
Logged

subsystems   subsystems   subsystems
nikki
Level 10
*****


View Profile
« Reply #3 on: February 05, 2010, 05:40:22 AM »

this is what computer science assignments look like Pierog Wink

well kenny since you also posted this exact same question on programmersheaven.com i thought , let's help that university cheating guy out.

I typed "constant execution time" in Google. Found many answers, so i have to say Yes it's possible.
An integer division seems the 'algorithm' you can amend according to 'bla'
An advice i found through Google is to read the book "Numerical Recipes in C" And mostly the last chapter...

for next week's assignment that'll come up ,i am sure, why don't you atleast try to understand the question, so you could restate the question in a more friendly and english way ?
Logged
allan
Guest
« Reply #4 on: February 05, 2010, 05:49:03 AM »

hi nikki
i have been searching it also
and i cant find it
thats why am asking for help here)))
Logged
nikki
Level 10
*****


View Profile
« Reply #5 on: February 05, 2010, 06:04:10 AM »

It'd be more educational to try to understand your own question. Well, hello there!

Since i haven't studied Computer Science (but Fine Art ) i am not the best guy here to help you do your homework. I could give it a go though.
Your question sounds really complicated. But what it means (I believe) is this:

constant execution time paradigm: execution time is NOT dependent on the arguments.
so for example : algorithm(4,80) takes just as long to execute as algorithm(4000300,6000000)

You must know this beter than i do but isn't that an algorithm that takes 0(N) or something ?

so your second sentence means the same as the first (since "amended according to the
constant execution time paradigm"="variation in execution time will
be reduced." )

well anyway , i believe simple arithmetic are algorithm that suit your need, or simple instructions (goto, cin, cout whatever)

to find the same info i just found type google:"constant execution time" and research it!
success


Logged
Hajo
Level 5
*****

Dream Mechanic


View Profile
« Reply #6 on: February 05, 2010, 06:06:16 AM »

I typed "constant execution time" in Google. Found many answers, so i have to say Yes it's possible.
An integer division seems the 'algorithm' you can amend according to 'bla'

Depending on the processor architecture an integer division may take a different number of cycles, depending on the operands. I'm not sure if this is a good example?

Usually the time (complexity) questions need algorithm + data structure to give real answers.

"insert" for a linked list is a constant time operation in most books.

(It's still varying like the integer division, but it does not scale with the size of the list, so it's "constant", while sorting the list is not ...)
Logged

Per aspera ad astra
nikki
Level 10
*****


View Profile
« Reply #7 on: February 05, 2010, 06:11:17 AM »

Quote
I'm not sure if this is a good example?
i beliueve your right and that example was wrong. It was the first link of someone asking the same question on some forum (but a bit more specific).

I was just imagining that you'd come back to your prof. and say "Yep i found it, its GOTO"
that'be a great laugh , and i believe the answer is right.
Logged
brog
Level 7
**



View Profile WWW
« Reply #8 on: February 05, 2010, 06:46:51 AM »

Here is an algorithm with a constant execution time:
Code:
int algorithm(int a)
{
  return 0;
}
Logged
Golds
Loves Juno
Level 10
*


Juno sucks


View Profile WWW
« Reply #9 on: February 05, 2010, 06:48:13 AM »

Hello everyone
Am searching for a simple example algorithm that is suitable to be amended according to the
constant execution time paradigm.

int CheckIfTheInputIsTheNumberThree(int input)
{
   if(input > 2)
   {
      if(input == 3)
          return 1;
   }
   return 0;
}

This  function runs in constant time.  It will take a number and determine if it is 3 in at most 2 conditional checks

and also a proposal to rewrite the algorithm so that the variation in execution time will
be reduced.

Is it possible?

int CheckIfTheInputIsTheNumberThree(int input)
{
   if(input == 3)
         return 1;

   return 0;
}

Now we check in constant time if the input is 3 in only one conditional check, for all cases.

Thanks to you
Logged

@doomlaser, mark johns
Rob Lach
Level 10
*****



View Profile WWW
« Reply #10 on: February 05, 2010, 05:00:01 PM »

this is what computer science assignments look like Pierog Wink

LOL, I guess assignments have changed since I graduated. It just seems so obscurely worded.
Logged

PsySal
Level 8
***


Yaay!


View Profile WWW
« Reply #11 on: February 06, 2010, 01:44:18 PM »

Hello everyone
Am searching for a simple example algorithm that is suitable to be amended according to the
constant execution time paradigm.

and also a proposal to rewrite the algorithm so that the variation in execution time will
be reduced.

Is it possible?
Thanks to you

I call HOMEWORK!
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic