Skip to content
This repository was archived by the owner on Oct 2, 2020. It is now read-only.

Queue Using LL #406

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions Data Structures/Queue/c++/Queue Using LL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include<iostream>
using namespace std;


template <typename T>
class Node {
public :
T data;
Node<T> *next;

Node(T data) {
this -> data = data;
next = NULL;
}
};

#include "Queue.h"
int main() {

Queue<int> 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;
}

}