Server Side Programming Articles

Page 2094 of 2109

C++ Program to Generate All Pairs of Subsets Whose Union Make the Set

Samual Sam
Samual Sam
Updated on 30-Jul-2019 335 Views

This is a C++ program to generate all pairs of subsets, whose union make the Set.AlgorithmsBegin    function UnionSet():    Arguments:       a[] = an array.       n = number of elements.       Body of the function:       1) Generate binary code from 0 to 2^(n-1)-1 for all 2^(n-1) pairs.       2) Print the array element which has 0 or 1 in corresponding indexes in code string for each code.       3) Print them in a different set, which on the union of both sets gives the super set. EndExample#include #include #include using namespace std; void display(char code[], int a[], int n) //display the pairs {    int i;    cout

Read More

C++ Program to Implement Treap

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 2K+ Views

This is a C++ program to implement Treap. Treap data structure is basically a randomized binary search tree. Here, we shall consider insert, delete and search operations on this.Functions and descriptionsfunction rotLeft() for left rotationFirst rotate the tree then set new root.function rotRight() for right rotationFirst rotate the tree then set new root.function insetNod() to insert a given key into treap with priority recursively −If root = nullptr    return data as root. If given data is less then root node,    Insert data in left subtree.    Rotate left if heap property violated. else    Insert data in right ...

Read More

C++ program to convert time from 12 hour to 24 hour format

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 1K+ Views

This is a C++ program to convert time from 12 hour to 24 hour format.AlgorithmBegin    In main(),    If median = pm       Check if entered hours is less than 12          Then add 12 to hours and print the time in 24 hours format.       Check if entered hours is equal to 12          Then print “00” as hours and print the time in 24 hours format.    Else If median=am       Check if entered hours is less than 12          Then print ...

Read More

C++ Program to Find Whether a Path Exists Between 2 Given Nodes

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 366 Views

This is a C++ program to find whether a path exists between 2 given nodesAlgorithmBegin    function isReach() is a recursive function to check whether d is reachable to s:    A) Mark all the vertices as unvisited.    B) Mark the current node as visited and enqueue it and it will be used to get all adjacent vertices of a vertex.    C) Dequeue a vertex from queue and print it.    D) Get all adjacent vertices of the dequeued vertex s.    E) If an adjacent has not been visited, then mark it visited and enqueue it.   ...

Read More

C++ Program to Print the Kind of Rotation the AVL Tree is Undergoing When you Add an Element or Delete an Element

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 229 Views

AVL tree is a self-balancing Binary Search Tree where the difference between heights of left and right subtrees cannot be more than one for all nodesTree rotation is an operation that changes the structure without interfering with the order of the elements on an AVL tree. It moves one node up in the tree and one node down. It is used to change the shape of the tree, and to decrease its height by moving smaller subtrees down and larger subtrees up, resulting in improved performance of many tree operations. The direction of a rotation depends on the side which ...

Read More

How to listdown all the symbols in a .so file in C++

Samual Sam
Samual Sam
Updated on 30-Jul-2019 926 Views

To read a .so file in elf format, use readelfreadelf -Ws libName.soIt helps to extract symbol from binary.The standard tool used for listing all symbol is, nmnm -g libName.so

Read More

C++ Program to Implement Hash Tables

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 22K+ Views

A hash table is a data structure which is used to store key-value pairs. Hash function is used by hash table to compute an index into an array in which an element will be inserted or searched.This is a C++ program to Implement Hash Tables.AlgorithmBegin    Initialize the table size T_S to some integer value.    Create a structure hashTableEntry to declare key k and value v.    Create a class hashMapTable:    Create a constructor hashMapTable to create the table.    Create a hashFunc() function which return key mod T_S.    Create a function Insert() to insert element at ...

Read More

C++ Program to Implement Hash Tables Chaining with Doubly Linked Lists

Samual Sam
Samual Sam
Updated on 30-Jul-2019 727 Views

A hash table is a data structure which is used to store key-value pairs. Hash function is used by hash table to compute an index into an array in which an element will be inserted or searched.This is a C++ program to Implement Hash Tables chaining with doubly linked lists.AlgorithmFor insert:Begin    Declare Function insert(int k, int v)       int hash_v= HashFunc(k)       HashTableEntry *en = ht[hash_v]       if (en == NULL)          en = new HashTableEntry          en->d = v          en->k = k ...

Read More

Global memory management in C++ : Stack or Heap?

Samual Sam
Samual Sam
Updated on 30-Jul-2019 2K+ Views

Stack and heap are used to store variables during the execution of the program and it also get destroyed.Global data structures or global variables are not consumed by stack or heap. They basically allocated in a fixed memory block, which remains unchanged.int a[10]; // located in a fixed memory block int main() {    int main() {       float *ptr = (int *)malloc(sizeof(float)10.0)); //use heap.    } }

Read More

C++ Program to Implement Hash Tables Chaining with List Heads

Samual Sam
Samual Sam
Updated on 30-Jul-2019 722 Views

A hash table is a data structure which is used to store key-value pairs. Hash function is used by hash table to compute an index into an array in which an element will be inserted or searched.This is a C++ Program to Implement Hash Tables Chaining with List Heads.AlgorithmFor insert:Begin    Declare function Insert(int k, int v)       int hash_v = HashFunc(k)       if (ht[hash_v] == NULL)          ht[hash_v] = new ListHead(k, v)       else          ListHead *en = ht[hash_v]          while (en->n != NULL) ...

Read More
Showing 20931–20940 of 21,090 articles
Advertisements