#include #include /* stack functions */ struct stack{ int *s; int top; }; struct stack* init(int n){ struct stack *st; st = (struct stack *)malloc(sizeof(struct stack)); st->s = (int *)malloc(n*sizeof(int)); st->top = -1; return st; } void push(struct stack *st, int w){ (st->top)+=1; st->s[st->top] = w; } int isempty(struct stack *st){ if (st->top == -1) return 1; return 0; } int pop(struct stack *st){ (st->top)--; return st->s[(st->top)+1]; } /* end of stack functions */ int algo1(int T[], int n){ int j; int x,y,z; int i_x,i_y,i_z; for(x=1; x<=n-2; x++){ for(y=x+1; y<=n-1; y++){ for(z=y+1; z<=n; z++){ for(j=0; j T[i] && p == -1) p=T[j]; if(T[j] > T[i] && T[j] < p) return 0; } } return 1; } int algo4(int T[], int n){ struct stack *st; st = init(n); int i, m = n; for (i=0; is[st->top] != T[i]) return 0; pop(st); } return 1; } int main(){ int *T, n, i; printf("\nn = "); scanf("%d", &n); printf("\nSequence: "); T = (int*)malloc(n*sizeof(int)); for(i=0; i