Can you determine whether a compound can form given particular elements?
Answer on first question is no, on second is yes.


Consider this short list C, H, O, N this elements can produce unlimited number of compounds. 
If you have short formula like C6H6 and you assuming only covalent bonds in molecule, define valence 4 for Carbon and 1 for Hydrogen you can make mathematical calculation according to graph theory and you will get 217 structures. But most of them doesn't exist due to bonds strain and intersection. If you want to obtain existing molecules you can filter this 217 models using for instance quantum mechanics calculation.