Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Structures and data algorithms / HomeworkExamPrep / main.cpp
diff options
context:
space:
mode:
1 files changed, 59 insertions, 0 deletions
-rw-r--r--Year 2/Structures and data algorithms/HomeworkExamPrep/main.cpp59
diff --git a/Year 2/Structures and data algorithms/HomeworkExamPrep/main.cpp b/Year 2/Structures and data algorithms/HomeworkExamPrep/main.cpp
new file mode 100644
index 0000000..060e94c
--- /dev/null
+++ b/Year 2/Structures and data algorithms/HomeworkExamPrep/main.cpp
@@ -0,0 +1,59 @@
+#include <iostream>
+
+// #include "Stack/Stack_Static.hpp"
+// #include "Stack/Stack_DynamicSeq.hpp"
+#include "Stack/Stack_Dynamic.hpp"
+
+// #include "Queue/Queue_Static.hpp"
+#include "Queue/Queue_Dynamic.hpp"
+
+#include "LinkedList.hpp"
+
+int main() {
+ // Stack
+ Stack<int> nums1;
+ nums1.push(1);
+ nums1.push(2);
+ nums1.push(3);
+ for (unsigned i = 0; i < 3; i++) {
+ std::cout << nums1.top() << ", ";
+ nums1.pop();
+ }
+ nums1.push(4);
+ std::cout << nums1.top() << std::endl;
+
+ // Queue
+ Queue<int> nums2;
+ nums2.push(1);
+ nums2.push(2);
+ nums2.push(3);
+ for (unsigned i = 0; i < 3; i++) {
+ std::cout << nums2.front() << ", ";
+ nums2.pop();
+ }
+ nums2.push(4);
+ std::cout << nums2.front() << std::endl;
+
+ // Linked List
+ LinkedList<int> nums3;
+ nums3.push_front(1);
+ nums3.push_back(3);
+ nums3.push_at(1, 2);
+ for (int& i : nums3)
+ std::cout << i << ", ";
+ std::cout << std::endl;
+
+ LinkedList<int> nums4;
+ nums4.push_back(1);
+ nums4.push_back(2);
+ nums4.push_back(3);
+ nums4.push_front(5);
+ nums4.push_back(5);
+ nums4.push_at(2, 5);
+ nums4.pop_at(2);
+ nums4.pop_front();
+ nums4.pop_back();
+ for (const int& i : nums4)
+ std::cout << i << ", ";
+ std::cout << std::endl;
+}