-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.c
More file actions
84 lines (56 loc) · 1.32 KB
/
Copy pathstack.c
File metadata and controls
84 lines (56 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include<stdio.h>
#include<stdlib.h>
#include "DLL.h"
#define true 1
#define false 0
typedef struct Stack {
DLL* elements;
} Stack;
/*
In this function, you have to allocate space for stack using malloc function.
Then you have to initialize the elements DLL using the function createDLL() defined in DLL.h
Then you have to return the newly allocated and initialized stack.
*/
Stack* createStack() {
}
/*
Use the appropriate function from the DLL.h file and perform the push operation on stack.
*/
void push(Stack* stack,int data) {
}
/*
Use the appropriate function from the DLL.h file and perform the pop operation on stack.
*/
void pop(Stack* stack) {
}
/*
Return true if stack is empty, else return false.
*/
int isEmpty(Stack* stack) {
}
/*
Get the top node of the stack.
*/
DLLNode* getTop(Stack* stack) {
}
/*
Free all the memory occupied by stack.
Hint: while the stack is not empty, keep on popping.
Then free stack.
*/
void deleteStack(Stack* stack) {
}
/*
You don't need to change this.
*/
int main() {
Stack* stack = createStack();
push(stack,4);
push(stack,3);
printf("The top element is = %d\n",getTop(stack)->data);
pop(stack);
printf("The top element is = %d\n",getTop(stack)->data);
pop(stack);
pop(stack);
return 0;
}