1 1 vote What is the time required to insert an element in a stack with linked implementation ? $O (\log_2 n)$ $O (n)$ $O (n\log_2 n)$ $O (1)$ Data Structures ugcnetcse-dec2006-paper2 stack data-structures time-complexity + – go_editor 7.7k views answer comment Share Follow Print See all 2 Comments 2 2 Comments reply Nirmal Gaur commented Sep 29, 2017 reply Follow flag here nothing is given about the order in which the element to be inserted , we just have to take the data from the list and push it onto the stack...since both operations requires constant time O(1) would be the correct answer... Note:if n elements are to be inserted then complexity would be O(n). 1 1 replyShare vg653 commented Mar 28, 2020 reply Follow flag O(1) 1 1 replyShare Please log in or register to add a comment.
1 1 vote D is the answer Since the operation will involve only a pointer modification which will take O(1) amaity answered Sep 29, 2017 amaity comment Share Follow See 1 comment 1 1 comment reply Kaluti commented Oct 1, 2017 reply Follow flag o(1) will be answer as element that is to be inserted in front of top pointer and then top pointer is modified to point to that new inserted element 0 0 replyShare Please log in or register to add a comment.
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. AkashChandraGupta answered Aug 6, 2020 AkashChandraGupta comment Share Follow 0 reply Please log in or register to add a comment.