Team QueueQueues and Priority Queues are data structures which are known to most computer scientists. The Team Queue, however, is not so well known, ....
分类:
其他好文 时间:
2014-08-10 18:13:30
阅读次数:
328
Describe how you could use a single array to implement three stacks.思路1:fixed divisionpackage Question3_1;import java.util.EmptyStackException;public ...
分类:
其他好文 时间:
2014-08-09 22:59:29
阅读次数:
401
解题报告
题意:
看输入输出就很明白。
思路:
优先队列。
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
struct node {
char m[100];
int v,k;
friend bool ope...
1.1 Implement an algorithm to determine if a string has all unique characters. Whatif you cannot use additional data structures? 1 #include 2 #includ....
分类:
其他好文 时间:
2014-08-09 18:17:58
阅读次数:
199
想必大家都很熟悉生产者-消费者队列,生产者负责添加元素到队列,如果队列已满则会进入阻塞状态直到有消费者拿走元素。相反,消费者负责从队列中拿走元素,如果队列为空则会进入阻塞状态直到有生产者添加元素到队列。BlockingQueue就是这么一个生产者-消费者队列。BlockingQueue是Queue的...
分类:
编程语言 时间:
2014-08-09 18:09:28
阅读次数:
255
题意:不解释。
策略:如题;
这道题可以用深搜也可以用广搜,我以前写的是用的深搜,最近在学广搜,就拿这道题来练练手。
代码:
#include
#include
#include
using std::queue;
bool vis[20][20];
const int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};//四个方向
int map[9][9]...
分类:
其他好文 时间:
2014-08-09 11:38:27
阅读次数:
155
这是做的第一道BFS,很基础很简单的题目广度优先搜索算法如下:(用QUEUE)(1) 把初始节点S0放入Open表中;(2) 如果Open表为空,则问题无解,失败退出;(3) 把Open表的第一个节点取出放入Closed表,并记该节点为n;(4) 考察节点n是否为目标节点。若是,则得到问题的解,成功...
分类:
其他好文 时间:
2014-08-09 02:32:26
阅读次数:
307
集合是编程中最常用的数据结构。而谈到并发,几乎总是离不开集合这类高级数据结构的支持。比如两个线程需要同时访问一个中间临界区(Queue),比如常会用缓存作为外部文件的副本(HashMap)。这篇文章主要分析jdk1.5的3种并发集合类型(concurrent,copyonright,queue)中的ConcurrentHashMap,让我们从原理上细致的了解它们,能够让我们在深度项目开发中获益非浅...
分类:
其他好文 时间:
2014-08-08 16:16:26
阅读次数:
244
图有四种存储结构:数组,邻接表,十字链表,邻接多重表。下面以数组为存储结构来实现图的深度优先搜索遍历和广度优先搜索遍历。其中广度优先搜索遍历中有用到STL中的queue,注意头文件的包含。具体代码如下:
//图的数组(邻接矩阵)存储表示和深度优先遍历
const int MAX_VERTEX_NUM=20; //最大顶点数
typedef enum {DG,DN,UDG,UDN} Graph...
分类:
其他好文 时间:
2014-08-08 12:39:35
阅读次数:
224
今天的微博有人讨论到对象池,我想到之前项目的实现,应该用模板来实现啊,唉,还是被前人的想法给框定了,只是实现一个特别简单,花了几分钟写了个:const int DefaultPoolSize = 1024;template class CSSObejctPool{private: queue m_O...
分类:
编程语言 时间:
2014-08-08 11:58:15
阅读次数:
180