Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 20th, 2004, 02:22 AM
mahd mahd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 2 mahd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
array algorithm help!!

hello there..

i have this algorithm and i'm trying to find a direction in solving it..

L, R and Data are one-dimensional arrays. each with 5 elements numbered from 1 to 5. the contents of the three arrays are shown below.

L R Data
1 2 3 DOG
2 0 4 BEAR
3 5 0 HORSE
4 0 0 CAT
5 0 0 GIRAFFE

in these arrays L(3) contains the number 5, R(2) contains the number 4 and Data(1) contains the data DOG.

this is the algorithm..

T = 0
P = 1
REPEAT
WHILE P < > 0 DO
T = T + 1
S(T) = P
END WHILE
IF T > 0 THEN
FINISHED = FALSE
P = S(T)
T = T - 1
OUTPUT DATA(P)
P = R(P)
ELSE
FINISHED = TRUE
END IF
UNTIL FINISHED
EXIT

and have to trace the table below. it is only necessary to enter values in the table when they change.

T P S(1) S(2) Finished Output
0 1
1 1
2
2 2
0 FALSE
2

thats it..and i'll be gratefull for any help
bye all

Reply With Quote
  #2  
Old March 20th, 2004, 02:34 AM
mahd mahd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 2 mahd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hello again..

sorry but the last table was posted wrong
here it is again..

T P S(1) S(2) Finished Output
0 1 - - - -
1 - 1 - - -
- 2 - - - -
2 - - 2 - -
- 0 - - FALSE -
- 2 - - - -

i have to complete the trace table. it is only necessary to enter values in the table when they change. i should work from left to right and top to bottom. the first six lines are completed.

thanx again

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > array algorithm help!!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT