Group 1
Group 2
Group 3
Group 4
Group 5
© 2023 Vedesh Kungebeharry. All rights reserved.
© 2023 Vedesh Kungebeharry. All rights reserved.
Marks were assigned on 11th Jan 2023 for groups 1 and 2 and 22nd Jan 2023 for groups 3,4,5.
© 2023 Vedesh Kungebeharry. All rights reserved.
https://youtu.be/Kr8tyBU4SEg
© 2023 Vedesh Kungebeharry. All rights reserved.
See video below:
https://youtu.be/fiv75dM_VXE
© 2023 Vedesh Kungebeharry. All rights reserved.
There are several ways in which algorithms can be represented:
Narrative form is a way of representing an algorithm using a story or a sequence of events. This representation is often used to describe algorithms in a way that is easy for humans to understand, but it can be difficult to translate into a programming language.
For example, an algorithm for sorting a list of numbers could be represented in narrative form as follows:
Here is an example of an algorithm in narrative form that explains the steps for using a menu system to withdraw money from an ATM:
Narrative form is often used to describe algorithms in a way that is easy for humans to understand, but it is not as precise as other forms of representation, such as pseudocode or programming language.
Pseudocode is a way of representing an algorithm using a combination of natural language and programming language constructs. It is often used to represent algorithms in a way that is easy for humans to understand, but that can also be easily translated into a programming language.
Here is an example of pseudocode for calculating the simple interest on a loan:
START CalculateSimpleInterest(principal, rate, time)
INPUT: float principal, float rate, float time
OUTPUT: float interest
interest <- principal * rate * time
RETURN interest
END
This pseudocode represents an algorithm that calculates the simple interest on a loan given the principal amount, interest rate, and time period. It starts by calculating the interest as the product of the principal, rate, and time. It then returns the value of interest as the output of the algorithm.
In this pseudocode, principal, rate, and time are the input variables, and interest is the output variable. The keyword START indicates the start of the algorithm, and the keyword END indicates the end of the algorithm. The keyword INPUT specifies the input variables, and the keyword OUTPUT specifies the output variable. The keyword RETURN is used to return the output of the algorithm.
Flowchart symbols are graphical symbols used to represent different parts of an by showing the flow from one step to another. Here are some common flowchart symbols and their meanings:
Flowchart symbols are used to represent the different steps and decisions in an algorithm in a way that is easy for humans to understand and visualize. They are an important tool for representing algorithms and are widely used in a variety of fields.
Here is a table showing the advantages and disadvantages of algorithms represented in different forms:
Form | Advantages | Disadvantages |
Narrative | – Easy for humans to understand | – Not precise |
– Can be used to describe complex algorithms in an intuitive way | – Difficult to translate into a programming language | |
– Can be used to communicate algorithms to people who are not familiar with programming languages | ||
Pseudocode | – Easy for humans to understand | – Still, it is not a real programming language, so it may require some translation to be implemented in a computer program |
– Can be easily translated into a programming language | ||
– Allows for a high level of precision and detail | ||
Flowchart | – Easy for humans to understand and visualize | – May require more time and effort to create than pseudocode or narrative forms |
– Can be used to communicate algorithms to people who are not familiar with programming languages | – May not be as precise as pseudocode | |
– Can be helpful for understanding and debugging algorithms |
As you can see, each form of representation has its own advantages and disadvantages. The form that is most suitable for a given situation will depend on the needs and goals of the person representing the algorithm.
[1] TA-Note
Create a program that would repeatedly prompt the user for a mark and outputs the corresponding grade.
confirm= input ("\nWould you like to enter a grade? \n Y for Yes, any other key for no\n")
while (confirm.lower() =="y" ):
#processdata here
grade = float(input("please enter a mark\n\n"))
if (grade<50):
print("fail")
elif (grade<65):
print("D")
elif (grade<75):
print("C")
elif (grade<85):
print("B")
else:
print ("A")
#end dataprocessing
confirm= input ("\nWould you like to enter a grade? \n Y for Yes, any other key for no\n")
print("end")
confirm= input ("\nWould you like to enter a grade? \n Y for Yes, any other key for no\n")
while (confirm.lower() =="y" ):
#processdata here
grade = float(input("please enter a mark\n\n"))
if (0<=grade and grade<50):
print("fail")
if (50<=grade and grade<65):
print("D")
if (65<=grade and grade<75):
print("C")
if (75<=grade and grade<85):
print("B")
if (85<=grade and
ygrade<=100):
print ("A")
#end dataprocessing
confirm= input ("\nWould you like to enter a grade? \n Y for Yes, any other key for no\n")
print("end")
© 2022 Vedesh Kungebeharry. All rights reserved.
Algorithms are really intended as a blueprint for communication to programmers.
Problem Definition: A solution is needed to find the area of a circle given a radius.
Solution as a flowchart
Solution in pseudocode:
START //variable declaration float radius float area float pi = 3.14 //input print "Please enter a radius" input radius //processing area = pi * radius * radius //output print "The area is : ", area END
Actual program code in C:
#include <stdio.h>
#include <stdlib.h>
int main()
{
float radius, area;
const float pi = 3.14;
//input
printf ("Please enter a radius\n");
scanf("%f", &radius);
//processing
area = pi *radius *radius;
printf ("\nThe area is : %f", area);
return 0;
}
Notice how similar the pseudocode is to the actual coded solution.
© 2022 Vedesh Kungebeharry. All rights reserved.
Accept 5 numbers from a user and output the average.
(Files used in solution can be found here)
Note: The task requires bounded iteration, a while loop is not ideal in principle however it can be done.
© 2022 Vedesh Kungebeharry. All rights reserved.
Excel File
1. Download the attached Excel file and complete the tasks listed in the sheet TUTORIAL TASKS. The Tasks are to be completed in sheet 1. Note, these tasks must be accomplished in Microsoft Excel and not google sheets. (SEE ATTACHED VIDEO INSTRUCTIONS).
2. After accomplishing the tasks, save your work.
3. Rename your File in the format “Last name, First name – Excel Exam”
3. Attach this file to to assignment and turn in your submission before the deadline date.
https://youtu.be/YWw4rJDwKv0
© 2022 Vedesh Kungebeharry. All rights reserved.
https://youtu.be/HnudH-ApOoM
Students to follow along with the video, using Microsoft word to –
1. Enable the developer tab.
2. Create a fillable form
3. Create a submit button : Submit A word processing form Via email
Can you create a fillable form using google forms? Reproduce the fillable form from the example using google forms if you can.
Read and practise the example from Information Technology for CSEC – 3rd edition, Howard Campbell, pg 154-157.
© 2021 Vedesh Kungebeharry. All rights reserved.