Skip to content

Instantly share code, notes, and snippets.

View manojnaidu619's full-sized avatar
🎯
Focusing

Manoj Kumar manojnaidu619

🎯
Focusing
  • Bangalore,India
View GitHub Profile
@manojnaidu619
manojnaidu619 / find_height_&_leaf_BST.cpp
Last active July 3, 2019 09:10
Getting height & leaf nodes of Left and Right subtree in a BST
#include <iostream>
using namespace std;
struct Node{
struct Node *lchild;
int data;
int height;
struct Node *rchild;
}*root=NULL,*lleaf=NULL,*rleaf=NULL; // Pointing to Left and Right leaf nodes in BST
@manojnaidu619
manojnaidu619 / cycle-loop_in_SLL.cpp
Created July 2, 2019 15:32
Leetcode solution for "Linked List Cycle" problem
class Solution {
public:
bool hasCycle(ListNode *head) {
struct ListNode *p=head, *q=head;
if(!head || head->next==NULL){
return false;
}
while(p!=NULL && p->next!=NULL){
p=p->next->next;
q=q->next;
@manojnaidu619
manojnaidu619 / del_node_in_SLL.cpp
Created July 2, 2019 15:30
Leetcode solution for "Delete Node in a Linked List" problem in CPP
class Solution {
public:
void deleteNode(ListNode* node) {
struct ListNode *p=node;
if(p->next != NULL){
p->val = p->next->val;
p->next = p->next->next;
}else{
return;
}
@manojnaidu619
manojnaidu619 / reverse_linked_list.cpp
Created June 30, 2019 09:41
Leetcode Solution for " Reverse Linked List " problem in CPP
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
@manojnaidu619
manojnaidu619 / BST.cpp
Last active July 3, 2019 08:08
Binary Search Tree Creation, Searching for key and Deleting leaf node in CPP
#include <iostream>
using namespace std;
struct Node{
struct Node *lchild;
int data;
struct Node *rchild;
}*root=NULL;
void insert(int key){
@manojnaidu619
manojnaidu619 / node_operations_BT.cpp
Last active July 1, 2019 17:27
Operations on nodes of Binary Tree in CPP
#include <iostream>
using namespace std;
int c = 0;
void postorder(struct Tree *p){ // Function to count number of nodes in the BT
if(p){
postorder(p->lchild);
postorder(p->rchild);
cout << p->data << " ";
@manojnaidu619
manojnaidu619 / BTree_using_Queue-LL.cpp
Last active July 3, 2019 07:29
Creating Binary Tree using Circular Queue (Linked List Representation) in CPP
#include <iostream>
using namespace std;
struct Tree{
struct Tree *lchild;
int data;
struct Tree *rchild;
}*root=NULL;
struct Node{
@manojnaidu619
manojnaidu619 / BTree_using_CircularQ.cpp
Last active July 3, 2019 07:32
Creating Binary Tree using Circular Queue (Array Representation) in CPP
#include <iostream>
using namespace std;
struct Node{
struct Node *lchild;
int data;
struct Node *rchild;
}*root=NULL;
@manojnaidu619
manojnaidu619 / DEq.cpp
Created June 27, 2019 08:29
Double Ended Queue using array in CPP
#include <iostream>
using namespace std;
struct queue{
int size;
int front;
int rear;
int *Q;
};
@manojnaidu619
manojnaidu619 / circular_Q.cpp
Last active June 27, 2019 10:37
Circular Queue implementation using Array in CPP
#include <iostream>
using namespace std;
struct Queue{
int size;
int front;
int rear;
int *Q;
};