The Gateway to Computer Science Excellence
0 votes


in DS by Loyal (6.9k points)
recategorized by | 84 views

O(n) time since you need to reach last node which point to new first node.

For circular double linked list it takes O(1).

Yea exactly but in Ace its Given option B as answer
Actually if all option are in terms of O then O(n) is correct but here we have to choose most appropriate here it will always take (n) time so theata(n) is more appropriate.
in worst case also you have to traverse total linked list and in best case also you have to traverse total linked list


therefore it is ϴ ( n )
Sir Please Elaborate. I didn't get why Theta(n) :)
ohk thnku
Big oh means in worst case it takes n but it can takes constant also , But Theata(n) means always takes n .

I try to explain in terms of number of comparision :

Theata(n) = Number of comaparision can be n-4,n-1, n-2, etc i.e. n assmptotically n.

O(n) means   Number of comaparision can be 1, ,2,3,4,4,5,5,6....n etc not garunteed n but we are sure it cannot go beyond n.

1 Answer

0 votes
inserting new node  1st check node  rear node -->next is  front

it will take o(n)
by (201 points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,647 questions
56,492 answers
100,707 users