-1
I would like an explanation of how to calculate the complexity of the algorithm below. I couldn’t understand very well using graph theory.
FUNCTION PageRank (G, iterarion)
d = 0.85
oh = G
ih = G
N = G
for all p in the graph do
opg[p] = 1 / N
end for
while iteration > 0 do
dp = 0
for all p that has no out-links do
dp = dp + d * (opg[p] / N)
end for
for all p in the graph G do
npg[p] = dp + ((1-d)/N)
for all ip int ih[p] do
npg[p] = npg[p] + ((d*opg[ip])/oh[ip])
end for
end for
opg = npg
iteration = iteration - 1
end while
end function
The image below helps to better visualize the algorithm with its respective lines.
Possible duplicate of What is the complexity of an algorithm?
– Francisco
This is an algorithm distinct from the other questions. So there is no possible duplicate @Francisco
– Leomar de Souza
I ran the algorithm. The image helps to visualize each line better, so I chose to place it, since there are mathematical operations that can become complex to be viewed @diegofm
– Leomar de Souza
@diegofm I did not change the edit, I just put the pseudocode and left the image. Only this change I did
– Leomar de Souza
Got it, anyway, gets the hint when add code more than one line, use the
{}
that it formats better :)– user28595
The time complexity of the algorithm is how much it takes to process the instructions for a middle input, also has the best input and the worst entry. In this case, you need to weigh the weight of each operation (usually each small arithmetic operation has weight 1) and, if it has repetition, how many times it repeats. I will post a full reply later
– Jefferson Quesado
Thanks @Jeffersonquesado. I’ll be waiting :)
– Leomar de Souza