Skip to content

Instantly share code, notes, and snippets.

PAGE - 1
//AVL TREE
//MAX PRODUCT SUBSEQ OF SIZE 3 IN INCREASING ORDER
#include<iostream>
using namespace std;
struct Node
{
//Quick sort on Link Lists
//Doubly LinkList
//Note:- tricky check while swap
#include<iostream>
using namespace std;
//In A Binary tree how many keys are >= k1 && <= k2
int KeyCount(Node* root,int k1, int k2)
{
if(root == NULL) return 0;
if(root.key < k1) return KeyCount(root->right,k1,k2);
if(root.key > k2) return KeyCount(root->left,k1,k2);
//Exception handling in threads
//To propagate exceptions between threads you could catch them in the thread
//function and store them in a place where it can be accessed later.
std::mutex g_mutex;
std::vector<std::exception_ptr> g_exceptions;
void throw_function()
{
//Post order to pre order travesal without building tree
//Assume tree is full tree just like min max heap
#include<iostream>
using namespace std;
struct Node
//Head Tail flip solution in room
//Room have many coins none of above on a coin
//u pick one coin if its tail u make it head and place back
//if its head toss it and what it come place same way
//what will be stage after 100000 iterations
// head to tail ratio i mean
#include<iostream>
using namespace std;
PAGE - 2
//DEC TO BCD
//BCD format each deciaml digit hold 4 bits 0->0001
//Bitset used here
//std::bitset<32> b(num)
#include<iostream>
using namespace std;
//splay tree implementation
//Insert operation
//Search operation
//delete not splay nodes
#include<iostream>
using namespace std;
struct Node
//Hackerrank code challenge
//DNA alignment and scoring
#include<iostream>
using namespace std;
int m[5][5] = {
//Can we throw exception from destructor
//yes we can but its not advisable to do this
//Why
//Bcoz may be some other function make an object of this class on stack in try block
//and in that try block if exception generated then its unstable state and programme
// be go in abort