Yes, as of this year.did they change the layout of the exam paper this year?
BEGIN DeleteString(StartPosition, NoOfCharacters)
Index = StartPosition
OriginalStringLength = StringLength(OriginalString)
WHILE Index <= OriginalStringLength – NoOfCharacters
{Overwrites elements to be deleted}
OriginalString[Index] = OriginalString[Index + NoOfCharacters]
Increment Index
ENDWHILE
WHILE Index <= OriginalStringLength
OriginalString[Index] = “”
{Clear contents of these elements}
Increment Index
ENDWHILE
{The original string will now be NoOfCharacters Shorter}
END DeleteString
Hi all, What does NoOfCharacters mean in Delete String Algorithm?
And more specifically what does the line WHILE Index <= OriginalStringLength – NoOfCharacters mean?Code:BEGIN DeleteString(StartPosition, NoOfCharacters) Index = StartPosition OriginalStringLength = StringLength(OriginalString) WHILE Index <= OriginalStringLength – NoOfCharacters {Overwrites elements to be deleted} OriginalString[Index] = OriginalString[Index + NoOfCharacters] Increment Index ENDWHILE WHILE Index <= OriginalStringLength OriginalString[Index] = “” {Clear contents of these elements} Increment Index ENDWHILE {The original string will now be NoOfCharacters Shorter} END DeleteString
4 <= (10 + 3)
4 <=13
Yes, those are examples of libraries. A library is simply a collection of modules that can be imported into a project and reused. Programmers often have their own libraries of functions they have made over the years. This is one of the reasons it is important to write code using parameters and local variables, so that the module may be independent from the rest of the system and can be reused in later projects.hey guys,
im not quite sure about library routines, can someone tell me what they are? are they the functions used in software solutions like vb that have been predefined?
Cheers.
This.Yes, those are examples of libraries. A library is simply a collection of modules that can be imported into a project and reused. Programmers often have their own libraries of functions they have made over the years. This is one of the reasons it is important to write code using parameters and local variables, so that the module may be independent from the rest of the system and can be reused in later projects.
Cheers! And good luck to you with your post-HSC relaxation!Just wanted to pop by and say,
Good luck on Thursday guys!
It can be modified to work with the first index being 0. You just have to take it into account in the main while loop. I'm not sure which version you're used to, but with the insertion sort I use the process of insertion repeats while endUnsorted > 0. If the first index was 0 and not 1, you'd change that line to: while endUnsorted >= 0, so that the leftmost element wouldn't be left out. Apart from that, the remaining process should be identical.Does the insertion sort only work if the first index is 1? and NOT 0
Yeah thanks. I was thinking that NextPosition had to be Last - 2It can be modified to work with the first index being 0. You just have to take it into account in the main while loop. I'm not sure which version you're used to, but with the insertion sort I use the process of insertion repeats while endUnsorted > 0. If the first index was 0 and not 1, you'd change that line to: while endUnsorted >= 0, so that the leftmost element wouldn't be left out. Apart from that, the remaining process should be identical.
Oh and also, you'd start the insertion process with endUnsorted = theArray(length-2). Usually starts with length-1, which means the final element is assumed to be sorted, but since index starts at 0, the length of the array would already be 1 more than the final index.
Eg.
theArray[0] = 4,
theArray[1] = 2,
theArray[2] = 5,
theArray[3] = 7.
To assume that theArray[3] (the FOURTH element of the array) is already sorted, we have to start our insertion process with endUnsorted = theArray[2].
Length of theArray is 4, but if we were to reference theArray(length-1) it would access theArray[3], which is the final element. This would cause an error in the insertion stage, as the algorithm would attempt to access theArray[5].
Hope this is helpful.
LOL! Made my night.How ready are you guys feeling from a scale of 0 to 1?
Sigh, i wish i was as prepared as you.LOL! Made my night.
Also: 1
Don't worry. I just spent the whole day relearning the course.Sigh, i wish i was as prepared as you.
My teacher doesnt teach shit, so im just basicly doing the whole course on my own..which is hard..
Nah I think I just need to make NextPosition = last - 2.It can be modified to work with the first index being 0. You just have to take it into account in the main while loop. I'm not sure which version you're used to, but with the insertion sort I use the process of insertion repeats while endUnsorted > 0. If the first index was 0 and not 1, you'd change that line to: while endUnsorted >= 0, so that the leftmost element wouldn't be left out. Apart from that, the remaining process should be identical.
Oh and also, you'd start the insertion process with endUnsorted = theArray(length-2). Usually starts with length-1, which means the final element is assumed to be sorted, but since index starts at 0, the length of the array would already be 1 more than the final index.
Eg.
theArray[0] = 4,
theArray[1] = 2,
theArray[2] = 5,
theArray[3] = 7.
To assume that theArray[3] (the FOURTH element of the array) is already sorted, we have to start our insertion process with endUnsorted = theArray[2].
Length of theArray is 4, but if we were to reference theArray(length-1) it would access theArray[3], which is the final element. This would cause an error in the insertion stage, as the algorithm would attempt to access theArray[5].
Hope this is helpful.
BEGIN InsertionSort
Set First to First Position
Set Last to Array.Length
Set NextPosition to Last – 1
WHILE NextPosition >= First
NextItem = Array[NextPosition]
Current = NextPosition
WHILE (Current < Last) AND (NextItem > Array[current + 1])
{Shuffle sorted part along}
Increment Current
Array[Current-1] = Array[Current]
ENDWHILE
Array[Current] = NextItem
Decrement NextPosition
ENDWHILE
END InsertionSort
1How ready are you guys feeling from a scale of 0 to 1?
Yeah if you use a 'first' variable it doesn't change, I use constants for those values though unless otherwise specified so that alteration made sense to me .Nah I think I just need to make NextPosition = last - 2.
My Algo:
Code:BEGIN InsertionSort Set First to First Position Set Last to Array.Length Set NextPosition to Last – 1 WHILE NextPosition >= First NextItem = Array[NextPosition] Current = NextPosition WHILE (Current < Last) AND (NextItem > Array[current + 1]) {Shuffle sorted part along} Increment Current Array[Current-1] = Array[Current] ENDWHILE Array[Current] = NextItem Decrement NextPosition ENDWHILE END InsertionSort
No. You should come out with me tonight.Best of luck everyone, and I'll prob come discuss the exam at 5.