Sunday, 28 Nov 2021
Category: Data Structures

Hashing is a great practical tool, with an interesting and subtle theory too. In addition to its use as a dictionary data structure, hashing also comes up in many different areas, including cryptography and complexity theory. This article discusses an important notion: Universal Hashing (also known as universal hash function families).Universal Hashing refers to selecting a […]

#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 (m[key] == 0) {            cout

An Adjacency List is used for representing graphs. Here, for every vertex in the graph, we have a list of all the other vertices which the particular vertex has an edge to.Problem: Given the adjacency list and number of vertices and edges of a graph, the task is to represent the adjacency list for a […]

#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 = NULL;    while (head != NULL) {                          nextNode = head->next;                          head->next = prev;          prev = head;          head = nextNode;    }    return prev;}  Node* Remove_Dup_Keep_Last_Occurence(    Node* head){        Node* dummy = new Node(-1);    dummy->next = head;          dummy->next = reverseList(dummy->next);          unordered_set visited;      Node *currNode = dummy, *nextNode;          while (currNode != NULL           && currNode->next != NULL) […]

Sorting is the process of arranging a set of data in a specific order, which may be numerical (ascending, descending) or lexicographical (alphabetical) order.Why Sorting Is Required?Sorting is very essential when there is a need to highly optimize the searching algorithm. For example, let’s assume two cases for searching for a certain element.Case 1: Searching […]

#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, int V){      struct HashNode* temp        = (struct HashNode*)malloc(sizeof(struct HashNode));    temp->key = key;    temp->value = V;              int hashIndex = key % capacity;          while (arr[hashIndex] != NULL           && arr[hashIndex]->key != key           && arr[hashIndex]->key != -1) {        hashIndex++;        hashIndex %= capacity;    }              if (arr[hashIndex] == NULL        || arr[hashIndex]->key == -1)        size++;      arr[hashIndex] = […]

#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 (top

Count ways to split array into three non-empty subarrays having equal Bitwise XOR valuesGiven an array arr[] consisting of N non-negative integers, the task is to count the number of ways to split the array into three different non-empty subarrays such that Bitwise XOR of each subarray is equal. Examples:Input: arr[] = {7, 0, 5, 2, […]