GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Jan-2005, 14:46
the_crazyman the_crazyman is offline
Awaiting Email Confirmation
 
Join Date: Apr 2004
Posts: 11
the_crazyman is on a distinguished road

ADT's - Common Usage


Hi all.

not been on for a while and as your help was so good last time, I was hoping you could lend me your views again.

Simple question, absolutely no code involved.

I'm trying to identify ways in which the follwoing ADT's could be used in a Real World environment.

Stacks

Queues

Linked Lists

Square Linked Lists

Binary Tree.


I have the following scenarios and any ideas you wanna throw in would be most useful.

Stack - ?? stuck on this one.

Queue - Could be used as a holding file for a print job. Airport take-off & landing scenario

Linked Lists - for holding data in ascending/descending order as easy to search through using Binary Search

Square Linked Lists - Same use as above, but used with much more data.

Binary Tree - ?? but suppose somert like storing phone book details as they a search on this type of data structure is very quick.


Any comments/additions most welcome.
And it's not got any of my 'bad' code in to analyse.


by the way, the reason I ask is this question may appear on my exam paper next week. Just trying to get a good foundation.

the_crazyman
  #2  
Old 14-Jan-2005, 01:35
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,258
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by the_crazyman
Stack - ?? stuck on this one.
Anyplace where you need to store information received and retrieve the information from the last info stored. A really common example is analyzing and breaking apart a math equation. Say you have the following equation:
2 + 3 * 1 + 8 - 3
and are to 'disassemble' the equation and executed from the right to left.
2 stacks are involved, operaors and operands. Store each number and operator on their respective stack as you move thru the equation:
operand gets: 2 3 1 8 3
operator gets: + * + -
Now you
1) remove them from the stack, 2 numbers per operator
2) perform the calculation
3) put the answer back on the stack:

IOW, retrieve 8, 3, - (8 - 3) and get 5. Put that back on the stack:
operand has: 2 3 1 5
operator has: + * +

Repeat til done.

Another stack example: a simple pile. Your bills start arriving. They go in a pile until you're ready to pay them. When that time comes, you take the top bill and write the check. Then the next. And so on until the money runs out. You can't look thru the bills, that would not be a stack.


Quote:
Originally Posted by the_crazyman
Queue - Could be used as a holding file for a print job. Airport take-off & landing scenario
Line at the grocery store...


Quote:
Originally Posted by the_crazyman
Binary Tree - ?? but suppose somert like storing phone book details as they a search on this type of data structure is very quick.
For adding data in an ordered way that is easy to traverse (follow the path). Each node can only have 2 subsequent nodes, one greater and one less. If the data (key) is less than the current node, you look at the sub-node to the left. Greater to the right. When you get to the point there is no node, you add the data there, creating the node.
Code:
---------- k / \ d s / \ / \ b i p u / / \ h t z
If you are adding j you'd look at:
1) k, move down left (j < k)
2) d, move down right (j > d)
3) i, move down right (j > i)
4) no node there, so add j to the right of i
__________________

Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
  #3  
Old 16-Jan-2005, 20:23
Max Payne's Avatar
Max Payne Max Payne is offline
Regular Member
 
Join Date: Apr 2004
Location: 3° 08 North 101° 42 East
Posts: 332
Max Payne is a jewel in the roughMax Payne is a jewel in the roughMax Payne is a jewel in the rough
here is some example...

Stack - A deck of card in card games like poker or solitare, also used alot in language processing, simple example writing strings backward.

Queue - every message fired by a windows application is queued in the Windows Message Queue. or cars lining in a toll booth.

Binary Tree - decision tree in AI application (dining decision example), parentage tree, space partitioning in harddisk or a game I used to play before where you devide the space given in binary and trap the bouncing ball in the space to the samllest space.
__________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds
  #4  
Old 17-Jan-2005, 08:37
the_crazyman the_crazyman is offline
Awaiting Email Confirmation
 
Join Date: Apr 2004
Posts: 11
the_crazyman is on a distinguished road
cheers for the above

much appreciated and stored in the old brain matter.

Exam next week, will let you know how badly/well I do.
 
 

Recent GIDBlogToyota - 2008 November Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
INtime real time system usage Bernard Computer Software Forum - Windows 0 28-Jul-2004 05:11
list of the most common keyboard and mouse shortcuts for IE, Opera and Firebird jrobbio Computer Software Forum - Windows 2 04-Sep-2003 10:10
PHP/Apache memory usage issue bacchus Apache Web Server Forum 0 18-Aug-2003 13:57
[class] Generate Forms Without Using HTML! Elmseeker PHP Code Library 6 11-Mar-2003 13:05

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 06:21.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.