retagged by
7,666 views
1 1 vote

What is the time required to insert an element in a stack with linked implementation ?

  1. $O (\log_2 n)$
  2. $O (n)$
  3. $O (n\log_2 n)$
  4. $O (1)$

2 Answers

1 1 vote
D is the answer

Since the operation will involve only a pointer modification which will take O(1)
0 0 votes
Insertion/PUSH is equivalent to the insertion of a node at the beginning of the linked list, which requires constant time. Just modification of two pointers. Therefore PUSH requires constant time.

Hence option D.
Position:
Show:

Related questions

0 0 votes
1 1 answer
1.4k
1.4k views
go_editor asked Mar 27, 2020
1,386 views
Which one of the following is a physical data structure ?ArrayLinked listsStacksTables
0 0 votes
2 2 answers
1.1k
1.1k views
go_editor asked Mar 27, 2020
1,050 views
When a function is recursively called, all automatic variables :are initialized during each execution of the functionare retained from the last executionare maintained in...
0 0 votes
2 2 answers
2.2k
2.2k views
go_editor asked Mar 27, 2020
2,150 views
The equivalent postfix expression for $d{\large /}(e+f)+b*c$ :$defbc/++*$$def+/bc+*$$def+/bc*+$None of these
0 0 votes
1 1 answer
1.5k
1.5k views
go_editor asked Mar 27, 2020
1,519 views
Which algorithm has the same average, worst case and best case time?Binary searchMaximum of n numberQuick sortFibonacci search