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 / fun_structures.cpp
Created June 25, 2019 14:11
Different methods of passing Structures to Functions
#include <iostream>
using namespace std;
struct Queue{
int size;
int rear;
int front;
};
void passing_pointer(struct Queue *p){
@manojnaidu619
manojnaidu619 / DLL.cpp
Last active July 1, 2019 17:30
Doubly linked list in CPP
#include <iostream>
using namespace std;
struct Node{
struct Node *prev;
int data;
struct Node *next;
}*start=NULL,*last=NULL;
void insert(int ele){
@manojnaidu619
manojnaidu619 / sll_ins-del.cpp
Last active July 1, 2019 17:30
SLL Insertions & Deletion in CPP
#include <iostream>
using namespace std;
struct Node{
int data;
struct Node *next;
}*start=NULL;
void ins(int ele){
struct Node *p = start;
@manojnaidu619
manojnaidu619 / sll.cpp
Last active July 1, 2019 17:27
SLL in CPP
#include <iostream>
using namespace std;
struct Node {
int data;
struct Node *next;
}*start=NULL;
typedef struct Node node;
@manojnaidu619
manojnaidu619 / fibonacci.cpp
Last active July 1, 2019 17:28
Fibonacci using Recursion in CPP
#include <iostream>
using namespace std;
int fib(int n){
if(n<=1){return n;}else{
return fib(n-2) + fib(n-1);
}
}
int main(){
@manojnaidu619
manojnaidu619 / expo.cpp
Created June 20, 2019 13:29
Exponents using Recursion in CPP
#include <iostream>
using namespace std;
int power(int m, int n){
if(n==0){ return 1;}else{
return power(m,n-1) * m;
}
}
int main(){
@manojnaidu619
manojnaidu619 / factorial.cpp
Last active July 1, 2019 17:31
factorial in different ways in CPP
#include <iostream>
using namespace std;
int recursive_fact(int n){
/*
ex: fact(n) = 1*2*3........*(n-1)*n
so, (fact(n-1)*n) Gives us the answer
*/
@manojnaidu619
manojnaidu619 / sum_of_n.cpp
Created June 20, 2019 12:59
Computing Sum of n Natural numbers using different methods
#include <iostream>
using namespace std;
int sum_function(int last){
static int sum = 0;
for(int i=1;i<=last;i++){
sum += i;
}
return sum;
}
@manojnaidu619
manojnaidu619 / head_tail_recursion.cpp
Created June 20, 2019 12:35
Head and Tail Recursion in CPP
#include <iostream>
using namespace std;
void head(int x){
if(x>0){
fun(x-1);
cout << x << " ";
}
}
@manojnaidu619
manojnaidu619 / knapsack.c
Created May 16, 2019 16:58
0/1 Knapsack to find maximized benefit using Dynamic programming in C
#include <stdio.h>
#include <stdlib.h>
int max(int a,int b){
return (a>b) ? a : b;
}
void knapsack(int n, int W, int val[], int wt[]){
int i,w;
int K[n+1][W+1];