stack

PPTX 16 pages 64.2 KB Free download

Page preview (5 pages)

Scroll down 👇
1 / 16
stack stack algorithms and data structures course data structures: stack stack is a data structure in which: items can be inserted only from one end. items can be taken only from the same end. the last inserted item is the first item to be taken. last input first output [lifo]. example: stack of plates. algorithms and data structures course data structures: stack operations push: inserts item to the top of the stack. time complexity is o(1). pop: removes items from the top of stack. time complexity is o(1). top: returns top element of the stack. time complexity is o(1). empty: returns “true”, if stack is empty. time complexity is o(1). size: returns size of stack. time complexity is o(1). algorithms and data structures course data structures: stack example algorithms and data structures course data structures: stack example algorithms and data structures course push 2 2 data structures: stack example algorithms …
2 / 16
ced. for example: “[(])” is not balanced. data structures: stack problem: balanced parentheses algorithms and data structures course algorithm: declare a character stack s. now traverse the expression string exp. if the current character is a starting bracket (‘(’ or ‘{’ or ‘[’ or ‘ ’) then pop from stack and if the popped character is the matching starting bracket then fine else parenthesis are not balanced. after complete traversal, if there is some starting bracket left in stack then “not balanced”. data structures: stack problem: balanced parentheses algorithms and data structures course initially: stack = expression = pushing step 1, added opening bracket: stack = expression = pushing step 2, added opening bracket : stack = expression = checking step 3, removed opening bracket : stack = expression = pushing step 4, added opening bracket : stack = expression = checking step 5, removed opening bracket : stack = …
3 / 16
stack - Page 3
4 / 16
stack - Page 4
5 / 16
stack - Page 5

Want to read more?

Download all 16 pages for free via Telegram.

Download full file

About "stack"

stack stack algorithms and data structures course data structures: stack stack is a data structure in which: items can be inserted only from one end. items can be taken only from the same end. the last inserted item is the first item to be taken. last input first output [lifo]. example: stack of plates. algorithms and data structures course data structures: stack operations push: inserts item to the top of the stack. time complexity is o(1). pop: removes items from the top of stack. time complexity is o(1). top: returns top element of the stack. time complexity is o(1). empty: returns “true”, if stack is empty. time complexity is o(1). size: returns size of stack. time complexity is o(1). algorithms …

This file contains 16 pages in PPTX format (64.2 KB). To download "stack", click the Telegram button on the left.

Tags: stack PPTX 16 pages Free download Telegram