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
//Sieve of Eratosthenes | |
//Author: Milon | |
#include<cstdio> | |
#include<cmath> | |
using namespace std; | |
#define max 19000000 | |
bool prime[max+1]; |
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
//Prime number check | |
//Author: Milon | |
bool isPrime(int num){ | |
if(num==1) | |
return false; | |
if(num==2) | |
return true; | |
if(num%2==0) | |
return false; |
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
//Prime number check | |
//Author: Milon | |
bool isPrime(int num){ | |
if(num<2) | |
return false; | |
if(num==2) | |
return true; | |
if(num%2==0) | |
return false; |
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
//Prime number check | |
//Author: Milon | |
bool isPrime(int num){ | |
if(num<2) | |
return false; | |
if(num==2) | |
return true; | |
if(num%2==0) | |
return false; |
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
//Prime number check | |
//Author: Milon | |
#include<iostream> | |
using namespace std; | |
bool isPrime(int num){ | |
if(num<2) | |
return false; | |
for(int i=2;i<num;i++) |
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
//Weighted graph | |
//Author: Milon | |
#include<iostream> | |
#include<cstdio> | |
using namespace std; | |
int main(){ | |
int n; | |
cout<<"Enter the number of nodes: "; |
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 | |
//Author: Milon | |
#include<iostream> | |
#include<cstdlib> | |
using namespace std; | |
struct list{ | |
int val; | |
struct list *next; |
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
//Directed graph | |
//Author: Milon | |
#include<iostream> | |
#include<cstdio> | |
using namespace std; | |
int main(){ | |
int n; | |
cout<<"Enter the number of nodes: "; |
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
//Two Way Linked List | |
//Author: Milon | |
import java.util.NoSuchElementException; | |
//Node class | |
class Node{ | |
//Instance variable | |
private Object data; | |
private Node nextNode; |
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
//Directed graph | |
//Author: Milon | |
#include<iostream> | |
#include<cstdio> | |
using namespace std; | |
int main(){ | |
int n; | |
cout<<"Enter the number of nodes: "; |