-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
82 lines (71 loc) · 2.27 KB
/
index.js
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
const SLinkedList = require("./Linear Data Structures/LinkedList/singly_linked_list");
const DLinkedList = require("./Linear Data Structures/LinkedList/doubly_linked_list");
const Stack = require("./Linear Data Structures/LinkedList/stack");
const Queue = require("./Linear Data Structures/LinkedList/queue");
const QueueWithTwoStacks = require("./Linear Data Structures/Queues/queues_with_two_stacks");
const QueuesWithArrays = require("./Linear Data Structures/Queues/queues_with_array");
const CircularArray = require("./Linear Data Structures/Arrays/circular_arrays");
sLinkedList = new SLinkedList();
sLinkedList.push(10);
sLinkedList.push(20);
sLinkedList.push(30);
sLinkedList.removeItem(1);
console.log(sLinkedList.getItem(1));
console.log(sLinkedList.toArray());
console.log(sLinkedList);
// dLinkedList = new DLinkedList()
// dLinkedList.push(10)
// dLinkedList.push(40)
// dLinkedList.push(30)
// dLinkedList.push(40)
// dLinkedList.push(90)
// console.log(dLinkedList.first)
// console.log(dLinkedList.lastIndexOf(40))
// console.log(dLinkedList.toArray())
// myStack = new Stack()
// myStack.push(1)
// myStack.push(2)
// myStack.push(3)
// console.log(myStack.peek())
// console.log(myStack.show())
// console.log(myStack.toArray())
// console.log(myStack.reverse())
// myQueue = new Queue()
// myQueue.enqueue({name: "ama", age: 21})
// myQueue.enqueue({name: "yaw", age: 26})
// myQueue.enqueue({name: "yaa", age: 16})
// myQueue.enqueue({name: "Kofi", age: 18})
// myQueue.dequeue()
// console.log(myQueue.peek())
// myQueue.reverse()
// console.log(myQueue.peek())
// console.log(myQueue.show())
// console.log(myQueue.toArray())
// queue = new QueueWithTwoStacks()
// queue.enqueue(2);
// queue.enqueue(3);
// queue.enqueue(5);
// queue.enqueue(6);
// queue.enqueue(9);
// console.log(queue)
// console.log(queue.dequeue())
// console.log(queue)
// queueArrays = new QueuesWithArrays(5)
// queueArrays.enqueue(1)
// queueArrays.enqueue(2)
// queueArrays.enqueue(3)
// queueArrays.enqueue(4)
// queueArrays.enqueue(5)
// queueArrays.dequeue()
// queueArrays.dequeue()
// console.log(queueArrays)
// cArray = new CircularArray(5)
// cArray.push(1)
// cArray.push(2)
// cArray.push(3)
// cArray.push(4)
// cArray.push(5)
// cArray.pop()
// cArray.pop()
// cArray.pop()
// console.log(cArray);