in Programming in C
451 views
0 votes
0 votes

in Programming in C
by
451 views

2 Answers

1 vote
1 vote

1)EVEN THOUGH LINKED LIST IS IMPLEMENTED USING ARRAY,TO DELETE A ELEMENT FROM LIST IT TAKES WPRST CASE OF O(N).

because elements are not stored in either incresing order and decresing order,we are not guarantee deleted element occupies which position.so to search entitre list then only know which place it occupies.

2) To reverse the list with the help of last pointer go last node in unit of time and make it as head node.

it is implemented using cirular array ,so no need of change any pointers only first and last pointer .it is done in o(1) time

edited by

3 Comments

As here we are using circular liked list implemented with array so we simply interchange first and last pointer in constant time so it will take O(1)
2
2
Won't it be o(1)?
0
0

 @santhoshdevulapally

Not getting what is this linked list implemented using circular array. Is it like this?

0
0
0 votes
0 votes
1 2 3 4 5 6 7 8 9 10

1) Delete Kth element in linked list implemented using array : 

pos=k;

for (i=pos-1; i<10; i++)
    {
        llist[i] = list[i+1];
    }

so for deletion it will take O(n) time in shifting elements .

2) Reverse Element of linked list:

To reverse linked list we have to just swap head and tail pointers , so it can be done in O(1) time.

Answer: B

Related questions