I had to implement Game of Life in a 3D matrix (int a[ ][ ][ ]) , but the complexity of my implementation is O(n^6) (6 imbricated for) and it runs very slow . Can anyone help me with an optimized version of Game of life , even with a 2D matrix . Or how the Game of Life in general could be optimized ?

It's a slightly strange statement that "the complexity is O(n^6)". A Life2d cell has 8 neighbours. A Life3d cell has 26 neighbours - that's all.
Help to optimize - what? That is a question...
Look at some prompts in
http://en.wikipedia.org/wiki/Conway's_Game_of_Life
Search Google for sparse matrix implementations...
Try to link all live cells in the list to avoid unnecessary idle cells processing...
And so on...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.