This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PAGE - 1 | |
//AVL TREE | |
//MAX PRODUCT SUBSEQ OF SIZE 3 IN INCREASING ORDER | |
#include<iostream> | |
using namespace std; | |
struct Node | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Quick sort on Link Lists | |
//Doubly LinkList | |
//Note:- tricky check while swap | |
#include<iostream> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//splay tree implementation | |
//Insert operation | |
//Search operation | |
//delete not splay nodes | |
#include<iostream> | |
using namespace std; | |
struct Node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Hackerrank code challenge | |
//DNA alignment and scoring | |
#include<iostream> | |
using namespace std; | |
int m[5][5] = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 |
OlderNewer