Question

My algorithm is as shown below. It makes a remote call to a server and gets the results process them and again send the remote call to a system. Can you give me an idea what can be time and space complexity of this algorithm?

Get search keyword from user
ϕ := getInfoFromConceptNet(keyword) // makes remote call
e := expandConcepts(ϕ)
expConcepts := {} // adds to an array
for each ec in e // first loop
expConcepts.add(ec) // adds to array
α= expandConcept(ec) //remote call
expConcepts.add(α) // adds to array
αkeywords=getKeywords(α) // calls a function to remove stopwords
for each αkw in αkeywords // second loop
Ω= expandConcept(αkw) // makes remote call
expConcepts.add(Ω) // adds to an array
results[ ]=performsearch(expConcepts,additional information) // searches the array
Was it helpful?

Solution

Your second loop is nested into first? If yes, the complexity analysis given below stands for your algorithm.

Time and space complexity of this algorithm depends on implementations of expandConcept(), getKeywords(), add() and performsearch() functions. For the add(), time and space complexity may be O(1) if just appends its argument to the expConcepts array front index. Assumed that performsearch() performs binary search, which has an O(logN) (N: number of expConcepts elements), time complexity and constant space complexity, and an additional O(M*(expandConcept() time-comp)*K*(expandConcept() time-comp)) (M: cardinal number of set e, K: cardinal number of akeywords), you have a O(M*(expandConcept time-comp)*K*(expandConcept() time-comp)*logN) time complexity. Space complexity depends on expandConcepts() space complexity.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top