1 / 21

第九次作业

第九次作业. 7.17 试在十字链表存储结构上实现图的基本操作: - InsertVex ( G,v ) , InsertArc ( G,v,w ), - DeleteVex ( G,v ), DeleteArc ( G,v,w ). 十字链表存储结构. 1.InsertVex( G,v ). 2.InsertArc( G,v,w ). 3.DeleteVex( G,v ). 4.DeleteArc( G,v,w ). 7.31 试完成求有向图的强连通分量的算法,并分析算法的时间复杂度。

Télécharger la présentation

第九次作业

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第九次作业

  2. 7.17 试在十字链表存储结构上实现图的基本操作: -InsertVex(G,v) ,InsertArc(G,v,w), -DeleteVex(G,v),DeleteArc(G,v,w)

  3. 十字链表存储结构

  4. 1.InsertVex(G,v)

  5. 2.InsertArc(G,v,w)

  6. 3.DeleteVex(G,v)

  7. 4.DeleteArc(G,v,w)

  8. 7.31 试完成求有向图的强连通分量的算法,并分析算法的时间复杂度。 • -在有向图中,如果对于每一对顶点相互可达,则称该图为强连通图;否则,将其中的极大强连通子图称为强连通分量。

  9. 算法思想: • 从某个顶点出发,进行深度优先搜索遍历,并退出DFS函数的顺序对顶点进行排序 • 从最后完成搜索的顶点出发,进行逆向的深度优先搜索,每次搜索得到的顶点集就是一个强连通分量

  10. DFS1:从V1开始 finished : (V2,V4,V3,V1) 2. 从V1开始DFS2: 输出:{V1,V3,V4} ,{V2} V1 V2 V4 V3 时间复杂度: 算法主要执行了两次深度优先遍历,所以T = O(n+e)

  11. 9.3 画出对长度为10的有序表进行折半查找的判定树,并求其等概率时查找成功的平均查找长度

  12. Mid = 5 2 8 9 3 6 1 4 7 10 ASL = (1+2*2+3*4+4*3)/10 =2.9

  13. 9.26 试将折半查找算法改写成递归算法

  14. 9.31试写一个判断给定二叉树是否为二叉排序树的算法,以二叉链表作为存储结构。且树中节点关键字均不同9.31试写一个判断给定二叉树是否为二叉排序树的算法,以二叉链表作为存储结构。且树中节点关键字均不同

  15. 9.33编写递归算法,从大到小输出给定二叉排序树中所以关键字不小于x的数据元素。9.33编写递归算法,从大到小输出给定二叉排序树中所以关键字不小于x的数据元素。

More Related