diff --git a/Data Structures/Queue/c++/Queue Using LL.txt b/Data Structures/Queue/c++/Queue Using LL.txt new file mode 100644 index 00000000..fefd72bf --- /dev/null +++ b/Data Structures/Queue/c++/Queue Using LL.txt @@ -0,0 +1,63 @@ +#include +using namespace std; + + +template +class Node { + public : + T data; + Node *next; + + Node(T data) { + this -> data = data; + next = NULL; + } +}; + +#include "Queue.h" +int main() { + + Queue q; + + int choice; + cin >> choice; + int input; + + while (choice !=-1) { + if(choice == 1) { + cin >> input; + q.enqueue(input); + } + else if(choice == 2) { + int ans = q.dequeue(); + if(ans != 0) { + cout << ans << endl; + } + else { + cout << "-1" << endl; + } + } + else if(choice == 3) { + int ans = q.front(); + if(ans != 0) { + cout << ans << endl; + } + else { + cout << "-1" << endl; + } + } + else if(choice == 4) { + cout << q.getSize() << endl; + } + else if(choice == 5) { + if(q.isEmpty()) { + cout << "true" << endl; + } + else { + cout << "false" << endl; + } + } + cin >> choice; + } + +}