上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 46 下一页

2014年11月9日

Binary Tree Level Order Traversal

摘要: Binary Tree Level Order TraversalGiven a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).Fo... 阅读全文

posted @ 2014-11-09 15:23 luckygxf 阅读(159) 评论(0) 推荐(0) 编辑

Binary Tree Level Order Traversal II

摘要: 这道题A的略烦Binary Tree Level Order Traversal IIGiven a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right... 阅读全文

posted @ 2014-11-09 14:19 luckygxf 阅读(161) 评论(0) 推荐(0) 编辑

图和图的遍历算法

摘要: 图和图的遍历算法1.存储结构(邻接链表)1.1每个顶点用VexNode类表示,每条边用ArcNode表示1.2所有顶点用数组VexNode adjlist[]表示,所有邻接顶点用链表表示2.遍历算法2.1深度优先遍历DFS用递归实现,从V0开始,访问V0即邻接顶点V1,访问V1及其邻接顶点...2.... 阅读全文

posted @ 2014-11-09 12:47 luckygxf 阅读(618) 评论(0) 推荐(0) 编辑

2014年11月8日

Remove Duplicates from Sorted List

摘要: Remove Duplicates from Sorted ListGiven a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, r... 阅读全文

posted @ 2014-11-08 23:38 luckygxf 阅读(124) 评论(0) 推荐(0) 编辑

Binary Tree Preorder Traversal

摘要: Binary Tree Preorder TraversalGiven a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ ... 阅读全文

posted @ 2014-11-08 23:02 luckygxf 阅读(115) 评论(0) 推荐(0) 编辑

Merge Sorted Array

摘要: Merge Sorted ArrayGiven two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that i... 阅读全文

posted @ 2014-11-08 15:53 luckygxf 阅读(166) 评论(0) 推荐(0) 编辑

2014年11月7日

Same Tree

摘要: Same TreeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally ide... 阅读全文

posted @ 2014-11-07 23:44 luckygxf 阅读(136) 评论(0) 推荐(0) 编辑

归并排序

摘要: 归并排序1.将两个有序序列归并成一个有序序列2.将带排序数组,通过递归调整成左右两个有序序列,在调用归并算法,将其归并成一个有序序列,完成排序Merg.java 1 package com.gxf.merg; 2 3 /** 4 * 归并排序 5 * 初始状态,将数组看成n个单独有序的序列,两... 阅读全文

posted @ 2014-11-07 23:38 luckygxf 阅读(172) 评论(0) 推荐(0) 编辑

Maximum Depth of Binary Tree

摘要: Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root ... 阅读全文

posted @ 2014-11-07 00:09 luckygxf 阅读(117) 评论(0) 推荐(0) 编辑

2014年11月6日

堆排序

摘要: 堆排序堆排序是直接选择排序的一种改进算法,先将数组调整成一个堆,在将堆第一个元素最小元素和待排序区间最后一个元素交换。重新调整堆,重复执行n - 1次即可得到有序数组具体解释代码注释中有说明,注意完全二叉树的性质如i节点的左子树节点为2 * i是从1开始,不是从0开始。实现的时候需要注意一下1.创建... 阅读全文

posted @ 2014-11-06 23:57 luckygxf 阅读(254) 评论(0) 推荐(0) 编辑

上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 46 下一页

导航