diff --git a/src/data-structures/graph/abstract-graph.ts b/src/data-structures/graph/abstract-graph.ts index 4a0931d..3b0be52 100644 --- a/src/data-structures/graph/abstract-graph.ts +++ b/src/data-structures/graph/abstract-graph.ts @@ -691,7 +691,7 @@ export abstract class AbstractGraph< if (vertexOrKey instanceof AbstractVertex) distMap.set(vertexOrKey, Infinity); } - const heap = new PriorityQueue<{ key: number; value: VO }>({ comparator: (a, b) => a.key - b.key }); + const heap = new PriorityQueue<{ key: number; value: VO }>([], { comparator: (a, b) => a.key - b.key }); heap.add({ key: 0, value: srcVertex }); distMap.set(srcVertex, 0); diff --git a/src/data-structures/heap/heap.ts b/src/data-structures/heap/heap.ts index 3e1eca2..55b52e3 100644 --- a/src/data-structures/heap/heap.ts +++ b/src/data-structures/heap/heap.ts @@ -6,13 +6,32 @@ */ import type { Comparator, DFSOrderPattern } from '../../types'; +import { HeapOptions } from "../../types"; export class Heap { - constructor(options: { comparator: Comparator; elements?: E[] }) { - this._comparator = options.comparator; - if (options.elements && options.elements.length > 0) { - this._elements = options.elements; - this.fix(); + options: HeapOptions; + + constructor(elements?: Iterable, options?: HeapOptions) { + const defaultComparator = (a: E, b: E) => { + if (!(typeof a === 'number' && typeof b === 'number')) { + throw new Error('The a, b params of compare function must be number'); + } else { + return a - b; + } + } + if (options) { + this.options = options + } else { + this.options = { + comparator: defaultComparator + } + } + + if (elements) { + for (const el of elements) { + this.push(el); + } + // this.fix(); } } @@ -22,12 +41,6 @@ export class Heap { return this._elements; } - protected _comparator: Comparator; - - get comparator(): Comparator { - return this._comparator; - } - /** * Get the size (number of elements) of the heap. */ @@ -46,10 +59,11 @@ export class Heap { /** * Static method that creates a binary heap from an array of elements and a comparison function. * @returns A new Heap instance. + * @param elements * @param options */ - static heapify(options: { elements: E[]; comparator: Comparator }): Heap { - return new Heap(options); + static heapify(elements: Iterable, options: { comparator: Comparator }): Heap { + return new Heap(elements, options); } /** @@ -283,7 +297,7 @@ export class Heap { * @returns A new Heap instance containing the same elements. */ clone(): Heap { - const clonedHeap = new Heap({ comparator: this.comparator }); + const clonedHeap = new Heap([], this.options); clonedHeap._elements = [...this.elements]; return clonedHeap; } @@ -340,7 +354,7 @@ export class Heap { } filter(predicate: (element: E, index: number, heap: Heap) => boolean): Heap { - const filteredHeap: Heap = new Heap({ comparator: this.comparator }); + const filteredHeap: Heap = new Heap([], this.options); let index = 0; for (const el of this) { if (predicate(el, index, this)) { @@ -353,7 +367,7 @@ export class Heap { map(callback: (element: E, index: number, heap: Heap) => T, comparator: Comparator): Heap { - const mappedHeap: Heap = new Heap({ comparator: comparator }); + const mappedHeap: Heap = new Heap([], { comparator: comparator }); let index = 0; for (const el of this) { mappedHeap.add(callback(el, index, this)); @@ -380,6 +394,15 @@ export class Heap { * Space Complexity: O(1) */ + print(): void { + console.log([...this]); + } + + /** + * Time Complexity: O(n) + * Space Complexity: O(1) + */ + /** * Time Complexity: O(log n) * Space Complexity: O(1) @@ -392,18 +415,13 @@ export class Heap { while (index > 0) { const parent = (index - 1) >> 1; const parentItem = this.elements[parent]; - if (this._comparator(parentItem, element) <= 0) break; + if (this.options.comparator(parentItem, element) <= 0) break; this.elements[index] = parentItem; index = parent; } this.elements[index] = element; } - /** - * Time Complexity: O(n) - * Space Complexity: O(1) - */ - /** * Time Complexity: O(log n) * Space Complexity: O(1) @@ -420,12 +438,12 @@ export class Heap { let minItem = this.elements[left]; if ( right < this.elements.length && - this._comparator(minItem, this.elements[right]) > 0 + this.options.comparator(minItem, this.elements[right]) > 0 ) { left = right; minItem = this.elements[right]; } - if (this._comparator(minItem, element) >= 0) break; + if (this.options.comparator(minItem, element) >= 0) break; this.elements[index] = minItem; index = left; } @@ -452,7 +470,7 @@ export class FibonacciHeapNode { export class FibonacciHeap { constructor(comparator?: Comparator) { this.clear(); - this._comparator = comparator || this.defaultComparator; + this._comparator = comparator || this._defaultComparator; if (typeof this.comparator !== 'function') { throw new Error('FibonacciHeap constructor: given comparator should be a function.'); @@ -653,7 +671,7 @@ export class FibonacciHeap { this._root = undefined; } else { this._min = z.right; - this.consolidate(); + this._consolidate(); } this._size--; @@ -705,27 +723,27 @@ export class FibonacciHeap { heapToMerge.clear(); } + /** + * Create a new node. + * @param element + * @protected + */ + createNode(element: E): FibonacciHeapNode { + return new FibonacciHeapNode(element); + } + /** * Default comparator function used by the heap. * @param {E} a * @param {E} b * @protected */ - protected defaultComparator(a: E, b: E): number { + protected _defaultComparator(a: E, b: E): number { if (a < b) return -1; if (a > b) return 1; return 0; } - /** - * Create a new node. - * @param element - * @protected - */ - protected createNode(element: E): FibonacciHeapNode { - return new FibonacciHeapNode(element); - } - /** * Time Complexity: O(1) * Space Complexity: O(1) @@ -782,7 +800,7 @@ export class FibonacciHeap { * @param x * @protected */ - protected link(y: FibonacciHeapNode, x: FibonacciHeapNode): void { + protected _link(y: FibonacciHeapNode, x: FibonacciHeapNode): void { this.removeFromRoot(y); y.left = y; y.right = y; @@ -803,7 +821,7 @@ export class FibonacciHeap { * Remove and return the top element (smallest or largest element) from the heap. * @protected */ - protected consolidate(): void { + protected _consolidate(): void { const A: (FibonacciHeapNode | undefined)[] = new Array(this.size); const elements = this.consumeLinkedList(this.root); let x: FibonacciHeapNode | undefined, @@ -824,7 +842,7 @@ export class FibonacciHeap { y = t; } - this.link(y, x); + this._link(y, x); A[d] = undefined; d++; } diff --git a/src/data-structures/heap/max-heap.ts b/src/data-structures/heap/max-heap.ts index 9b90701..a0462ea 100644 --- a/src/data-structures/heap/max-heap.ts +++ b/src/data-structures/heap/max-heap.ts @@ -7,11 +7,12 @@ */ import { Heap } from './heap'; -import type { Comparator } from '../../types'; +import type { HeapOptions } from '../../types'; export class MaxHeap extends Heap { constructor( - options: { comparator: Comparator; nodes?: E[] } = { + elements?: Iterable, + options: HeapOptions = { comparator: (a: E, b: E) => { if (!(typeof a === 'number' && typeof b === 'number')) { throw new Error('The a, b params of compare function must be number'); @@ -19,8 +20,7 @@ export class MaxHeap extends Heap { return b - a; } } - } - ) { - super(options); + }) { + super(elements, options); } } diff --git a/src/data-structures/heap/min-heap.ts b/src/data-structures/heap/min-heap.ts index e5181dd..65ef234 100644 --- a/src/data-structures/heap/min-heap.ts +++ b/src/data-structures/heap/min-heap.ts @@ -7,11 +7,12 @@ */ import { Heap } from './heap'; -import type { Comparator } from '../../types'; +import type { HeapOptions } from '../../types'; export class MinHeap extends Heap { constructor( - options: { comparator: Comparator; nodes?: E[] } = { + elements?: Iterable, + options: HeapOptions = { comparator: (a: E, b: E) => { if (!(typeof a === 'number' && typeof b === 'number')) { throw new Error('The a, b params of compare function must be number'); @@ -19,8 +20,7 @@ export class MinHeap extends Heap { return a - b; } } - } - ) { - super(options); + }) { + super(elements, options); } } diff --git a/src/data-structures/linked-list/doubly-linked-list.ts b/src/data-structures/linked-list/doubly-linked-list.ts index d7b9b90..dcb2da5 100644 --- a/src/data-structures/linked-list/doubly-linked-list.ts +++ b/src/data-structures/linked-list/doubly-linked-list.ts @@ -26,10 +26,15 @@ export class DoublyLinkedList { /** * The constructor initializes the linked list with an empty head, tail, and length. */ - constructor() { + constructor(elements?: Iterable) { this._head = null; this._tail = null; this._length = 0; + if (elements) { + for (const el of elements) { + this.push(el); + } + } } protected _head: DoublyLinkedListNode | null; @@ -834,4 +839,8 @@ export class DoublyLinkedList { return accumulator; } + + print(): void { + console.log([...this]); + } } diff --git a/src/data-structures/linked-list/singly-linked-list.ts b/src/data-structures/linked-list/singly-linked-list.ts index d7372f0..d1d9a1a 100644 --- a/src/data-structures/linked-list/singly-linked-list.ts +++ b/src/data-structures/linked-list/singly-linked-list.ts @@ -24,10 +24,14 @@ export class SinglyLinkedList { /** * The constructor initializes the linked list with an empty head, tail, and length. */ - constructor() { + constructor(elements?: Iterable) { this._head = null; this._tail = null; this._length = 0; + if (elements) { + for (const el of elements) + this.push(el); + } } protected _head: SinglyLinkedListNode | null; @@ -781,4 +785,8 @@ export class SinglyLinkedList { return accumulator; } + + print(): void { + console.log([...this]); + } } diff --git a/src/data-structures/priority-queue/max-priority-queue.ts b/src/data-structures/priority-queue/max-priority-queue.ts index f1765a9..5bfa218 100644 --- a/src/data-structures/priority-queue/max-priority-queue.ts +++ b/src/data-structures/priority-queue/max-priority-queue.ts @@ -6,11 +6,12 @@ * @license MIT License */ import { PriorityQueue } from './priority-queue'; -import type { Comparator } from '../../types'; +import type { PriorityQueueOptions } from '../../types'; export class MaxPriorityQueue extends PriorityQueue { constructor( - options: { comparator: Comparator; nodes?: E[] } = { + elements?: Iterable, + options: PriorityQueueOptions = { comparator: (a: E, b: E) => { if (!(typeof a === 'number' && typeof b === 'number')) { throw new Error('The a, b params of compare function must be number'); @@ -20,6 +21,6 @@ export class MaxPriorityQueue extends PriorityQueue { } } ) { - super(options); + super(elements, options); } } diff --git a/src/data-structures/priority-queue/min-priority-queue.ts b/src/data-structures/priority-queue/min-priority-queue.ts index 04276ee..a06b8ee 100644 --- a/src/data-structures/priority-queue/min-priority-queue.ts +++ b/src/data-structures/priority-queue/min-priority-queue.ts @@ -6,20 +6,20 @@ * @license MIT License */ import { PriorityQueue } from './priority-queue'; -import type { Comparator } from '../../types'; +import type { PriorityQueueOptions } from '../../types'; export class MinPriorityQueue extends PriorityQueue { - constructor( - options: { comparator: Comparator; nodes?: E[] } = { - comparator: (a: E, b: E) => { - if (!(typeof a === 'number' && typeof b === 'number')) { - throw new Error('The a, b params of compare function must be number'); - } else { - return a - b; - } - } - } + constructor(elements?: Iterable, + options: PriorityQueueOptions = { + comparator: (a: E, b: E) => { + if (!(typeof a === 'number' && typeof b === 'number')) { + throw new Error('The a, b params of compare function must be number'); + } else { + return a - b; + } + } + } ) { - super(options); + super(elements, options); } } diff --git a/src/data-structures/priority-queue/priority-queue.ts b/src/data-structures/priority-queue/priority-queue.ts index e28121a..6978221 100644 --- a/src/data-structures/priority-queue/priority-queue.ts +++ b/src/data-structures/priority-queue/priority-queue.ts @@ -7,10 +7,10 @@ */ import { Heap } from '../heap'; -import { Comparator } from '../../types'; +import { PriorityQueueOptions } from '../../types'; export class PriorityQueue extends Heap { - constructor(options: { comparator: Comparator; nodes?: E[] }) { - super(options); + constructor(elements?: Iterable, options?: PriorityQueueOptions) { + super(elements, options); } } diff --git a/src/data-structures/queue/deque.ts b/src/data-structures/queue/deque.ts index 5ec2c2e..9326682 100644 --- a/src/data-structures/queue/deque.ts +++ b/src/data-structures/queue/deque.ts @@ -819,6 +819,10 @@ export class Deque { return accumulator; } + print(): void { + console.log([...this]) + } + /** * Time Complexity: O(n) * Space Complexity: O(n) diff --git a/src/data-structures/queue/queue.ts b/src/data-structures/queue/queue.ts index 74b0302..32a7bab 100644 --- a/src/data-structures/queue/queue.ts +++ b/src/data-structures/queue/queue.ts @@ -300,6 +300,10 @@ export class Queue { return new Queue(this.nodes.slice(this.offset)); } + print(): void { + console.log([...this]); + } + * [Symbol.iterator]() { for (const item of this.nodes) { yield item; diff --git a/src/data-structures/stack/stack.ts b/src/data-structures/stack/stack.ts index bfc4464..93cb0d3 100644 --- a/src/data-structures/stack/stack.ts +++ b/src/data-structures/stack/stack.ts @@ -10,8 +10,13 @@ export class Stack { * of elements of type `E`. It is used to initialize the `_elements` property of the class. If the `elements` parameter * is provided and is an array, it is assigned to the `_elements */ - constructor(elements?: E[]) { - this._elements = Array.isArray(elements) ? elements : []; + constructor(elements?: Iterable) { + this._elements = []; + if (elements) { + for (const el of elements) { + this.push(el); + } + } } protected _elements: E[]; @@ -153,7 +158,7 @@ export class Stack { * @returns An iterator object. */ * [Symbol.iterator]() { - for (let i = this.elements.length - 1; i >= 0; i--) { + for (let i = 0; i < this.elements.length; i++) { yield this.elements[i]; } } @@ -203,4 +208,8 @@ export class Stack { } return accumulator; } + + print(): void { + console.log([...this]); + } } diff --git a/src/types/data-structures/heap/heap.ts b/src/types/data-structures/heap/heap.ts index cb0ff5c..ed8deed 100644 --- a/src/types/data-structures/heap/heap.ts +++ b/src/types/data-structures/heap/heap.ts @@ -1 +1,3 @@ -export {}; +import { Comparator } from "../../common"; + +export type HeapOptions = { comparator: Comparator } \ No newline at end of file diff --git a/src/types/data-structures/priority-queue/priority-queue.ts b/src/types/data-structures/priority-queue/priority-queue.ts index cb0ff5c..524b762 100644 --- a/src/types/data-structures/priority-queue/priority-queue.ts +++ b/src/types/data-structures/priority-queue/priority-queue.ts @@ -1 +1,3 @@ -export {}; +import { HeapOptions } from "../heap"; + +export type PriorityQueueOptions = HeapOptions & {} \ No newline at end of file diff --git a/test/integration/conversion.test.ts b/test/integration/conversion.test.ts deleted file mode 100644 index e69de29..0000000 diff --git a/test/unit/data-structures/heap/heap.test.ts b/test/unit/data-structures/heap/heap.test.ts index d5f0499..84d4b7d 100644 --- a/test/unit/data-structures/heap/heap.test.ts +++ b/test/unit/data-structures/heap/heap.test.ts @@ -23,7 +23,7 @@ describe('Heap Operation Test', () => { }); it('should object heap work well', function () { - const minHeap = new MinHeap<{ a: string; key: number }>({ comparator: (a, b) => a.key - b.key }); + const minHeap = new MinHeap<{ a: string; key: number }>([], { comparator: (a, b) => a.key - b.key }); minHeap.add({ key: 1, a: 'a1' }); minHeap.add({ key: 6, a: 'a6' }); minHeap.add({ key: 2, a: 'a2' }); @@ -43,7 +43,7 @@ describe('Heap Operation Test', () => { i++; } - const maxHeap = new MaxHeap<{ key: number; a: string }>({ comparator: (a, b) => b.key - a.key }); + const maxHeap = new MaxHeap<{ key: number; a: string }>([], { comparator: (a, b) => b.key - a.key }); maxHeap.add({ key: 1, a: 'a1' }); maxHeap.add({ key: 6, a: 'a6' }); maxHeap.add({ key: 5, a: 'a5' }); diff --git a/test/unit/data-structures/heap/max-heap.test.ts b/test/unit/data-structures/heap/max-heap.test.ts index e665cf3..c8dc654 100644 --- a/test/unit/data-structures/heap/max-heap.test.ts +++ b/test/unit/data-structures/heap/max-heap.test.ts @@ -5,7 +5,7 @@ describe('MaxHeap', () => { let maxHeap: MaxHeap; beforeEach(() => { - maxHeap = new MaxHeap({ comparator: numberComparator }); + maxHeap = new MaxHeap([], { comparator: numberComparator }); }); it('add and poll elements in descending order', () => { diff --git a/test/unit/data-structures/heap/min-heap.test.ts b/test/unit/data-structures/heap/min-heap.test.ts index cdd8960..92f82df 100644 --- a/test/unit/data-structures/heap/min-heap.test.ts +++ b/test/unit/data-structures/heap/min-heap.test.ts @@ -5,7 +5,7 @@ describe('MinHeap', () => { let minHeap: MinHeap; beforeEach(() => { - minHeap = new MinHeap({ comparator: numberComparator }); + minHeap = new MinHeap([], { comparator: numberComparator }); }); it('add and poll elements in ascending order', () => { diff --git a/test/unit/data-structures/priority-queue/max-priority-queue.test.ts b/test/unit/data-structures/priority-queue/max-priority-queue.test.ts index 9e5f7ec..2461256 100644 --- a/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +++ b/test/unit/data-structures/priority-queue/max-priority-queue.test.ts @@ -16,7 +16,7 @@ describe('MaxPriorityQueue Operation Test', () => { }); it('should add elements and maintain heap property in a object MaxPriorityQueue', () => { - const priorityQueue = new MaxPriorityQueue<{ keyA: number }>({ comparator: (a, b) => b.keyA - a.keyA }); + const priorityQueue = new MaxPriorityQueue<{ keyA: number }>([], { comparator: (a, b) => b.keyA - a.keyA }); priorityQueue.refill([{ keyA: 5 }, { keyA: 3 }, { keyA: 1 }]); priorityQueue.add({ keyA: 7 }); @@ -52,7 +52,7 @@ describe('MaxPriorityQueue Operation Test', () => { it('should correctly heapify an array', () => { const array = [5, 3, 7, 1]; - const heap = MaxPriorityQueue.heapify({ elements: array, comparator: (a, b) => b - a }); + const heap = MaxPriorityQueue.heapify(array, { comparator: (a, b) => b - a }); heap.refill(array); expect(heap.poll()).toBe(7); @@ -63,7 +63,8 @@ describe('MaxPriorityQueue Operation Test', () => { it('should correctly heapify an object array', () => { const elements = [{ keyA: 5 }, { keyA: 3 }, { keyA: 7 }, { keyA: 1 }]; - const maxPQ = MaxPriorityQueue.heapify<{ keyA: number }>({ elements, comparator: (a, b) => b.keyA - a.keyA }); + debugger + const maxPQ = MaxPriorityQueue.heapify<{ keyA: number }>(elements, { comparator: (a, b) => b.keyA - a.keyA }); expect(maxPQ.poll()?.keyA).toBe(7); expect(maxPQ.poll()?.keyA).toBe(5); diff --git a/test/unit/data-structures/priority-queue/priority-queue.test.ts b/test/unit/data-structures/priority-queue/priority-queue.test.ts index 1b9aed4..710bef5 100644 --- a/test/unit/data-structures/priority-queue/priority-queue.test.ts +++ b/test/unit/data-structures/priority-queue/priority-queue.test.ts @@ -5,7 +5,7 @@ import { isDebugTest } from '../../../config'; const isDebug = isDebugTest; describe('PriorityQueue Operation Test', () => { it('should PriorityQueue poll, pee, heapify, toArray work well', function () { - const minPQ = new PriorityQueue({ comparator: (a, b) => a - b }); + const minPQ = new PriorityQueue([], { comparator: (a, b) => a - b }); minPQ.refill([5, 2, 3, 4, 6, 1]); expect(minPQ.toArray()).toEqual([1, 2, 3, 4, 6, 5]); minPQ.poll(); @@ -14,15 +14,14 @@ describe('PriorityQueue Operation Test', () => { expect(minPQ.toArray()).toEqual([4, 5, 6]); expect(minPQ.peek()).toBe(4); expect( - PriorityQueue.heapify({ - elements: [3, 2, 1, 5, 6, 7, 8, 9, 10], + PriorityQueue.heapify([3, 2, 1, 5, 6, 7, 8, 9, 10], { comparator: (a, b) => a - b }).toArray() - ).toEqual([1, 2, 3, 5, 6, 7, 8, 9, 10]); + ).toEqual([1, 3, 2, 5, 6, 7, 8, 9, 10]); }); it('should Max PriorityQueue poll, peek, heapify, toArray work well', function () { - const maxPriorityQueue = new PriorityQueue({ comparator: (a, b) => b - a }); + const maxPriorityQueue = new PriorityQueue([], { comparator: (a, b) => b - a }); maxPriorityQueue.refill([5, 2, 3, 4, 6, 1]); expect(maxPriorityQueue.toArray()).toEqual([6, 5, 3, 4, 2, 1]); maxPriorityQueue.poll(); @@ -31,15 +30,15 @@ describe('PriorityQueue Operation Test', () => { expect(maxPriorityQueue.toArray()).toEqual([3, 2, 1]); expect(maxPriorityQueue.peek()).toBe(3); expect( - PriorityQueue.heapify({ - elements: [3, 2, 1, 5, 6, 7, 8, 9, 10], + PriorityQueue.heapify([3, 2, 1, 5, 6, 7, 8, 9, 10], { + comparator: (a, b) => a - b }).toArray() - ).toEqual([1, 2, 3, 5, 6, 7, 8, 9, 10]); + ).toEqual([1, 3, 2, 5, 6, 7, 8, 9, 10]); }); it('should PriorityQueue clone, sort, getNodes, dfs work well', function () { - const minPQ1 = new PriorityQueue({ comparator: (a, b) => a - b }); + const minPQ1 = new PriorityQueue([], { comparator: (a, b) => a - b }); minPQ1.refill([2, 5, 8, 3, 1, 6, 7, 4]); const clonedPriorityQueue = minPQ1.clone(); expect(clonedPriorityQueue.elements).toEqual(minPQ1.elements); @@ -52,7 +51,7 @@ describe('PriorityQueue Operation Test', () => { describe('Priority Queue Performance Test', () => { it('should numeric heap work well', function () { - const pq = new PriorityQueue({ comparator: (a, b) => b - a }); + const pq = new PriorityQueue([], { comparator: (a, b) => b - a }); const tS = performance.now(); diff --git a/test/unit/data-structures/stack/stack.test.ts b/test/unit/data-structures/stack/stack.test.ts index 8ee443d..15118d9 100644 --- a/test/unit/data-structures/stack/stack.test.ts +++ b/test/unit/data-structures/stack/stack.test.ts @@ -83,7 +83,7 @@ describe('Stack iterative methods', () => { result.push(element); } - expect(result).toEqual([3, 2, 1]); // iteration should start from the top of the stack + expect(result).toEqual([1, 2, 3]); // iteration should start from the top of the stack }); test('should apply forEach to the stack', () => { @@ -92,7 +92,7 @@ describe('Stack iterative methods', () => { result.push(element); }); - expect(result).toEqual([3, 2, 1]); + expect(result).toEqual([1, 2, 3]); }); test('should filter elements in the stack', () => { diff --git a/test/unit/unrestricted-interconversion.test.ts b/test/unit/unrestricted-interconversion.test.ts new file mode 100644 index 0000000..c970212 --- /dev/null +++ b/test/unit/unrestricted-interconversion.test.ts @@ -0,0 +1,59 @@ +import { + Deque, + DoublyLinkedList, + MaxHeap, + MaxPriorityQueue, + MinHeap, + MinPriorityQueue, + Queue, + SinglyLinkedList, + Stack +} from '../../src'; + +const orgArr: number[] = [6, 1, 2, 7, 5, 3, 4, 9, 8]; +describe('conversions', () => { + it('Array to Queue', () => { + const q = new Queue(orgArr); + q.print(); + }) + + it('Array to Deque', () => { + const dq = new Deque(orgArr); + dq.print(); + }) + + it('Array to SinglyLinkedList', () => { + const sl = new SinglyLinkedList(orgArr); + sl.print(); + }) + + it('Array to DoublyLinkedList', () => { + const dl = new DoublyLinkedList(orgArr); + dl.print(); + }) + + it('Array to Stack', () => { + const stack = new Stack(orgArr); + stack.print(); + }) + + it('Array to MinHeap', () => { + const minHeap = new MinHeap(orgArr); + minHeap.print(); + }) + + it('Array to MaxHeap', () => { + const maxHeap = new MaxHeap(orgArr); + maxHeap.print(); + }) + + it('Array to MinPriorityQueue', () => { + const minPQ = new MinPriorityQueue(orgArr); + minPQ.print(); + }) + + it('Array to MaxPriorityQueue', () => { + const maxPQ = new MaxPriorityQueue(orgArr); + maxPQ.print(); + }) +}) \ No newline at end of file