流程图 - 递归

问题描述

我想为递归函数创建流程图。但问题是有两行代码调用函数并导致递归。 在代码中它可能看起来很简单

function(array):
  if (base case) do: // base case check
     return
  if (array.length > 1) do:
     function(array= elements from 1 to array.length/2) // first call 
     function(array= elements from array.length/2 to array.length) // second call

但我不知道如何在流程图中显示 我想过做这样的事情:

enter image description here

它看起来没有调用顺序,一般我不知道如果 array.length 检查(第二个检查)是假的,我不知道要显示什么

顺便说一下,我使用的是 https://app.diagrams.net/

解决方法

您可以使用堆栈来表示流程图中的执行:

enter image description here

我在此处回答了类似问题并提供了更多详细信息:https://stackoverflow.com/a/68241088/1927695