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
/* | |
Converting a BST to TBT [Two way - Predecessor & Successor] | |
- Ajinkya Sonawane [AJ-CODE-7] | |
*/ | |
#include<iostream> | |
#include<list> | |
using namespace std; | |
class 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
/* | |
Adjacency List of a graph | |
- Ajinkya Sonawane [AJ-CODE-7] | |
*/ | |
#include<iostream> | |
#include<queue> | |
#define INFINITY 9999 //Defining INFINITY to 9999 | |
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
/* | |
Shortest Path between two cities using Djikstra's Algorithm | |
- Ajinkya Sonawane [AJ-CODE-7] | |
*/ | |
#include<iostream> | |
#define INFINITY 9999 | |
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
/* | |
Implementing AVL Tree using C++. | |
Ajinkya Sonawane [AJ-CODE-7] | |
*/ | |
#include<iostream> | |
using namespace std; | |
class 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
/* | |
C++ Program to create a Complete Binary Tree. | |
-Ajinkya Sonawane [AJ-CODE-7] | |
In a complete binary tree every level, except possibly the last, is completely filled, | |
and all nodes in the last level are as far left as possible. | |
It can have between 1 and 2h nodes at the last level h. | |
An alternative definition is a perfect tree whose rightmost leaves (perhaps all) have been removed. | |
Some authors use the term complete to refer instead to a perfect binary tree as defined above, |
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
/* | |
C++ Program to covert BST to Pre-Order TBT. | |
- Ajinkya Sonawane [AJ-CODE-7] | |
Pre-Order : Root -> Left -> Right | |
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
class Node: | |
def __init__(self,data,level,fval): | |
""" Initialize the node with the data, level of the node and the calculated fvalue """ | |
self.data = data | |
self.level = level | |
self.fval = fval | |
def generate_child(self): | |
""" Generate child nodes from the given node by moving the blank space | |
either in the four directions {up,down,left,right} """ |