Software Marathon 2011 (1 Viewer)

COLDBOY

Member
Joined
Sep 23, 2009
Messages
79
Gender
Male
HSC
2011
did they change the layout of the exam paper this year?
 

MrBrightside

Brightest Member
Joined
Jan 18, 2010
Messages
2,033
Gender
Undisclosed
HSC
N/A
Hi all, What does NoOfCharacters mean in Delete String Algorithm?

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
And more specifically what does the line WHILE Index <= OriginalStringLength – NoOfCharacters mean?
 

soccer16

Member
Joined
Aug 24, 2011
Messages
30
Gender
Male
HSC
2011
Hi all, What does NoOfCharacters mean in Delete String Algorithm?

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
And more specifically what does the line WHILE Index <= OriginalStringLength – NoOfCharacters mean?

quickly went through it. It seems like NoOfCharacters is a value of how many characters will be removed from a certain string (In this case, whatever "originalString" equals. For example, an originalString with a value of "Shirt" and a NoOfCharacters with a value of 2 parsed through that function would result in "irt". This is of course expected if StartPosition equals 1. Otherwise, it could be "Srt" or "shi" or any other combination.

To answer your second question, "Index" will act as a counter beginning at what value "StartPosition" equals in the string "originalString". The pre-loop will check the index against the length of the original string minus the value of "NoOfCharacters" (which holds how many characters will be removed". For example, a "originalString" value of 10, a "NoOfCharacters" value of 3 and a figurative incremental value of 4 for index would result in:

Code:
4 <= (10 + 3)
4 <=13
Which is true, so it'd continue.

It's 5am, I might be wrong. Doubt it though

EDIT: yeah, no i'm right. Do you have any harder questions?
 

freelife

New Member
Joined
Apr 16, 2010
Messages
3
Gender
Male
HSC
2011
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.
 

_pizza

Member
Joined
Mar 31, 2011
Messages
37
Location
Space
Gender
Male
HSC
N/A
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.
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.
 

MrBrightside

Brightest Member
Joined
Jan 18, 2010
Messages
2,033
Gender
Undisclosed
HSC
N/A
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.
This.

Also for the Evolution of programming languages option topic:

What's the difference between encapsulation and polymorphism.
 

SpiralFlex

Well-Known Member
Joined
Dec 18, 2010
Messages
6,960
Gender
Female
HSC
N/A
Just wanted to pop by and say,

Good luck on Thursday guys!
 

_pizza

Member
Joined
Mar 31, 2011
Messages
37
Location
Space
Gender
Male
HSC
N/A
Just wanted to pop by and say,

Good luck on Thursday guys!
Cheers! And good luck to you with your post-HSC relaxation! ;)

Hope there's lots of algorithms... and in option 2, some complex logic gates.
 

MrBrightside

Brightest Member
Joined
Jan 18, 2010
Messages
2,033
Gender
Undisclosed
HSC
N/A
Does the insertion sort only work if the first index is 1? and NOT 0
 

_pizza

Member
Joined
Mar 31, 2011
Messages
37
Location
Space
Gender
Male
HSC
N/A
Does the insertion sort only work if the first index is 1? and NOT 0
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.
 
Last edited:

MrBrightside

Brightest Member
Joined
Jan 18, 2010
Messages
2,033
Gender
Undisclosed
HSC
N/A
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.
Yeah thanks. I was thinking that NextPosition had to be Last - 2
 

Reikira

Member
Joined
Mar 8, 2010
Messages
68
Gender
Male
HSC
2012
LOL! Made my night.

Also: 1
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..
 

Clarky13

New Member
Joined
Sep 5, 2010
Messages
27
Gender
Male
HSC
2011
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..
Don't worry. I just spent the whole day relearning the course.
 

MrBrightside

Brightest Member
Joined
Jan 18, 2010
Messages
2,033
Gender
Undisclosed
HSC
N/A
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.
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
 

_pizza

Member
Joined
Mar 31, 2011
Messages
37
Location
Space
Gender
Male
HSC
N/A
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
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 :D.

Best of luck everyone, and I'll prob come discuss the exam at 5.
 

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

Top