September 19, 2020, 11:17:09 pm

### AuthorTopic: SDD Help  (Read 313 times) Tweet Share

0 Members and 1 Guest are viewing this topic.

#### justin.ferreira

• Fresh Poster
• Posts: 2
• Respect: 0
##### SDD Help
« on: August 11, 2020, 01:03:52 pm »
0
Hello, Im currently studying SDD and its rather challenging. I'm enquiring about algorithms, as my trials are approaching next week. What are the best methods in-order to understand algorithms as a whole and recognise particular questions that suit various algorithms.

Thanks Justin

#### stylahex

• Fresh Poster
• Posts: 3
• :)
• Respect: +2
##### Re: SDD Help
« Reply #1 on: August 11, 2020, 02:11:08 pm »
0
When you say algorithms, I assume you're talking about the sorts? I.e selection, insertion, bubble etc.
2019 HSC [ Software Design and Development | 90 ]

2020 HSC (TBD) [ Eng ADV ] | [ Maths Stnd ] | [ Business Studies ] | [ Construction ]

#### justin.ferreira

• Fresh Poster
• Posts: 2
• Respect: 0
##### Re: SDD Help
« Reply #2 on: August 11, 2020, 05:01:52 pm »
0
When I'm mentioning algorithms I'm meaning the algorithms generally covered throughout the SDD syllabus

#### stylahex

• Fresh Poster
• Posts: 3
• :)
• Respect: +2
##### Re: SDD Help
« Reply #3 on: August 12, 2020, 10:42:09 am »
+5
Sure.

In general, the SDD syllabus mainly covers algorithms through
1. The forms in which they are represented.
2. Standard Algorithms.

In terms of how they are represented, in the syllabus, this refers to pseudocode, flowchart diagrams, EBNF and railroad diagrams. Understanding how these work and how to create them help to overall understand algorithms as a whole as these representations are often used to convert into actual code and vice versa.

With standard algorithms, i.e the five searches (selection, linear, bubble etc), these have code already provided in the course specifications or various textbooks (Samuel Davis / Heineman) You don't have to memorise these codes, as you can simply understand the concept through which the algorithm works and create your own based on that.

When I studied these algorithms, what I did was create a visual representation of the algorithm I'm trying to learn. For example, I would create a flowchart or a DFD or a railroad diagram of a, say a bubble sort, based on the algorithm provided through the course specifications. I would then convert this into my own code, in pseudocode. This encourages you to understand the process of the algorithm, as you need to in order to simplify it or create your own version of it.

With recognising particular questions and their suitability to certain algorithms, again it really comes down to your understanding of how various aspects of an algorithm works. If you really understand how they work, you'll be able to automatically pick up parts of the question that you can recognise as part of a standard algorithm and or determine the effectiveness/suitability of an algorithm to a question.

For example, in terms of sorts, a selection or insertion sort is inefficient in long arrays with lots of elements as these sorts go through each item in an array, either once or multiple times. Instead, a bubble sort a binary search is much more suited to longer arrays since it splits the array into two, and disregards the other half, provided that conditions are met.

There isn't really a "best' method for this. It really depends on how you learn. This is a method that worked for me, and I hope for you as well.

Resources I recommend:
Grok learning (If your school offers it)

« Last Edit: August 12, 2020, 02:16:54 pm by stylahex »
2019 HSC [ Software Design and Development | 90 ]

2020 HSC (TBD) [ Eng ADV ] | [ Maths Stnd ] | [ Business Studies ] | [ Construction ]

#### Justin_L

• MOTM: July 20
• Forum Regular
• Posts: 86
• Respect: +88
##### Re: SDD Help
« Reply #4 on: August 12, 2020, 11:55:03 am »
0
For example, in terms of sorts, a selection or insertion sort is inefficient in long arrays with lots of elements as these sorts go through each item in an array, either once or multiple times. Instead, a bubble sort is much faster since it splits the array into two, and disregards the other half, provided that conditions are met.

Hey!

Just wanted to add on, how can you tell between selection and insertion sort? I always get them mixed up, especially when you have to consider ascending and descending sort.

Also, I think that behaviour is for a binary search and not a bubble sort? But I think it's right that bubble sort is faster for large arrays.

#### stylahex

• Fresh Poster
• Posts: 3
• :)
• Respect: +2
##### Re: SDD Help
« Reply #5 on: August 12, 2020, 02:12:27 pm »
+4
Also, I think that behaviour is for a binary search and not a bubble sort? But I think it's right that bubble sort is faster for large arrays.

Oops! Yeah, you're right, I did mix up a binary search with bubble sort, my bad.

Just wanted to add on, how can you tell between selection and insertion sort? I always get them mixed up, especially when you have to consider ascending and descending sort.

In a selection sort, the array is split into two lists; a sorted and unsorted one. The sorted sublist is initially empty. The algorithm then iterates through the entire unsorted sublist to find the minimum, or maximum item depending on the sort order and then adds a new element at the end of the sorted array and this element is swapped with the element to be sorted. (next minimum or maximum item)

It then repeats this until the array is sorted.

The insertion sort is basically the same thing. It has an initial array, that splits into sorted and unsorted sublists. Initially, the sort determines the first element of the array as the only element of the sorted sublist while the rest are unsorted. At each iteration, the sort takes the first element of the unsorted list and 'inserts' it into place (sorting it) on the sorted sublist. This repeats until the unsorted list is empty, and hence the array is sorted.

TLDR, when sorting, the selection sort swaps elements, while the insertion sort takes an element that is unsorted and puts it in the correct position in a sorted list, shifting the elements of the array to the right to make space for that addition.

They're the same in every way except how they sort.

Code wise, a selection sort has the following:

Let Temp = A
Let A = B
Let B = Temp

Whereas an insertion sort does not.

In code, ascending and or descending sorting is determined by either a > or a <, in addition to the positions of the variables being compared.

Hope that helps, let me know if I got anything wrong / could be explained better

(See attached for gifs as a graphical representation of how the sorts work)
2019 HSC [ Software Design and Development | 90 ]

2020 HSC (TBD) [ Eng ADV ] | [ Maths Stnd ] | [ Business Studies ] | [ Construction ]

#### Justin_L

• MOTM: July 20
• Forum Regular
• Posts: 86
• Respect: +88
##### Re: SDD Help
« Reply #6 on: August 13, 2020, 09:05:27 pm »
+2
/snip

Ah right, that makes sense. Great tip about the swap code, that's a really nice way to quickly tell what sort of sort it is just from eyeballing the algorithm. Thanks!