Skip to content

chisa-sifiso/QueueDatastuacture-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Queue-Activity-Java

This repository contains a Java implementation of a Queue using an array, demonstrating circular queue behavior and basic queue operations.

Overview

The Queue follows the FIFO (First In, First Out) principle. This implementation uses an array with a circular approach, meaning that when the rear index reaches the end of the array, it wraps around to the beginning if there is space available.

Features

  • Enqueue: Inserts an element at the rear of the queue.
  • Dequeue: Removes an element from the front of the queue.
  • Peek: Retrieves the front element without removing it.
  • isEmpty & isFull: Checks if the queue is empty or full.
  • Circular Array: Uses modulus arithmetic to wrap indices.

Project Structure

Queue-Activity-Java/
├── src/
│   ├── Queue.java
│   └── Main.java
├── README.html
└── .gitignore
    

Usage

Clone the repository, compile the Java source files, and run the Main class:

git clone https://github.com/Chisa-sifiso/Queue-Activity-Java.git
cd Queue-Activity-Java/src
javac Main.java
java Main
    

Code Example

Queue queue = new Queue(5);
queue.enqueue(10);
queue.enqueue(20);
queue.enqueue(30);
queue.printQueue(); // Output: Queue: 10 20 30
System.out.println("Dequeued: " + queue.dequeue());
queue.printQueue();
    

License

This project is licensed under the MIT License.

#

Developed by Sifiso Vinjwa

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages