Which notation can be used for expressing how many times that function or subroutine called during a run of a program?

Example program pseudocode:

$ a \gets 0 \\ \textbf{While } a \neq 5 \textbf{ do} \\ \quad \textit{function1()} \\ \quad a \gets a + 1 \\ \textbf{end} $

$g: functions \rightarrow \mathbb{N}$ and for this example it is: $g(function1()) = 5$

I want to use it for expressing empirical observations depending on function call count.

Most of the time less than |iterSearch(searchState)|/3 child node searched during experiments. 

What are the possible notations for function $g$ ?

  • 2
    $\begingroup$ Welcome to CS.SE! I don't understand what you are asking. What does $g$ represent? Why do you write "g(function1())=5"? Where did that come from? What do you mean "it will give that"? What do you mean by "the right notation"? I'm not sure what kind of answer you are looking for. $\endgroup$ – D.W. Mar 7 '18 at 20:27
  • $\begingroup$ Sorry, if I couldn't express myself. I want to know is there a notation like $|function()|$ for any function to give how many times that function called for a run of a program. $\endgroup$ – user85403 Mar 7 '18 at 20:39
  • 3
    $\begingroup$ @de6f I don't think any well known notation exists, so feel free to come up with your own. If you'd like suggestions for the notation, I'll need more details. Why do you want some special notation for this? Is the function something you'll be using a lot? For what purpose? $\endgroup$ – Discrete lizard Mar 7 '18 at 22:40
  • $\begingroup$ Please edit the question based on the feedback you've received. Don't just leave explanations/clarifications in the comments -- edit the question so it is self-contained and reads well for someone who encounters it for the first time. We don't want people to have to read the comments to understand what you are asking. Thanks! $\endgroup$ – D.W. Mar 7 '18 at 22:53

Based on your desired usage and the fact that there likely isn't a widely-known notation for this, I think that, whatever notation your use, you should formally simply consider it a name. As you want to use the actual value, a variable (or function if you wish to distinguish among parameters for the call) would suffice.

What I mean by considering the notation a name is that you give your notation no syntactic status: it is simply a naming convention for some function or variable. This requires that you must define the name for each different method call number you wish to describe. I advise you to do this, as number of function calls is something that is context-dependent (calls by whom? calls made when?), so defining this for every function call separately gives a natural place to specify this.

So, for your particular example, a name like $\#\mathrm{function1}(\bullet)$ could work.

Then, we can write something like

Let $\#\mathrm{itersearch}(a)$ be the number of calls to the function $\mathrm{itersearch}()$ in the execution of algorithm A with parameter $a$.


Most of the time less than $\#\mathrm{iterSearch}(searchState)/3$ child nodes were searched during experiments.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy