快速排序(quick sort)
使用哈希表实现字典

BFS && DFS

Jimmy posted @ 2011年11月03日 04:40 in Algorithm Basics , 1879 阅读

最近听港大数据结构课,于是想动手实现一些最基本的算法。深度优先跟广度优先是最基本的遍历算法,实现的时候还是会有一些小的错误。

比如删除队列中的元素,出现段错误因为:

head -> next = head -> next -> next;

free(head -> next)

以及遍历链表时无法得到最后一个元素

while(tmp -> next != NULL)

都是一些细节没有处理好,以后写程序要注意了……

附上两个程序的图

BFS:

C语言程序可在GitHub下载:https://github.com/jia1546/BFS

DFS:

C语言程序可在GitHub下载:https://github.com/jia1546/DFS

 

Avatar_small
celebrity heights 说:
2021年3月08日 20:45

Have you ever wonder about any celeb height wiki in real life? You can find all the information you need on this website.

Avatar_small
civaget 说:
2024年1月11日 04:17

acer laptops have much brighter lcd screens compared to other brands* how to make my google docs dark mode


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter