Skip to content

Instantly share code, notes, and snippets.

View Ajinkya-Sonawane's full-sized avatar

Ajinkya Sonawane Ajinkya-Sonawane

View GitHub Profile
@Ajinkya-Sonawane
Ajinkya-Sonawane / tbt.cpp
Created March 19, 2017 07:02
C++ program for a two way Inorder Threaded Binary Tree.
/*
Converting a BST to TBT [Two way - Predecessor & Successor]
- Ajinkya Sonawane [AJ-CODE-7]
*/
#include<iostream>
#include<list>
using namespace std;
class node
@Ajinkya-Sonawane
Ajinkya-Sonawane / adjlist.cpp
Last active April 20, 2021 15:31
C++ Program to create Adjacency List of a Graph (Directedd or Undirected).
/*
Adjacency List of a graph
- Ajinkya Sonawane [AJ-CODE-7]
*/
#include<iostream>
#include<queue>
#define INFINITY 9999 //Defining INFINITY to 9999
using namespace std;
@Ajinkya-Sonawane
Ajinkya-Sonawane / dj.cpp
Last active March 24, 2017 15:47
Shortest Path Program between two cities using Djikstra's Algorithm
/*
Shortest Path between two cities using Djikstra's Algorithm
- Ajinkya Sonawane [AJ-CODE-7]
*/
#include<iostream>
#define INFINITY 9999
using namespace std;
@Ajinkya-Sonawane
Ajinkya-Sonawane / avl.cpp
Created March 23, 2017 18:48
AVL Tree Implementation using C++.
/*
Implementing AVL Tree using C++.
Ajinkya Sonawane [AJ-CODE-7]
*/
#include<iostream>
using namespace std;
class node
@Ajinkya-Sonawane
Ajinkya-Sonawane / cbt.cpp
Created March 25, 2017 18:53
Complete Binary Tree Implementation using C++.
/*
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,
@Ajinkya-Sonawane
Ajinkya-Sonawane / preTBT.cpp
Last active March 31, 2017 17:09
C++ Program to convert BST to Pre-Order Threaded Binary Tree
/*
C++ Program to covert BST to Pre-Order TBT.
- Ajinkya Sonawane [AJ-CODE-7]
Pre-Order : Root -> Left -> Right
5
/ \
/ \
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} """