views:

117

answers:

2

I want to model a purification of the Petri Network. And i was given the suggestion to use a matrix which is allocated dynamically. After thinking about the problem i came up with a different approach like so:

A static matrix of n transitions and p locations and a function which returns the purified matrix from the static matrix.

Which approach is the safest and the best? The static implementation or the dynamical one?

+1  A: 

A dynamically allocated matrix is better:

  • can be resized to suit the input dimensions
  • you pay only for what you need

though you have the burden of managing the memory all by yourself.

dirkgently
+1  A: 

In terms of safety, the static implementation is much less likely to leak memory. The dynamic one is more flexible though. If you're thinking about this issue, it's probably best to just go with the dynamic solution.

CookieOfFortune