please help if you know what you are doing Estimate the run-time complexity of t
ID: 3553825 • Letter: P
Question
please help if you know what you are doing
Estimate the run-time complexity of the following Describe an algorithm to find the middle node (or element) of a singly I inked Iist in one pass, i e, your algorithm will traverse the list starting from the head of the list and ending at the last node with the answer You can use temporary variable in your algorithm What would be the run-time complexity and space complexity of your algorithm representing in BIG-O notation Describe the best case and the worst case scenarios and their run-time complexity of your algorithm aboveExplanation / Answer
1. estimated Time Complexity O(nxn)=O(n^2)
2. find_mid(head)
{
p=head
q=head
while(q->next!=null)
{
p=p->next
q=q->next->next
}
return p;
}
3.runtime complexity O(n)
space complexity O(1) constant
4.best case is when even no of nodes
worst case is odd no of nodes
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.