Two recursive calls in a Merge Sort function confusion

前端 未结 9 1644
情书的邮戳
情书的邮戳 2021-02-19 13:37

I have been out of touch with Algorithms for a while and have start revising my concepts these days. To my surprise the last i remember of my recursions skill was that i was goo

9条回答
  •  终归单人心
    2021-02-19 13:40

    Run this piece of code to understand recursion well.I have considered the stack depth in the console.Hope it makes it easy to understand!

        #include "stdafx.h"
        #include 
        using namespace std;
        static int stackdepth=0;
        void mergesort(int[],int,int);
        void merge(int[],int,int,int);
        void  space(int);
        int main(int argc,char *argv[])
        {
            int a[8]={5,7,1,4,9,3,2,0};
            mergesort(a,0,7);
            for(int i=0;i<10;i++)
        //  cout<

提交回复
热议问题