Pertemuan ke - 3 13-03-2018 Stack is an important data structure which stores its elements in an ordered manner. Simplest logic is Last In First Out (LIFO) way. The elements in a stack are added and removed only from one end, which is called the top. In a linked stack, every node has two parts: – One that stores data – One that stores the address of the next node Stack Operations push(x) : add an item x to the top of the stack. pop() : remove an item from the top of the stack. top() : reveal/return the top item from the stack. //top is also known as peek Infix, Postfix , and Prefix Notation Prefix Infix Postfix * 4 10 4 * 10 4 10 * + 5 * 3 4 5 + 3 * 4 5 3 4 * + + 4 / * 6 – 5 2 3 4 + 6 * (5 – 2) / 3 4 6 5 2 – * 3 / + Prefix: Operator, Left Operand , Right Operand (OLR) Infix : Left Operand , Opera...
Komentar
Posting Komentar