Can anyone give me some examples on how to apply stacks and trees..

stacks can be implemented using array .take a variable which is nothing but index of the position in which we can insert data,call it top and increment it whenever we
insert and decrement it by one whenever we pop out something

@JONZ

Your question doesn't specify your need correctly.Well I could frame two questions out of it. So answering them.

1)How to create stacks and trees?

Stacks can be created using many methods. By Arrays, using a variable to act as top indicator. By Linked List, using a node pointer to act as top indicator.

2)Where can you apply stacks and trees?

Stacks can be applied for various applications.
Ex : Reversal of a string.
Trees are applied where ever solution to the problem needs branching of decisions at various levels according to requisites.
Ex : T9 dictionary in mobiles.

0
Trees are applied where ever solution to the problem needs branching of decisions at various levels according to requisites.
Ex : T9 dictionary in mobiles.

There also an important use of Trees in gaming Applications like in a Football game the movement of a Player is actually implemented using Trees by moving in huge number of nodes beside each other this technique makes the player's movement more flexible .

are trees implemented in the minesweeper game? if yes, then how?

are trees implemented in the minesweeper game? if yes, then how?

I don't think so, since the Mine Sweeper will use two Dimensional array as a Data Structure to assign a random number of mines in random cells.

But i think tress can be used implicitly by implementing recursive functions.

That's my thoughts :$ .

Ya I too agree with Ahmed_I that Minesweeper just uses a two dimensional array with mines generated at random.
Then a program is run which takes the present cell co-ordinates and calculates number of mines in all adjoining cells and writes a number equal to number of mines around it.

The later part of clicking and all can be done through some other methods.

I just read a while ago that trees can be implemented in some boardgames..can you give me some board games where trees are implemented?

I just read a while ago that trees can be implemented in some boardgames..can you give me some board games where trees are implemented?

Well SCRABBLE would be the best example I suppose.When the computer plays with its set of letters it branches out and tries all possibilities to make a word which is there in the process of branching and trying for new words trees are used... Because they would be the best way to try out things.

Checkers would be a good example. It would be a decent way to make an "AI" for it. Use trees to see all possible outcomes of a certain move, compare that with all the other outcomes to see the best move. (adding a limitation on the depth of analysis might be appropriate for speed/difficulty purposes)

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.