
数据结构
文章平均质量分 59
nova0831
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【数据结构】链表
昨天学了链表的一些基本操作,今天记录下来进行复习巩固首先是链表结构的声明,链表包含表元素以及指向该元素后继元的指针/** * Created by novax_000 on 2016/4/5. */public class ListNode { //单链表结构,元素值value,指向后继元的指针next public T value; public ListN原创 2016-04-06 13:33:53 · 227 阅读 · 0 评论 -
【leetcode】235. Lowest Common Ancestor of a Binary Search Tree
题目要求:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is def原创 2016-05-06 13:51:56 · 209 阅读 · 0 评论 -
【leetcode】141. Linked List Cycle
题目要求:Given a linked list, determine if it has a cycle in it.即给定一个链表,判断是否有环的存在思路:定义一个快指针,一个慢指针,若两个指针相遇,则说明有环存在/** * Definition for singly-linked list. * class ListNode { * int va原创 2016-05-04 20:28:41 · 258 阅读 · 0 评论 -
【leetcode】100. Same Tree
题目要求:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.即原创 2016-05-04 19:57:15 · 227 阅读 · 0 评论 -
【数据结构】二叉树相关操作
1、二叉树的层次遍历 //二叉树的层次遍历 //利用队列 public void FloorVisit(BinaryTree root) { Queue queue = new LinkedList(); if(root==null) { return; } Bina原创 2016-05-02 21:51:45 · 415 阅读 · 0 评论 -
【leetcode】102. Binary Tree Level Order Traversal
题目要求:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \原创 2016-05-03 20:39:18 · 325 阅读 · 0 评论 -
【数据结构】将有序数组转为二叉搜索树
//将有序数组转化为二叉搜索树 //二叉搜索树:每一个节点的值大于左孩子的值,小于右孩子的值,如果采用中序遍历,输出结果为从小到大的 public BinaryTree arrayToBST(T array[],int start,int end) { if(start>end) { return null;原创 2016-05-03 15:22:41 · 535 阅读 · 0 评论 -
【leetcode】226. Invert Binary Tree
题目要求:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1即将一颗二叉树进行左右翻转思路:递归的将左子树和右子树进行对调/** * Definition for a bin原创 2016-05-02 21:49:21 · 248 阅读 · 0 评论 -
【leetcode】104. Maximum Depth of Binary Tree
题目要求:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.即给定一个二叉树,求它的最大深度思路:递归原创 2016-05-02 18:12:09 · 234 阅读 · 0 评论 -
【数据结构】二叉树遍历
二叉树结构/** * Created by novax_000 on 2016/5/1. */public class BinaryTree { public T value; public BinaryTree left; public BinaryTree right; public BinaryTree(T value, BinaryTree le原创 2016-05-01 19:07:22 · 250 阅读 · 0 评论 -
【leetcode】155. Min Stack
题目要求:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top(原创 2016-04-16 22:46:57 · 348 阅读 · 0 评论 -
【leetcode】225. Implement Stack using Queues
题目要求:Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.empty() -- Re原创 2016-04-14 22:12:10 · 301 阅读 · 0 评论 -
【leetcode】232. Implement Queue using Stacks
题目要求:Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the front eleme原创 2016-04-14 22:01:41 · 283 阅读 · 0 评论 -
【leetcode】206. Reverse Linked List
题目要求:Reverse a singly linked list.即反转一个单向链表/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */p原创 2016-04-14 21:54:22 · 263 阅读 · 0 评论 -
【leetcode】237. Delete Node in a Linked List
题目要求:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node w原创 2016-04-14 21:58:25 · 209 阅读 · 0 评论 -
【数据结构】栈与队列
今日学习总结:自己创建一个栈/** * Created by novax_000 on 2016/4/11. */public class MiniStack { private int size; private Object[] array = new Object[4]; public boolean isEmpty() {原创 2016-04-13 23:00:49 · 286 阅读 · 0 评论 -
【剑指offer】二叉搜索树与双向链表
题目描述输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表。要求不能创建任何新的结点,只能调整树中结点指针的指向。/**public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int va原创 2017-03-02 13:58:54 · 248 阅读 · 0 评论