data-structures-and-algorithms

Stacks and Queues

the challenge is about create as constructor for stack and queue.

Challenge

the challenge is about create as constructor for stack and queue.then to make methods push,pop,peek and isEmpty for the stack, and enqueue,dequeue,peek and isEmpty for the queue

Approach & Efficiency

BigO: Stack | Queue ——–|— push(value): time => O(1) space => O(1) | enqueue(value): time => O(1) space => O(1) pop(): time => O(1) space => O(1) | dequeue(): time => O(1) space => O(1) peek():time => O(1) space => O(1) | peek():time => O(1) space => O(1) isEmpty(): time => O(1) space => O(1) | isEmpty(): time => O(1) space => O(1)

API

Stack:

Queue:

Whiteboard

stack-and-queue