-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
57 lines (49 loc) · 1.28 KB
/
main.cpp
File metadata and controls
57 lines (49 loc) · 1.28 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
#include<iostream>
#include"AVLTree.h"
#include"DMem.h"
#include<fstream>
using namespace std;
int main(){
int method;
cout<<"Enter 3 for DoubleLinkedList type Dictionary"<<endl;
cout<<"Enter 2 for BSTree type Dictionary"<<endl;
cout<<"Enter 1 for AVLTree type dictionary"<<endl;
cin>>method;
ifstream infile;
infile.open("input.txt");
int n; //number of test cases
int count =0;
infile>>n;
while(n--){
int size;
infile>>size;
DMem *object = new DMem(size, method);
int t;
infile>>t;
while (t--){
count++;
string command;
infile>>command;
int arg;
infile>>arg;
int result = -5;
if(command == "Allocate"){
result = object->Allocate(arg);
}
if(command == "Free"){
result = object->Free(arg);
}
if(command == "Defragment"){
object->Defragment();
}
if(result!= -5){
cout<<result<<endl;
}
}
}
infile.close();
int t;
cout<<"Enter 0 to exit"<<endl;
cin>>t;
return 0;
}