logoNEURAL COOK
SearchAll PostsTagsNotesAuthor
logoNEURAL COOK

A posts created with Next.js and Tailwind.css

Explore

  • All posts
  • Notes
  • Snippets
  • Tags
  • RSS feed

Connect

instagramtwitterfacebookyoutubelinkedinmailgithub

© 2026 VIKI. All rights reserved.

Built with
Contents
ArraysData StructuresListMath OperationBinary SearchSortingString Operation
Snippets/java

Data Structures

1 min read
On this pageQueue
QueueStackHeap

# 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);
←PreviousArraysNext→List

On this page

QueueStackHeap