• YOU can help the next generation of students in the community!
    Share your trial papers and notes on our Notes & Resources page

Algorithms... (1 Viewer)

Freedom_Dragon

The 36th Dragon
Joined
Oct 11, 2003
Messages
154
Location
Behind a door that will never open.
Gender
Undisclosed
HSC
N/A
Seraph said:
now if i wanted to extract COMP
Start - 1 is out of the array.....
Using the example [C][O][M][P][T][E][R].

Now u wanted to extract [C][O][M][P].
U dont need "Start-1".
U know that ur "Start" is [C] which is the first "1" element of the string.
U know that ur "Finish" is [P] which is the fourth "4" element of the string.
Simply apply:

Function Extract (Xstring, Start, Finish)
Index=1
FOR Position=Start TO Finish //Start is "1" & Finish is "4" of the extract
Newstring(Index)=Xstring(Position)
Index=Index+1 //Increments index of Newstring
ENDFOR
Newstring=Extract
END Extract

U can extract anything, anywhere.

The time when u would use "Start-1" is when the deletion occur is greater than the first element.

If u wanted to delete [C][O][M][P] from [C][O][M][P][T][E][R]
I guess u would jus perform an extract instead.
Start=5
Finish=8
 

Seraph

Now You've done it.......
Joined
Sep 26, 2003
Messages
897
Gender
Male
HSC
N/A
ahhh of course. yea i could just extract the end :p

ARGH
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top