Skip to content

bilalmalik395/DSA-assinment-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Stack and Queue Implementation using Linked Lists

Objective

This project demonstrates the implementation of Stack and Queue data structures using Linked Lists. It was developed as part of an academic assignment.


Features

Stack Functionalities

  • Push operation: Adds an element to the stack.

  • Pop operation: Removes the top element from the stack.

  • Peek operation: Views the top element without removing it.

  • Check if the stack is empty.

Queue Functionalities

  • Enqueue operation: Adds an element to the rear of the queue.

  • Dequeue operation: Removes the front element from the queue.

  • Peek operation: Views the front element without removing it.

  • Check if the queue is empty.


Stack Documentation

Overview

A Stack follows the LIFO (Last-In, First-Out) principle, meaning elements are added and removed from the top.

Methods

  • push(value): Adds an element to the top of the stack.

  • pop(): Removes and returns the top element. If the stack is empty, it returns "Stack is empty."

  • peek(): Returns the top element without removing it. If the stack is empty, it returns "Stack is empty."

  • isEmpty(): Checks whether the stack is empty.

  • stackSize(): Returns the current size of the stack.

  • displayStack(): Displays all elements in the stack, from top to bottom.


Queue Documentation

Overview

A Queue follows the FIFO (First-In, First-Out) principle, where elements are added at the rear and removed from the front.

Methods

  • enqueue(element): Adds an element to the rear of the queue.

  • dequeue(): Removes and returns the element from the front. If the queue is empty, it returns "Queue is empty."

  • peek(): Returns the front element without removing it. If the queue is empty, it returns "Queue is empty."

  • isEmpty(): Checks whether the queue is empty.

  • size(): Returns the current size of the queue.

  • displayQueue(): Displays all elements in the queue, from front to rear.


Time Complexity

Stack Operations

  • Push: ( O(1) )

  • Pop: ( O(1) )

  • Peek: ( O(1) )

Queue Operations

  • Enqueue: ( O(1) )

  • Dequeue: ( O(1) )

  • Peek: ( O(1) )


Author Information

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages