
Stack & Queue
Feynman1999
理论都是灰色的,而生活之树常青^_^
展开
-
栈的顺序存储结构操作及实现
栈的顺序存储结构操作及实现 /* 栈的顺序存储结构操作及实现 */ #include #define MAXSIZE 20 using namespace std; typedef int SElemType; //这里用int示例 //stack element type 栈中元素的数据类型 typedef struct //栈结构的定义 { SElemType data[MA原创 2017-03-21 20:56:07 · 1046 阅读 · 0 评论 -
17AHU排位赛3 F题 (多路归并求第k大和)
problem蕊蕊有n部喜欢的番剧,每部番剧里面有m个老婆,每个老婆都有一个颜值。现在蕊蕊想从每部番剧里挑出一个老婆,总共挑出n个老婆,组成后宫团,后宫团的颜值是里面n个老婆的颜值和。显然,蕊蕊一共可以组成m^n个后宫团,现在她想知道这m^n个后宫团中,颜值和第K大的总颜值是多少。若K>m^n,输出0。Input第一行三个整数n,m,k(1<=n<=1000,1<=m<=500,1<=k<=1000原创 2017-08-29 11:31:30 · 599 阅读 · 0 评论 -
TOJ 3515(堆\优先队列)
problemThere is a sequence of integers, we have two operations now1 add a: means add an integer a to the end of the sequence, forms a N+1 long sequence.2 mid : Output the current sequence’s middle numb原创 2017-08-11 00:14:44 · 408 阅读 · 0 评论 -
POJ 2823(单调队列)
Description An array of size n ≤ 106 is given to you. There is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the wi原创 2017-08-03 13:37:51 · 574 阅读 · 1 评论 -
队列的链式存储操作
typedef int QElemtype; typedef struct QNode { QElemtype data; struct QNode *next; }QNode,*QueuePtr; typedef struct { QueuePtr front,rear; }LinkQueue; //插入元素e为Q的新的队尾元素 Status EnQueue(LinkQueue *Q原创 2017-03-24 18:57:08 · 430 阅读 · 0 评论 -
循环队列的相关操作(顺序结构)
typedef int Elemtype typedef struct { Elemtype data[MAXSIZE]; int front; int rear; }SqQueue; Status InitQueue(SqQueue *Q) { Q->front=0; Q->rear=0; return OK; } int QueueLength(SqQueue Q) { re原创 2017-03-24 17:58:34 · 531 阅读 · 0 评论 -
栈(stack)的抽象数据类型及进栈出栈次序
栈的抽象数据类型 ADT 栈 (stack) Data 同线性表。元素具有相同的类型,相邻元素具有前驱和后继关系。 Operation InitStack(*s):初始化操作,建立一个空栈S. DestroyStack(*S):若栈存在,则销毁它 ClearStack(*S):将栈清空 StackE原创 2017-03-11 22:40:31 · 1146 阅读 · 0 评论 -
四则运算表达式求值(逆波兰法)
零、逆波兰表示法(后缀表达式) 为了更好的解决表达式的优先运算问题,波兰逻辑学家Jan Lukasiewicz 定义了一种后缀表示法,一般称作逆波兰(Reverse Polish Notation,RPN)表示法。 例如对表达式 “12+(7-3)*2+9/3”,如果要用后缀表示法应该是:“12 7 3 - 2 * + 9 3 / +”,这样的表达式称为后缀表达式,之所以叫做后缀,是因为所有的原创 2017-03-22 18:50:40 · 1260 阅读 · 0 评论 -
栈的链式存储结构操作及实现
栈的链式存储结构操作及实现 /* 栈的链式存储结构操作及实现 */ #include #include #include #include using namespace std; typedef int SElemType; //这里用int示例 typedef struct StackNode //节点的定义 { SElemType data; struct StackNod原创 2017-03-21 20:58:05 · 809 阅读 · 0 评论 -
优先队列简介
优先队列 STL中封装了优先队列(priority_queue)这种结构,它和普通队列的区别是:普通的队列是一种先进先出的数据结构,元素在队列尾部追加,从队列头删除。 而在优先队列中,元素被赋予优先级。当访问元素时,具有最高优先级的元素最先删除。优先队列具有最高级先出(first in,largest out)的行为特征。 相关定义及操作 类的定义 #include<a...原创 2017-08-10 17:36:41 · 440 阅读 · 0 评论