Peek - Get the value of the front of the queue without removing it.Dequeue - Removing element from the front of the queue.Enqueue - Appending elements at the end of the queue.In browsers, the back button to keep track of all urls visited earlier.Time Complexity: For the array-based implementation of a stack, the push and pop operations take constant time, i.e. Stack Implementation class stack: def _init_(self): self.stack = def push(self, element): return (element) def pop(self): return () def isEmpty(self): return len(self.stack) = 0 def peek(self): if len(self.stack) != 0: return self.stack else: return "Stack is Empty" """ create_stack = stack() create_stack.push(5) create_stack.push(2) create_stack.push(3) create_stack.push(4) print(create_stack.stack) `` create_stack.pop() `4` create_stack.peek() `3` create_stack.pop() create_stack.pop() create_stack.pop() create_stack.isEmpty() `True` create_stack.peek() 'Stack is Empty' """ peek - Finding the top element from stack.isEmpty - Check if stack is empty or not.Pop - Removing the top element from stack.Push - Adding element at the top of the stack.Figure 2: Stack Basic operations in Stack
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |