摘要: 1)递归 int GetHeight(link root) { if(NULL== root) return false; int left_count = GetHeight(root->ls)+1; int right_count = GetHeight(root->rs)+1; return left_count > right_count ... 阅读全文
posted @ 2019-10-30 20:13 __MEET 阅读(2009) 评论(0) 推荐(1) 编辑
摘要: /* 判断单链表是否存在环 1)暴力:双层循环遍历(n^2) 2)双指针:快指针fast=NULL,慢指针slow=NULL int judge(link head) { if(NULL==head) return false; link fast = head, slow = head; while(slow!=NULL && fast!=NULL) { slow = slow->next; f 阅读全文
posted @ 2019-10-30 19:47 __MEET 阅读(127) 评论(0) 推荐(0) 编辑