![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
HiCoderMan
热爱移动开发~正在深入~
展开
-
Java PriorityBlockingQueue 分析
在练习下载模块时需要对下载任务设置优先级原创 2014-11-11 10:24:47 · 1974 阅读 · 0 评论 -
单向链表中间结点
Node *middle(Node *head){ if (head==NULL||head->next==NULL) { return head; } Node *p=head; Node *q=p; while (p!=NULL&&p->next!=NULL) { q=q->next; p=p->next->next; } return q;}原创 2014-10-11 15:18:35 · 484 阅读 · 0 评论 -
编程实现栈的入栈/出栈操作
a原创 2014-10-13 08:09:58 · 1147 阅读 · 0 评论 -
用C++实现用两个栈实现一个队列的功能
#include "stdafx.h"#include "stdlib.h"#include using namespace std;template struct Queue{ stack s1; stack s2; bool empty(){ return s1.empty()&&s2.empty(); } T enqueue(T &obj){ s1.push(原创 2014-10-14 09:13:02 · 1349 阅读 · 0 评论 -
代码实现判断两棵树是否相等
//两棵树是否相等bool compare(const Node *root1,const Node *root2){ if (root1==NULL&&root2==NULL) { return true; } else if(root1==NULL||root2==NULL) { return false; } if (root1->data!=root2->data原创 2014-10-14 14:04:00 · 4912 阅读 · 0 评论 -
把二叉树打印成多行
需要用两个变量来记录下一层有多少个结点需要打印以及本次还有多少个结点未打印。原创 2014-10-14 14:14:56 · 1444 阅读 · 0 评论 -
二叉树的下一个结点
//找出二叉树中序遍历的某个结点的下一个结点Node *GetNext(Node *pNode){ if (pNode==NULL) { return NULL; } //1.有右子树 if (pNode->right!=NULL) { //右子树中最左边结点 Node *p=pNode->right; while (p->left!=NULL) { p=原创 2014-10-14 15:13:18 · 961 阅读 · 0 评论 -
按之字形顺序打印二叉树
使用两个栈。原创 2014-10-14 15:38:49 · 1520 阅读 · 2 评论 -
判断一棵树是否对称
使用前根遍历和前根对称遍历,即根左右和根右左,然后判断原创 2014-10-14 14:12:40 · 1669 阅读 · 0 评论 -
滑动窗口的最大值
#include #include using namespace std;vector maxInWindow(const vector& num,int size){ vector maxInWindow; if (num.size()>=size&&size>=1) { deque index; for (int i = 0; i < size; i++) {原创 2014-10-14 17:55:13 · 1228 阅读 · 0 评论 -
复制双向链表
工原创 2014-10-10 13:32:13 · 1972 阅读 · 0 评论 -
编程实现单链表的逆置
void reverse(Node **head){ if (head==NULL) { return; } Node *p=*head; Node *q=NULL; Node *pre=NULL; while (p!=NULL) { pre=q; q=p; p=p->next; //修改为指向前 q->next=pre; } *head=q;}原创 2014-10-11 15:09:44 · 1122 阅读 · 0 评论 -
递归创建链表
Node *create(){ int input=0; scanf("%d",&input); if (input!=-1) { Node *node=new Node(); node->v=input; node->nxt=create(); return node; } return NULL;}原创 2014-10-18 10:25:48 · 2140 阅读 · 0 评论 -
链表是否有环
Node * isLoop(Node *head){ if (head==NULL||head->nxt==head) { return head; } Node *p=head; Node *q=head; while (p!=NULL&&p->nxt!=NULL) { p=p->nxt->nxt; q=q->nxt; if (p==q) { return原创 2014-10-18 11:30:24 · 506 阅读 · 0 评论 -
Android Glide GifDrawable 模块源码解析
背景项目有个需求:对GIF动图实时添加文字。结合之前FollowMe景区导游助手项目中做过图片添加水印,MovieMaker项目中多张图片合成一段具有多种切换效果视频的经验,预测需要对GIF文件的数据进行解码,合成处理,编码输出合成文件。 项目基于Glide库实现GIF图片的显示,因此需要搞清楚GIF文件的数据是怎么显示到ImageView模块。本文记录分析GifDrawable模块的原理的过程原创 2017-01-09 00:31:44 · 4153 阅读 · 2 评论 -
编程实现队列的入队/出队操作
// DataStructure.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"typedef struct Student{ int data; Student *next;}Node;typedef struct{ Node *head; Node *tail;}Queue;Queue * create(int *data,原创 2014-10-12 15:27:04 · 952 阅读 · 0 评论 -
编程实现单链表的排序
Node *sort(Node *head){ if (head==NULL||head->next==NULL) { return head; } Node *p=head; //选择排序 while (p!=NULL) { Node *q=p->next; while (q!=NULL) { //找出最小的数 if (q->datadata)原创 2014-10-11 14:55:22 · 1382 阅读 · 0 评论 -
字符串最长回文串
工原创 2014-10-10 13:32:43 · 440 阅读 · 0 评论 -
N个骰子的点数
把n个骰子扔在地上,所有骰子朝上原创 2014-10-09 17:14:10 · 427 阅读 · 0 评论 -
和为s的连续正数序列
private static void findContinuousSequence(int sum) { if (sum < 3) { return; } int front = 1; int back = 2; int middle = (1 + sum) >> 1; int currentSum = front + back; while (fron原创 2014-10-09 15:20:42 · 441 阅读 · 0 评论 -
交换两个变量的值
int a=3,b=4; // int temp=a; // a=b; // b=temp; // b=a+b; // a=b-a; // b=b-a; a=a^b; b=a^b; a=a^b;原创 2014-10-09 14:44:03 · 468 阅读 · 0 评论 -
数组中只出现一次的数字
package com.google.android;public class NumsAppearOnce { public static void main(String[] args) { // 仅有两个数字只出现了一次,其他都出现两次 int[] data = { 2, 4, 3, 6, 3, 2, 5, 5 }; int[] result = new int[2];原创 2014-10-09 12:52:29 · 484 阅读 · 0 评论 -
判断二叉树是不是平衡二叉树
需要重复遍历结点的算法 private static boolean isBalanced(Tree root) { if (root == null) { return false; } int left = getDepth(root.left); int right = getDepth(root.right); int diff = Math.abs(lef原创 2014-10-09 10:40:00 · 405 阅读 · 0 评论 -
二分查找算法的递归与非递归实现
工原创 2014-10-09 09:51:46 · 443 阅读 · 0 评论 -
数字在排序数组中出现的次数
统计一个数字在排序数组中出现的次数。例如输入排序原创 2014-10-09 09:48:18 · 396 阅读 · 0 评论 -
数组中的逆序对
工原创 2014-10-06 22:16:20 · 460 阅读 · 0 评论 -
把数组排成最小的数
public static void main(String[] args) { int[] data={32,3,321,Integer.MAX_VALUE}; print(data); } private static void print(int[] data) { if (data==null) { return; } //用字符串来解决大数的问题原创 2014-10-06 22:02:23 · 492 阅读 · 0 评论 -
编程实现单链表的插入
Node *insert(Node **head,int index,int value){ Node *p=*head; //头结点之前插入 if (index<=0) { Node* node=new Node(); node->data=value; node->next=p; *head=node; } else { int i=0; Node *pr原创 2014-10-11 13:02:01 · 941 阅读 · 0 评论 -
约瑟夫环问题
// DataStructure.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"typedef struct Student{ int data; Student *next;}Node;void print(Node *head){ if (head==NULL) { return ; } Node *p=head; do原创 2014-10-11 17:33:48 · 427 阅读 · 0 评论 -
双向链表的创建/插入/删除
// DataStructure.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"typedef struct Teacher{ int data; Teacher * left; Teacher * right;}Node;Node * create(int* data,int length){ if (data==NULL||leng原创 2014-10-11 16:23:29 · 412 阅读 · 0 评论 -
编程实现一个单链表的建立/测长/打印
// DataStructure.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"typedef struct Student{ int data; Student * next;}Node;Node * create(int* data,int length){ if (data==NULL||length<=0) { return原创 2014-10-11 10:38:49 · 1864 阅读 · 0 评论 -
关于编程中Context的理解
前言在编程的过程中,经常看到别人的源码中使用Context。经过一段时间的实践,谈谈个人对其的理解。正文是什么Context 指做一件事情的背景/环境/上下文/所需要的必要的数据AppContext 应用上下文,包含整个App运行期间必要的数据UserContext 用户上下文,包含一个User的上下文数据一个经典的Context例子:在一个操作系统中,包含多个进程,每个进程包含多个线程原创 2017-03-05 23:11:41 · 9401 阅读 · 1 评论