Posts

Showing posts with the label Stack

Evaluating the reverse polish notation

Problem Given the list of strings consisting of the asthmatic equation expressed in the Reverse Polish notation. Write the program that evaluates the equation and returns the result. Example:     For { "4" , "1" , "+" , "2.5" , "*" }, output =12.5     { "5" ,  "80" , "40" , "/" , "+" } = 7

Evaluating the mathematic expression without parentheses

Problem Given the arithmetic expression, $2+3+3-4*2+12/3$, your algorithm should return the result of the calculation.

Finding the common ancestor in the tree - Part 2 [reviewed]

Image
Problem You are given a Binary Tree (not BST) along with two pointers to nodes somewhere in the tree. Your algorithm should returns the pointer to the common parent to given nodes. For example, in the following tree Figure 1. Binary Search Tree example The common ancestor of "d" and "f" is "a".