|
I have a DAG of N nodes ( say million ) that I will querying for connectivity of two nodes [ isConnected(a,b} ]. I will be querying the DAG M ( say million ) times. Is there a way to optimize the process?
Here are the best approaches that I could come up with.
BFS = O( M * N )
Dijkstra = O( M* E* log N)
Is there any other better approach for this process ?
|
|
|
|
|
Dear all,
I am trying to do dual axis solar tracker with seasonal tilt.
Necessary Document:
1)Below links gives us calculation sun elevation/ azimuth angle.
http://www.nrel.gov/midc/spa/[^]
2)i am using Inclinometer to determine actual motion of tracker
Questions:
1) can someone give me algorithm flowchart for Dual axis solar tracker.
2)Dual axis tracker will move either horizontal/ vertical axis .How/when to set motion of motor along its axis.
3)what are the angle we need to taken consideration for calculation.
|
|
|
|
|
Hello, I have a variation of the weighted activity selection problem I could use some help with. The problem is that there are activities that have a start time, finish time, and profit. I need to find the maximum profit achievable with the variation that there must be more "short" activities used than "long" activities. Where a short activity is an activity with duration less than 5 (finish time - start time). I have solved the problem without the variation, not sure how to implement the restrictions. This is homework so i am only looking for help with the recursion.
|
|
|
|
|
"...there must be more "short" activities used than "long" activities."
In the recursive step (where I assume you add another activity), just skip adding "long" activities when the number of short activities is less than or equal to the number of long activities minus one.
|
|
|
|
|
Presumably you are picking the best solution based on the final weight score.
And presumably you have an idea of what "more" means.
Then while spanning the graph you keep track of a count for long and short. Then at the end you provide an additional weight value based on the "more" calculation. So for example if you just need to do 'short > long' for the comparison then you might add a weight of '5' to the total if that is true. Or if you need to do a difference between long and short then you would multiple that difference by '5' and add it to the score. For that latter solution you should consider if you want to deal with a negative difference or not.
|
|
|
|
|
Hi I am in a college programming class and I am kind of confused how to write this pseudocode.
It says "Write the pseudocode for problem 9-2.5"
9-2.5-
Prompt the user to input a temperature in the Fahrenheit scale. Then display its equivalent in the Celsius scale. Repeat until a temperature of 9999 is entered.
Example Preudocode:
INPUT length, width
LET area = length * width
OUTPUT area
or
LET count = 1
LET total_area = 0
DO WHILE count < = 4
INPUT length, width
LET area = length * width
LET total_area = total_area + area
LET count = count +1
LOOP
OUTPUT total_area
|
|
|
|
|
What exactly are you confused about? What have you tried so far?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I am unsure how to write this pseudocode altogether lol.
|
|
|
|
|
It amounts to simply writing down the steps necessary to complete the task. Since it's pseudo code, you don't need to be technically accurate.
What is the first thing that has to happen to solve this problem? What is the second thing?
Hint:
1. User enters number
2. First step to calculate answer
3. Second step to calculate answer
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Here's one clue: when you want to have a loop that is guaranteed to be executed once, that construct is: Do ... While. In this case consider:
Do
// code
// code
While (the user has not entered 9999)
"What Turing gave us for the first time (and without Turing you just couldn't do any of this) is he gave us a way of thinking about and taking seriously and thinking in a disciplined way about phenomena that have, as I like to say, trillions of moving parts.
Until the late 20th century, nobody knew how to take seriously a machine with a trillion moving parts. It's just mind-boggling." Daniel C. Dennett
|
|
|
|
|
There is no standard for writing pseudo-code, so you almost free to write without bounds of language syntax (however I saw universities with there own standard, and if you have something like this at your college, you should use it).
Read about the idea of pseudo-code - start here http://en.wikipedia.org/wiki/Pseudocode[^]
This is one sample to the '9-2.5' problem...
GET temp_f
WHILE temp_f != 9999
COMPUTE temp_c = (temp_f - 32) * 5/9
PRINT temp_c
GET temp_f
LOOP
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is (V).
|
|
|
|
|
Thanks a lot man! I appreciate it!
|
|
|
|
|
You're not supposed to do the work for him!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I believe in innocent. His not asked just because his lazy but because he don't know how to ask even.
So beside to give him some - not very bright - solution I tried to point him to the right direction...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is (V).
|
|
|
|
|
It's quite clear from the original question that this is a college assignment. So by giving him the answer you are not really helping him. It's much better that people like him learn to think for themselves and at least try to work out the answer.
Veni, vidi, abiit domum
|
|
|
|
|
I made a website (my master project at Technical University of Graz) where you can find animations of some algorithms.
It is made with SVG/Javascript. You can run/pause/step/back an algorithm and see the pseudo code variables changing in real time.
It should be very helpful for Bsc students and also teachers can use it during lectures.
The site is called: alg0rithms.com (0 = zero)
I'm waiting for your feedbacks...
|
|
|
|
|
Perhaps some more algorithms, for example heapsort, bucket sort, counting sort, shell sort, midpoint circle algorithm..
Btw I think this may technically be the wrong forum for this type of question
|
|
|
|
|
Thank you for your feedback. I will do that if the site gets enough users.
|
|
|
|
|
It's nice, and you made me curious. What master project for?
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is (V).
|
|
|
|
|
Thank you. It is a master project for visualization of algorithms at TU Graz.
|
|
|
|
|
It looks really good. After seeing your work, I am planning to implement the same in .net technology MVC. I think you have used php.
modified 2-Dec-13 6:28am.
|
|
|
|
|
Thank you. Yes a mix of PHP and JavaScript.
|
|
|
|
|
I tried to watch the site but don't work.
Changed address ?
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
Hi, I want to implement a ceiling function:
x++;
if ( x>7 ) x =7;
Anybody know if there is a bit-wise expression fit the same function?
modified 6-Nov-13 16:14pm.
|
|
|
|
|
Certainly, but it's going to suck unless you make some assumptions.
For example, if x is known to be < 8 and bigger than -2 before the increment, then it's enough to do this:
x++;
x -= x >> 3; which subtracts 0 if x is already less than 8, otherwise x is 8 (because of the assumption) and it subtracts 1.
Or, if you have 32 bit ints (pretty common, and you can adapt it to other widths) and arithmetic shifts (you usually do) and x is known to be less than 8 and bigger than -2147483642 prior to the increment:
x -= (x - 7) >> 31;
which effectively adds one if (x - 7) is negative (ie if x is less than 7)
Or, if you have 32 bit ints (adaptable), arithmetic shifts, and x is pretty much anything, you can do
x++;
int mask = (x - 7) >> 31;
x = (mask & x) | (~mask & 7);
which uses the "bitwise minimum" trick, and it valid for almost all x, except x < 0x80000006 or x == 0x7fffffff
|
|
|
|