# Data Structures

### Indexed Priority Queue with Implementation

#include using namespace std;  template   class indexed_priority_queue {          unordered_map m;          vector v;          long long numberOfElement;          Comparator comp;          long long capacity = LLONG_MAX;          long long int getValueIndex(T1 key)    {        if…

### Print Adjacency List for a Directed Graph

An Adjacency List is used for representing graphs. Here, for every vertex in the graph, we have a list of…

### Modify a Linked List to contain last occurrences of every duplicate element

#include using namespace std;  class Node {public:    int data;    Node* next;      Node(int x)    {        this->data = x;        this->next = NULL;    }};  Node* reverseList(Node* head){    Node *prev = NULL, *nextNode =…

### When to use each Sorting Algorithms | Set 2

Sorting is the process of arranging a set of data in a specific order, which may be numerical (ascending, descending)…

### Program to implement Hash Table using Open Addressing

#include #include   struct HashNode {    int key;    int value;};  const int capacity = 20;int size = 0;  struct HashNode** arr;struct HashNode* dummy;  void insert(int key,…

### Design a dynamic stack using arrays that supports getMin() in O(1) time and O(1) extra space

#include using namespace std;  class Stack {private:            int Max = 5;              int* arr = new int(Max);              int minEle = 0;              int top = 0;  public:            bool empty()    {        if…

### Count ways to split array into three non-empty subarrays having equal Bitwise XOR values

Count ways to split array into three non-empty subarrays having equal Bitwise XOR valuesGiven an array arr[] consisting of N…

### Subtract 1 from a number represented as Linked List

#include using namespace std;  class Node {public:    int data;    Node* next;};  Node* newNode(int data){        Node* new_node = new Node;    new_node->data = data;    new_node->next = NULL;          return new_node;}  int subtractOneUtil(Node*…