1 votes 1 votes 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)$ DS ugcnetcse-dec2006-paper2 stack + – go_editor asked Mar 27, 2020 • edited Jun 21, 2022 by Arjun go_editor 6.5k views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply Nirmal Gaur commented Sep 29, 2017 reply Follow Share 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 votes 1 votes vg653 commented Mar 28, 2020 reply Follow Share O(1) 1 votes 1 votes Please log in or register to add a comment.
1 votes 1 votes 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 See all 1 1 comment reply Kaluti commented Oct 1, 2017 reply Follow Share 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 votes 0 votes Please log in or register to add a comment.
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. AkashChandraGupta answered Aug 6, 2020 AkashChandraGupta comment Share Follow See all 0 reply Please log in or register to add a comment.