Data Structures
Arrays
Array is just a list of some objects of certain datatype.
We have 1-D and 2-D arrays.
Each element is stored at a certain index and can be accessed using that index.
Vectors or ArrayList
Same as array but elements can be removed or inserted while executing.
Vector
Dictionaries or Hash Tables
Store a list of keys having a value associated with each of them.
Map
Stacks (LIFO)
A list in which only the last element entered can be accessed or manipulated.
Queues (FIFO)
A list of objects in which only initially entered/first element can be accessed or manipulated.
Sieve of Eratosthenes
generate all prime numbers between two given numbers
int x[100001]; int max=100001; void sieve() { for(int i=0;i<max;i++) x[i]=1; x[0]=x[1]=0; for(int i=2;i<max;i++) { if(x[i]==1) { for(int j=2*i;j<max;j+=i) x[i]=0; } } } main() { int n,m; cin>>n>>m; for(int i=n;i<=m;i++) { if(x[i]==1) print (i); } }
Code for Sieve of Eratosthenes :
Questions?
Thank You
By Vijay Krishnavanshi
Open Source Developer at KDE