Properties of an ADT

Properties of an ADT

An ADT must possess the following characteristics:[1]

1. the facility to create a container to hold the data;

2. the facility to add a new element to the container;

3. the facility to remove/delete an element which satisfies some

criterion form the container;

4. the facility to find an element which satisfies some criterion within

the container;

5. the facility to destroy the container when it is no longer required.


[1] (Caribbean Examinations Council Computer Science Syllabus, 2015, p. 83)

Video Series: Using Powerpoint presentation Software

These videos cover the main topics used for NCSE ICT for Presentation software.

Please watch these videos before attempting your assignments.

01 – Intro, Layout and Adding Slides – Presentation software

02 – Adding text and Viewing the Slideshow – Presentation software

03 – Inserting Shapes – Presentation software

04 – Inserting pictures – Presentation software

05 – Inserting Charts- Presentation software

06 – Animations – Presentation software

07 – Transitions and Conclusion – Presentation software

© 2020  Vedesh Kungebeharry. All rights reserved. 

Creating a website and choosing a design using wordpress.com

I created a video on creating a website using wordpress.com

Creating a wordpress site

These were the steps that were shown in the video:

  • Visit http://wordpress.com
  • Create an account OR login if you have an account already
  • Choose a free web domain
  • Choose and apply theme for your site
  • update your site’s name using the word press control panel
  • ensure that you verify your wordpress account.

© 2020  Vedesh Kungebeharry. All rights reserved. 

Presentation Software.

Presentation software is used to display information one slide at a time. The term “slide” can be thought of as a single poster used to display a small number of points or a single idea.  

Presentation software was made to mimic the behaviour of a traditional slide projector.

Many slides are displayed one at a time by the presenter. The presenter can include the following items on slides:

  • Text – including short points on the topic being presented.  Text is usually held within a Textbox.
  • Shapes – including pre defined  shapes e.g circle, square etc.
  • Images: users can insert downloaded images, or provided clip art.
  • Charts: the presentation software provides facilities for creating and inserting various chart types including bar, line, pie charts etc.
  • Animations – Objects can be set in motion on any slide. Objects include images, shapes, text boxes etc.
  • Transitions – Slides transform from one to the next in one smooth animation.

Example of presentation software are Microsoft Powerpoint  and Prezi.

Required reading :

 Students to study Presentations in a full context: http://www.teach-ict.com/gcse_new/software/presentation/miniweb/index.htm

© 2020 Vedesh Kungebeharry. All rights reserved

Linear search

Introduction

In a linear search, each element of the array is traversed by using iteration.  Each element in the traversal is compared against a search key. If the key is found, the location of the array index is returned.  If the entire array is traversed without finding the key, dummy value is returned (e.g. -1)

Linear search Algorithm and Implementation

Given a list of items of a finite size and a Key we traverse the list to find the key and output the location of the key(s) found in the list.

Consider the scenario where we have a list with unique items (in an array) and we wish to find a key.

Demonstration in flowgorithm:

(Download the Demonstration file here)

We set up an Real array of size 10  named “list” and initialized with the following values:

array named “list” of size 10 with data values

We could implement a function as shown below:

Linear search function

Below is an example of how the function can be used:

Using linear search on the array “list” with data.

Exercises

  1. Identify the sentinel variables in the LinearSearch function.

  2. Show the trace table for all variables found within linear search when the following function calls are made using the array “list” initialized in the figure 1 above:

    a) LinearSearch(10,list,300)
    b) LinearSearch(10,list,19)
    c) LinearSearch(2,list,19)

Hint:
Use the following trace table format:

StepsizekeySearchResulti
1    
2    
3    
4    
5    
  • Note that an optional column, called “step” is used to keep track of each variable change such that a step is considered to be any time  time a variable is initialized or changed.  
  • You do not need to show the list array.
  • Assume that no value is assigned during a variable declaration.
    E.g


will not be shown as a step in the trace table.

As an example, this table has been filled to the 4th step for part a) above.

StepsizekeySearchResulti
110   
2 300  
3  -1 
4   0
 5    
Example trace table

Updates

2022/02/03 –

Added introductory paragraph: “In a linear search, each …… is returned (e.g. -1)”

Added heading “linear search algorithm…..”

© 2020  Vedesh Kungebeharry. All rights reserved. 

Repetition (Iteration) Constructs

Consider the following example:

Find the sum of 10 numbers provided by the user.

This can be accomplished as follows:

The above solution is very long as well as difficult to understand , manipulate and communicate .

Observe that there were many repeated steps in obtaining input from the user.

The solution can be simplified by looping.

A general looping construct is shown below:

The solution can be simply implemented using looping:

Class Discussion: walk-through of solution is discussed.

This files used in this post can be downloaded here:

https://drive.google.com/drive/folders/1KjNcPQATyqh8quxnRjUDbJOgdzGvUY1P?usp=sharing

Homework:

Create an algorithm which uses repetition to output  the 12 times table from 1 to 12.

Updates

2022-10-6: Added files used in this post.

© 2020  Vedesh Kungebeharry. All rights reserved. 

The Selection Construct

Sometimes we wish to change the order of processing based on certain conditions.

This can be accomplished by using a selection construct pictured below:

We will examine this in the following example:

Jim is a salesman for an auto car company. If his total sales for the week exceeds $10000 he is rewarded a sales commission of 8 percent of the sale, if not he is awarded no commission.

Create a flowchart algorithm which accepts the total sales and outputs the commission.

Exercise:

The problem is modified such that  if the total sales were less than $10000 he would receive a commission of 4 percent. See changes below:

Jim is a salesman for an auto car company. If his total sales for the week exceeds $10000 he is rewarded a sales commission of 8 percent of the total sales, if not he is awarded a commission of 4 percent.

Create a flowchart algorithm which accepts the total sales and outputs the commission.

Draw a flowchart for the modified scenario.

© 2020  Vedesh Kungebeharry. All rights reserved. 

Algorithms In Narrative Form

An algorithm in narrative form is not written in discrete steps.   It is expressed as directions in paragraph form and instructions on how rules should be followed.

An algorithm in narrative form can be considered a precursor to pseudocode or a flowchart

Example

An example is given below for the given problem statement

Problem Definition: A solution is needed which finds the circumference of a circle.

Algorithm in narrative form: Prompt the user to enter a non-negative value for the radius and store it. If the radius entered is negative or is not a number, keep on prompting the user and accept values until a suitable value is entered.  Use the formula C=2*3.14* r to calculate and store the circumference. Output the circumference to the user and stop processing.

In class exercise

Write an algorithm in narrative form which gives instructions/directions on how to follow the rules in order to play “Snakes and ladders”.

© 2020  Vedesh Kungebeharry. All rights reserved.