I don’t understand this part of the Hamiltonian Cycle - list

I am currently in university and i got an assignment on nodes for the Hamiltonian cycles and my lecturer dis not explain this thus am having issues trying to understand this part of the code by myself.Could you please help me?
List<List> allHamiltonianCycles = findAllHamiltonCycles(nodes);

Related

Runge-Kutta 4th order for predator-prey model

I want to solve a predator-prey model (Lotka-Volterra equations) with 4th order Runge-kutta method, but I don't know how to calculate the k's coefficients, my question isn't about programming (I even wrote a program to calculate the temporal evolution using Euler's method) but about maths, may someone explain me please?
Sorry if I don't post the equations, that's due I haven't the reputation enough to insert images.

How to divide vector into quintiles

My question is not so much about code, it's more of an algorithm problem. I am trying to think of a way to divide a vector of doubles into "quintiles" i.e. 5 parts. I then need to find the average of each individual part. The vector can have any number of data points. Does anyone have an idea of how to go about determining what the beginning and end index would be for each quintile? If anyone would like to suggest code, the language I am working with is C++. Thank you.

Diagonalization of a complex hermitian matrix in c++

I need to find a piece of code that will diagonalize a complex hermitian matrix. The size I'm looking at will be ranging from 3x3 to 30x30. Any help would be great, I'm a little new to c++. Please could you post links to the code rather than a description of where to find it if possible. Thanks!
A simple google search would have given the answer. Nonetheless you can start with
http://www.netlib.org/lapack++/
http://www.gnu.org/software/gsl/
http://www.mpi-hd.mpg.de/personalhomes/globes/3x3/
http://www.nrbook.com/empanel/

Data structures implementation code understanding

Im taking a course in algorithms and data structers, and my instructor wants me to implement several data structers (such as BST, stack etc.), and algorithms (such as quick search, DFS, etc.).
I want to belive that I understand the basics, but everytime Im starting to plan the code I have the same difficulty:
here's my current assigment: my instructor wants me to implement a DFS (depth first search) for a directed graph (using c++).
my question is- how do I suppose to implement the graph? should I use adjacency matrix? or should I use adjacency list? neither this nor that??
so I asked my instructor, and his answare was this: "think of the graph as a black box"...
more confused than before, I rashed to stackoverflow, and here i am posting this question...
I dont look for someone to tell me how to implement DFS (or any other algorithm- I can google too!)- I just need someone to explain what should I get as input, and what should I provide as output?
I'll appreciate any comment! thanks!
What he means by a black box is just that you cannot see the nodes and how they connect before you do your DFS. You will probably just get the root node and your algorithm with have to explore from there. As for what you should output- that depends on the assignment. Are you looking for specific data? if not, perhaps a detail of which nodes were visited in which order.

ideas regarding artificial intelligence in simple game (for ex : Tic Tac Toe) C++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
i have totally no idea regarding making artificial intelligence in a game (i am going to apply it on a simple Tic Tac Toe game)
my current idea is to make an array of possible options to win the game (like 3 X in row 1 = win or something)
and then makes the computer try to fill the grid with one of the arrays, but how to choose the most appropriate option from others, and how to make it smart/stupid (difficulties)
if possible i need an algorithm to use, and if possible a book that fills the gap in my brain =P
Best Regards
Check out the wikipedia page on Game trees, tic-tac-toe is actually used as an example.
Here's the complete solution for you:
courtesy: xkcd
Tic-Tac-Toe is a type of Zero-sum game and the "common" approach to such games is the Minimax algorithm. It's very efficient and fast, especially when combined with a good heuristic function.
There are some good C++ implementation of Minimax for Tic-Tac-Toe.
Update
Despite the fact that search algorithms such as Minimax fall under the AI algorithms category, I don't really consider them to be AI algorithms. I consider Minimax to be efficient search algorithms, so if you want an actual AI algorithm I would recommend looking into machine learning concepts such as: support vector machines, neural networks, genetic algorithms, genetic programming, etc. However, nearly all of the machine learning algorithms are going to be an overkill for the purposes of making a Tic-Tac-Toe agent/bot.
The Tic Tac Toe game is a "solved" game in Game Theory. That means there is an ability to say is one or another game situation win or lose.
I think this link might help you.
One possibility for simple games like tic-tac-toe would be brute force. If you have a winning move make it; otherwise if your opponent would have a winning move block that; otherwise consider every possible move recursively.
Look, pretty much every AI issue comes down to some sort of search. In the case of tic-tac-toe, you're searching among all the possible board positions. There are 9 cells, and 3 values, so there aer only 39 possible boards. If you generate them at the start, your search is very straightforward: start with you current position, look at all the pathways that result in a win for your side, and pick that.