edited by
6,522 views
1 votes
1 votes

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)$
edited by

2 Answers

1 votes
1 votes
D is the answer

Since the operation will involve only a pointer modification which will take O(1)
0 votes
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.

Related questions

0 votes
0 votes
1 answer
1
go_editor asked Mar 27, 2020
573 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 votes
0 votes
2 answers
2
go_editor asked Mar 27, 2020
1,081 views
The equivalent postfix expression for $d{\large /}(e+f)+b*c$ :$defbc/++*$$def+/bc+*$$def+/bc*+$None of these
0 votes
0 votes
1 answer
3
go_editor asked Mar 27, 2020
822 views
Which one of the following is a physical data structure ?ArrayLinked listsStacksTables
0 votes
0 votes
1 answer
4
go_editor asked Mar 27, 2020
1,531 views
Which of the regular expressions corresponds to this grammar ?$S → AB/AS, A → a/aA, B → b$$aa^*b^+$$aa^*b$$(ab)^*$$a(ab)^*$