logoNEURAL COOK
SearchAll PostsTagsNotesAuthor
instagramtwitterfacebookyoutubelinkedinmailgithubrss
Copyright © 2026 All rights reserved.
•
VIKI
Built with Vikramaditya Singh
Built with
VIKI - A posts created with Next.js and Tailwind.css
java
Arrays
Data Structures
List
Math Operation
Binary Search
Sorting
String Operation
Snippets›java

Data Structures

# Queue

To create a queue

Queue&lt;object_type&gt; queue = new LinkedList<>();

to insert an element

queue.add(object);

to see the head

queue.peek();

to remove the head

object_type object = queue.poll();

# Stack

To create a stack

Stack&lt;object_type&gt; stack = new Stack<>();

to insert an element

stack.push(object);

to remove an element on top

object_type object = stack.pop();

to see the top of the stack

object_type object = stack.peek();

# Heap

The PriorityQueue is based on the Priority Heap

// Priority Queue Min Type by deafault
PriorityQueue&lt;object_type&gt; heap = new PriorityQueue<>();
 
// Priority Queue Max Type use comparator 
PriorityQueue&lt;object_type&gt; heap = new PriorityQueue<>(Collections.reverseOrder());

to add an element

heap.add(o);

to see the top of the queue

object_type o = heap.peek();

to remove the top element

object_type o = heap.poll();

to remove object o from the queue

object_type o = heap.remove(o);
PreviousArraysNextList
CONTENTS
QueueStackHeap