Queue Implementation using Arrays and Linked List in Java | Enqueue | Dequeue| Data structures

preview_player
Показать описание
Queue Introduction - How to perform Enqueue and Dequeue on Arrays using front and rear - shifting technique in arrays for dequeue - complexity analysis - How to perform Enqueue and Dequeue using linked list - implementation in c/c++

#DataStructures #Algorithms #DSA #DS #DSALGO

Рекомендации по теме
Комментарии
Автор

mam i reallly learning from ur videos its lovely

AlgoXperience
Автор

7:20 “Arrays vechu implement panradhu seriyaana thalavali”🤣🤣

nikithaas
Автор

I have a doubt. In enque method while checking the front==null you have assigned the newNode as front. But not assigned the newNode as rear. Why ❓
Like,
if(front==null) {
front = newNode;
rear = newNode;
}

harirams
Автор

Hi.. amazing job.. very helpful videos.. i think a small change is required in Enqueue method- LL implementation - if front==null, then front =newNode and also rear =newNode i believe. that assignment is missed. only in else condition its mentioned rear= newNode. correct me if my understanding is not right.

ambicasanjeevi
Автор

is array memory allocation should be done in constructor ? with using array

shibushiva
Автор

mam suggest a good screen recorder for windows

KavinkumarV-in
Автор

Hi madam, Your teaching is awesome, very helpful to me. Small idea from my side regarding implementing Queue using array without rear variable as well as flexible queue that works always with no boundary issues by MODULUS % operator that overcomes the limitation of O(1) and O(n) in both the techniques u told. Here is my code. I am just a learner. Please give me feedback madam.

public class QueueArray<T> {
private static final int MAX_SIZE = 5;
private T arr[];
private int front;
private int queueSize;


QueueArray(){
arr = (T[])new Object[MAX_SIZE];
front = 0;
queueSize = 0;
}

public void enqueue(T val){
if(queueSize == MAX_SIZE)
throw new is Full");
arr[(front + queueSize++) % MAX_SIZE] = val;
: " + val);
}

public T dequeue(){
if(queueSize == 0)
throw new is Empty");
int temp = front;
front = ++front % MAX_SIZE;
queueSize--;
return arr[temp];
}

public void display(){
int temp = front;
if(queueSize == 0)
throw new is Empty");
in queue :\t");
for(int i=0;i<queueSize;i++){
System.out.print(arr[temp] + " ");
temp = ++temp % MAX_SIZE;
}
System.out.print("\nFront : " + front + "\tSize : " + queueSize + "\n");
}
}


public class QueueDemo {

public static void main(String[] args) {
QueueArray<Integer> queue = new QueueArray<Integer>();
= 1
queue.display();
= 2
queue.display();
= 3
queue.display();
: " + queue.dequeue()); //queueSize = 2
queue.display();
: " + queue.dequeue()); //queueSize = 1
queue.display();
: " + queue.dequeue()); //queueSize = 0
//queue.display(); //Queue is Empty
: " + queue.dequeue()); //Queue is Empty
= 1
queue.display();
= 2
queue.display();
= 3
queue.display();
: " + queue.dequeue()); //queueSize = 2
queue.display();
= 3
queue.display();
= 4
queue.display();
is full
//queue.display();
: " + queue.dequeue()); //queueSize = 3
queue.display();
: " + queue.dequeue()); //queueSize = 2
queue.display();
: " + queue.dequeue()); //queueSize = 1
queue.display();
}
}

tamilevergreensongs
Автор

Yekkov na ipotha langs kathukalam iruka...so Playlist la post panniruka c, c++ la ellame cover pannirukingala sister.

SSR_ARENA
Автор

Madam queue structure c, c++ explanation video irukka ?

naveed-mzej
Автор

mam neinga super coding podureing and super soillum thareinga aana neing ye youtube la videos
upload pannureinga

ltgaming
Автор

I hae used a different method i will paste the code is this effective?

//queue implementation using array

import java.util.Arrays;

class cls
{

int size=4;
int[] arr=new int[size];
int front, rear;

cls(){
front=0;
rear=-1;
}
public void enqueue(int val)
{
if(rear==arr.length-1)
{
throw new full aaa irruku can't insert any element");
}
rear+=1;
arr[rear]=val;

}
public void dequeue() {
try {
if (arr[front] == 0) {
throw new empty ya irruku cannot delete any thing");
}
else {
System.out.println("Dequeued element is :" + arr[front]);
front += 1;
}
} catch e){
//System.out.println("empty queue");
throw new queue");
}
}
}


class maincls
{
public static void main(String args[])
{
cls object=new cls();
//object.dequeue();
object.enqueue(5);
object.enqueue(51);
object.enqueue(511);
object.enqueue(5123);
object.enqueue(12345);
object.dequeue();
object.dequeue();
object.dequeue();
object.dequeue();
object.dequeue();
}
}

renga
Автор

Hii bro difference between front end developer and backend developer full details poduinga

nothingisimpossible
Автор

Mam please tell y we use bufferReader in programming... No doubt in this videos

sathishraja
Автор

You made a mistake this code got error because you didn't mention (rear = newNode) inside if condition

SakthivelB-yp