哪个数据结构用于求解简单的数学方程 [英] Which Data Structure used to solve a simple math equation

查看:101
本文介绍了哪个数据结构用于求解简单的数学方程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当接受(10 + 5 * 15)和后续操作顺序的表达式时。

When taking in a expression like (10+5*15) and following orders of operations.

如何最好地解决这样的问题?什么样的数据结构最好?

How would one best solve a problem like this? What kind of data structure is best?

谢谢。

推荐答案

我会使用Dijkstra的调车场算法来创建 AST

I'd go with Dijkstra's Shunting yard algorithm to create the AST.

这篇关于哪个数据结构用于求解简单的数学方程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆