Stacks and trees

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2008
Posts: 8
Reputation: JONZ is an unknown quantity at this point 
Solved Threads: 0
JONZ JONZ is offline Offline
Newbie Poster

Stacks and trees

 
0
  #1
Feb 10th, 2009
Can anyone give me some examples on how to apply stacks and trees..
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 4
Reputation: priyankasaini has a little shameless behaviour in the past 
Solved Threads: 0
priyankasaini priyankasaini is offline Offline
Newbie Poster

Re: Stacks and trees

 
0
  #2
Feb 10th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 476
Reputation: csurfer is just really nice csurfer is just really nice csurfer is just really nice csurfer is just really nice csurfer is just really nice 
Solved Threads: 76
csurfer's Avatar
csurfer csurfer is offline Offline
Posting Pro in Training

Re: Stacks and trees

 
0
  #3
Feb 10th, 2009
@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.
I Surf in "C"....
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 32
Reputation: Ahmed_I is an unknown quantity at this point 
Solved Threads: 1
Ahmed_I Ahmed_I is offline Offline
Light Poster

Re: Stacks and trees

 
0
  #4
Feb 10th, 2009
Originally Posted by csurfer View Post
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 .
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 8
Reputation: JONZ is an unknown quantity at this point 
Solved Threads: 0
JONZ JONZ is offline Offline
Newbie Poster

Re: Stacks and trees

 
0
  #5
Feb 12th, 2009
are trees implemented in the minesweeper game? if yes, then how?
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 32
Reputation: Ahmed_I is an unknown quantity at this point 
Solved Threads: 1
Ahmed_I Ahmed_I is offline Offline
Light Poster

Re: Stacks and trees

 
0
  #6
Feb 12th, 2009
Originally Posted by JONZ View Post
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 .
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 476
Reputation: csurfer is just really nice csurfer is just really nice csurfer is just really nice csurfer is just really nice csurfer is just really nice 
Solved Threads: 76
csurfer's Avatar
csurfer csurfer is offline Offline
Posting Pro in Training

Re: Stacks and trees

 
0
  #7
Feb 12th, 2009
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 Surf in "C"....
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 8
Reputation: JONZ is an unknown quantity at this point 
Solved Threads: 0
JONZ JONZ is offline Offline
Newbie Poster

Re: Stacks and trees

 
0
  #8
Feb 14th, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 476
Reputation: csurfer is just really nice csurfer is just really nice csurfer is just really nice csurfer is just really nice csurfer is just really nice 
Solved Threads: 76
csurfer's Avatar
csurfer csurfer is offline Offline
Posting Pro in Training

Re: Stacks and trees

 
0
  #9
Feb 14th, 2009
Originally Posted by JONZ View Post
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.
I Surf in "C"....
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 357
Reputation: death_oclock will become famous soon enough death_oclock will become famous soon enough 
Solved Threads: 37
death_oclock's Avatar
death_oclock death_oclock is offline Offline
Posting Whiz

Re: Stacks and trees

 
0
  #10
Feb 14th, 2009
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)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC