|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Software Design > array algorithm help!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|