What is the asymptotic complexity (or the big-O) of the following function? Brie
ID: 3537804 • Letter: W
Question
What is the asymptotic complexity (or the big-O) of the following function? Briefly explain how you arrived at your answer.
Note: No programming is necessary for this problem. Just state the big-O of the function, and
provide a couple of sentences explaining how you arrived at the solution.
template <class Type>
void printQueue(linkedQueueType<Type>& queue)
{
Type item;
linkedQueueType<Type> tmpQueue = queue;
while (queue.isEmptyQueue() == false)
{
item = queue.front();
queue.deleteQueue();
cout << item << " ";
}
queue = tmpQueue;
}
Explanation / Answer
complexity=O(n)
since,out of the 13 lines line no-6(loop) runs n times ,rest all lines are of order 1
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.