Login

Welcome, Guest. Please login or register.

March 30, 2024, 12:13:39 am

Author Topic: SDD Skills - An Approach to Algorithms  (Read 3499 times)  Share 

0 Members and 1 Guest are viewing this topic.

Justin_L

  • MOTM: July 20
  • Moderator
  • Trendsetter
  • *****
  • Posts: 190
  • Respect: +235
SDD Skills - An Approach to Algorithms
« on: June 01, 2021, 10:22:16 pm »
+9
SDD Skills: An Approach to Algorithm Questions

In the first article of the SSD skills series, we’ll be looking at how to approach algorithm questions in the HSC Software Exam!

Algorithm questions are an integral part of every software exam, and are often high value questions with multiple parts. These questions can generally broken down into two main sections: The scenario and the specification.

Question Layout: (*Adapted from Q27 2020 HSC SDD Exam)

An example scenario may be something like this, and is generally followed up by a few sub questions to test your system design knowledge:

Quote
Question 1 (12 Marks)
AN Co. is looking to develop a booking system to allocate seating to their holiday HSC lectures in a safe, socially distanced way.

These questions will often contain sub questions which add additional detail and test your system design skills, for example:

Quote
Question 27a (3 marks)
The next lecture is to be held in July. AN Co. would like to consult with student focus groups on the design of the user interface, with ease of use being a priority.
Propose an appropriate software development approach for the system and justify your choice.


This article won't be covering software development approaches and system design, but it’s useful to have this extra context to inform what the markers expect of you.

After establishing context and some system modelling, algorithm questions will generally give you a specification for which to design your algorithm:

Quote
Question 27c (5 marks)
The booking and seat allocation module needs to fulfill these requirements.

The audience is to be seated in 15 rows of 12 seats.

The user should be asked to select a seat. If the seat is already allocated, an appropriate message should be displayed and the booking process restarted.

Seats should be socially distanced. If the seat is directly beside, in front, or behind is allocated, an appropriate message should be displayed and the booking process restarted.

If the seat is successfully allocated, output the allocated seat number and booking number.

A diagram has been provided showing the seating plan represented as a 2-dimensional  array. Column 0 contains the letters A to M. Row 0 contains the numbers 1 to 12. An ‘X’ indicates that the seat has already been allocated.


But First: Pseudocode or Flowchart?
To represent your algorithm, NESA has provided two standardised frameworks for you to choose from: Pseudocode or Flowchart. While you can choose to represent your algorithm in another language or framework of your choice (eg. Python, Java, etc) there is no guarantee your HSC marker will understand the syntax and is not recommended unless you have no other option.

Pseudocode is NESA’s own syntax for writing algorithms and is specific to the HSC SDD course. It can be a bit confusing to initially learn as it isn’t based on any one programming language (as NESA intended the course to be language agnostic), but works essentially the same manner as a standard programming language and is much more reflective of programming outside of this course.

Flowcharts offer a visual way to represent programs, and are much more intuitive as an introduction to algorithms. While it can be helpful to understand algorithms and see them in a visual way, I would recommend against using it in an exam unless specifically asked of you. This is because Pseudocode is much faster to write and more compact, which gives you a massive advantage under exam conditions.


Solving an Algorithm Question
Finally, the fun part! My approach to these questions to read the question. Then read it again.

Understanding the specification is half the challenge, and you don’t want to be halfway through your program before realising you’ve solved the wrong problem (Surprisingly common under exam stress).

There will often also be hints in the way things are written – for example, the question mentions a 2 dimensional array, which is the most appropriate data structure to work with in this instance!

Next, we can begin to break down the problem. I generally like to break programs down into subprograms, then write the mainline of the program. For example:

 BEGIN SeatBooking
   Get SeatNumber
   Let SeatValid = true
   
   // Check if seat is already booked
   IF SeatTaken(SeatNumber) == true THEN
      SeatValid = false
      Display “Seat Taken! Try Again.”
      SeatBooking() // Run program again
   ENDIF

   // Check if neighboring seats are booked
   IF SociallyDistanced(SeatNumber) == false THEN
      SeatValid = false
      Display “Seat not available! Try Again”
      SeatBooking() // Run program again
   ENDIF
   
   // If seat is valid, book seat and return seat number
   IF SeatValid == true THEN
      BookSeat(SeatNumber)
      Display “Booking Successful! Your Seat Number is “ + SeatNumber
   ENDIF
END SeatBooking

In this case, I’ve interpreted the specification and broken it down into 3 main subtasks: Check if a seat is booked, check if a neighboring seat is booked, and booking the seat.

I’ve written a mainline which runs through the basic sequence of events and provides a high level overview to the marker of how I’m solving the problem.

In this case, I’ve chosen to include comments (denoted by the //) to even more explicitly link what I’m doing to the specification.

I’ve also explicitly stated the I’m calling SeatBooking from inside the program to run it again using recursion as this isn’t strictly taught within the Software course and can be a point of confusion. While style isn’t a major consideration given exam conditions, you should still try your best to use whitespace and legible handwriting to make it as easy as possible for the marker to understand your intentions and give you the marks you deserve!

Now, it’s just a matter of writing the subprograms. This approach to development is called a top down development approach, and is the method I used to approach algorithms during my HSC, giving me near full marks for this type of question.

If you want to have a go at implementing the subprograms for this algorithms, feel free to post them below and I’ll provide feedback to any solutions or questions.

Otherwise, check out some of the other articles in the SDD Skills Series from the main thread here!

FAQs:
Does the specific syntax of pseudocode matter in an exam?
« Last Edit: June 18, 2021, 08:35:58 pm by Justin_L »
Да здравствует революция государственного модератора