COVID CSEC IT Contingency!

Hello Students! ‌ I hope all is well with you and your families.


‌ In order to keep prepared, I’ll be posting some resources and directions via Edmodo (and here on island class). ‌

During COVID Oxford international press has made all Caribbean CSEC books freely available via this link: https://global.oup.com/education/support-learning-anywhere/key-resources-online/?region=international&utm_campaign=learninganywhere&utm_source=umbraco&utm_medium=display&utm_content=support_learning_key_resources&utm_team=int

Just scroll down until you find the section for “Caribbean”.


These books are only available for a limited time. ‌ The book we need to use is available via this link : https://en.calameo.com/read/000777721de16be0f6397?authid=WDfoYvs1wwLH&region=international

Alternatively, you can purchase a pdf copy of Information Technology for CSEC Examinations 3rd Edition here: https://macmillancaribbeanebooks.com/information-technology-for-csce-examinations-3rd-edition-pdf.html

CONTINUING OUR STUDIES

Oxford Information Technology for CSEC Third edition: We continue with pages 138 to 150. ‌

Information Technology for CSCE Examinations 3rd Edition: We continue with pages 161 to 176 ‌ ‌

Please read these pages if you can in order to continue with you studies during this week. ‌ ‌ ‌

As you know, school is currently closed. You are not required to read the information above. However, I feel like the majority of students will at least give it a try as long as your personal situation is comfortable for you to make that attempt.


‌ For those of you who cannot read the notes at this point in time, do not worry!!! ‌

When school officially restarts, we will definitely cover the content. In the meantime, keep safe and keep your mind engaged!

© 2020 Vedesh Kungebeharry. All rights reserved

Stacks

A stack consists of a collection of items which analogous to  a real world stack of items stored on a desktop.

Discussion: Scenario of a traditional Inbox pile where new items are placed on the top of the stack. (Simalarity to: a/an

 Instagram feed

Cargo entering a ships container palate by palate, filled to capacity which must be processed by customs at the destination port.

Washing dishes collected after dinner.

)

  1. Characteristics of a Stack
  2. Coded example
    1. Stack.h
    2. Stack.c
    3. Main.c
  3. Updates to this post

Characteristics of a Stack

Form our discussion. We see that in a real life stack, the most recent item to enter the stack is the first to be processed and leave the stack.

We say that the Last item In is the First item Out (LIFO)

The stack ADT consists of a collection of items and an integer which keeps track of the size of the stack. 

The stack  supports the following operations:

OperationExplanation
Push(…)Adds an item to the top of the stack and returns the size of the stack. If an error occurs, return a negative number
Peek()Return the data at the top of the stack
Pop(…)Removes and Returns the item at the top of the stack, keeping track of the size.
IsEmpty()Returns true if the stack is empty, i.e, size==0

NB, When using a stack, the programmer only has access to the item stored at the top/head of the stack at any given point in time. The programmer is unable to access any other data that is stored under the top.

The top of the stack is also referred to as the head of the stack.

Coded example

Stack.h

#include <stdbool.h>
#ifndef STACK_H_INCLUDED
#define STACK_H_INCLUDED

//push data if the stack is not full
bool push(int newData);

//returns the +ve integer at the 
//top of the stack or -1 if the stack is empty
int peek();

//Removes and returns the +ve integer at the 
//top of the stack or -1 if the stack is empty
int pop();

//returns the current size of the stack
int size();

//returns true if the stack is empty
bool isEmpty();


#endif // STACK_H_INCLUDED

Stack.c

#include <stdbool.h>
#include <stdio.h>
#define MAX_SIZE 10
#include "Stack.h"

int stackData[MAX_SIZE];
int sizeOfStack = 0;

bool push(int newData)
{

    if(sizeOfStack==MAX_SIZE)
    {
        puts("ERROR: Tried to push to a full stack. Operation failed\n");
        return false;
    }
    else
    {
        stackData[sizeOfStack]=newData;//add data to the next available location
        sizeOfStack++;//increment size
        return true;
    }



}

int peek()
{
    if(isEmpty())
    {
        puts("ERROR: Tried to peek at an empty stack. -999999 returned as result\n");
        return-999999;
    }

    else
        return stackData[sizeOfStack-1];//return item at the top of the stack
}

int pop()
{
    if(isEmpty())
    {
        puts("ERROR: Tried to pop an empty stack. -999999 returned as result\n");
        return -999999;
    }
    else
    {
        int result = stackData[sizeOfStack-1];//return item at the top of the stack
        sizeOfStack--;//reduce size
        return result;
    }

}

int size()
{
    return sizeOfStack;
}

bool isEmpty()
{
    return sizeOfStack==0;
}


Main.c

#include <stdio.h>
#include <stdlib.h>
#include "Stack.h"
int main()
{
    //stack demo
    //try peeing at empty stack
    printf("%d\n",peek());

    //push 100,200,...,1000,1100 (push 11 numbers, 10 should be pushed, 1100 will not be pushed
    push(100);
    printf("%d\n",peek());
    push(200);
    printf("%d\n",peek());
    push(300);
    printf("%d\n",peek());
    push(400);
    printf("%d\n",peek());
    push(500);
    printf("%d\n",peek());
    push(600);
    printf("%d\n",peek());
    push(700);
    printf("%d\n",peek());
    push(800);
    printf("%d\n",peek());
    push(900);
    printf("%d\n",peek());
    push(1000);
    printf("%d\n",peek());
    push(1100);
    printf("%d\n",peek());

    //try displaying the size and popping 11 times.
    //failure expected on the 11th time.
    printf("Size, Pop\n");
    printf("%d\n",size());
    printf("%d\n",pop());
    printf("\n\n");
    printf("Size, Pop\n");
    printf("%d\n",size());
    printf("%d\n",pop());
    printf("\n\n");
    printf("Size, Pop\n");
    printf("%d\n",size());
    printf("%d\n",pop());
    printf("\n\n");
    printf("Size, Pop\n");
    printf("%d\n",size());
    printf("%d\n",pop());
    printf("\n\n");
    printf("Size, Pop\n");
    printf("%d\n",size());
    printf("%d\n",pop());
    printf("\n\n");
    printf("Size, Pop\n");
    printf("%d\n",size());
    printf("%d\n",pop());
    printf("\n\n");
    printf("Size, Pop\n");
    printf("%d\n",size());
    printf("%d\n",pop());
    printf("\n\n");
    printf("Size, Pop\n");
    printf("%d\n",size());
    printf("%d\n",pop());
    printf("\n\n");
    printf("Size, Pop\n");
    printf("%d\n",size());
    printf("%d\n",pop());
    printf("\n\n");
    printf("Size, Pop\n");
    printf("%d\n",size());
    printf("%d\n",pop());
    printf("\n\n");
    printf("Size, Pop\n");
    printf("%d\n",size());
    printf("%d\n",pop());
    printf("\n\n");


    return 0;
}

Updates to this post

11th June 2024 –

1. Added Table of Contents

    2. changed :

    The stack ADT consists of a collection of items and an integer which keeps track of the size of the stack. 

    to:

    STATE
    The stack ADT consists of a collection of items and two integers,
    top – used to keep track of the top of stack, and
    size which keeps track of the size of the stack.

    BEHAVIOUR
    The stack supports the following operations:.....

    © 2020 Vedesh Kungebeharry. All rights reserved

    Abstract Data Types

    Previously we’ve dealt with primitive datatypes  in C. 

    Examples of some primitive data types are shown below:

    Data TypeExample
    integer int a=5;
    Floating point numbersfloat a=5.1;
    Characterchar input =’q’;

    In this case we see that only one item of data is stored per variable declared.

    Abstract Data Types  (ADTs)  store collections of data  and are accompanied by functions which perform operations on the data.

    They are created for use by programmers who in turn manipulate the data collection by use of the provided functions. The programmer using the ADT is never expected to directly manipulate the collection of data.

    ADTs are used to model collections of data in real world scenarios.

    An ADT consists of  :

    State- The container of items itself, information about the container of items e.g the size, a reference to the first item in the  list etc

    Behaviour – The operations that can be performed on the collection of data. Usually adding and/or, updating, and/or removing items.

    The array is the considered to be a basic abstract data type that was formalized to use indexing during the development of high level languages. supporting programs were built to allow for the creation and management of data access to arrays.

    If you’ve previously created c structures and managed their use through functions then you’ve created a specialized ADT. For example, our book catalog is an ADT.

    A seemingly unlikely ADT example: The array

    Even though assignment and retrieval of data in array seems trivial and is supported by basic syntax as with other primitive data types; this was not the case during the early development of programming languages.

    High level programming languages were modified so that arrays could use the basic syntax of variable declaration, initialization, assignment and access because of their expected widespread use.

    Updates to this post

    • 4th June 2024 –
      -Added “Updates to this post” as a section
    • Updated on 17/9/2020.

    © 2018Vedesh Kungebeharry. All rights reserved.

    Submit A word processing form Via email

    Creating a button to submit a  Word processing Form as an email Attachment

    • From the developer tab select Command Button:
    • Change the button’s name:
      • Right click on the button and select edit:
    • The button text now becomes editable, change it to what best describes the button. In this case, the text was changed to “Save Document and Send via Email”:


    (The text was too long, so the button was widened to display all text.)

    Set up the button to send the email when clicked:

    • Right Click the button and choose view code:

    A visual basic window will popup. This gives a place to put some code that will be executed when the button is clicked


    • Place the following code:


          Options.SendMailAttach = True
          ActiveDocument.SendMail

      Such that it is within the button click sub routine:
    • You may now close the Visual Basic window.
    • Now , when the button is clicked, you computer’s default mail client will be opened with the form attached for sending via email.

    Note that the method above does not allow for setting a recipient’s address in the opened mail client.  If you would like to specify a recipient  address and email subject, use the following code within the click subroutine:

    Activedocument.HasRoutingSlip = True
    With Activedocument.RoutingSlip
    .Subject = "New subject goes here"
    .AddRecipient "Firstaddress@Mail.com"
    .AddRecipient "Secondaddress@Mail.com"
    .Delivery = wdAllAtOnce
    End With
    Activedocument.Route
    


    © 2020 Vedesh Kungebeharry.  All rights reserved.


    Stages in problem solving

    Problem Definition

    This is a precise and concise definition of a problem stating what needs to happen to transform from the current state of things to the desired future state. The problem definition should address the inputs to the problem and the desired outcome.

    Problem Analysis

    We determine:

    Input

    • what data needs to be recorded/managed by our solution;

    Processing

    • What events need to occur during the use of the solution,
    • the rules for manipulating/processing the data in our solution;

    Output

    • and what data and files our solution needs to deliver to the end user and save for future use.

    Identify and evaluate possible solutions

    Multiple approaches may be used to solve the problem, thus many solutions may be generated.

    Identify and evaluate possible solutions

    Multiple approaches may be used to solve the problem, thus many solutions may be generated. Each solution’s comparative strength and weakness is documented at this point.

    Select and justify the optimal solutions;

    Of all solutions generated, we select the one which is most optimal and best suited to solve the problem.

    The optimal solution is chosen based on criteria which point to the most efficient solution based on speed, storage capacity and generally how good the solution is suited against the problem statement/definition.

    A detailed algorithm of the best solution is the output of the process.

    Implementation and review

    Implementation: The algorithm is implemented in code and placed in the environment of its intended and made accessible to users.

    Review : To determine any unforeseen issues:

    • The implementation is observed in its environment. 
    • Feedback is elicited from users.

    After the initial review phase, any major issues are fixed. 

    We compare our solution back to our original problem statement to verify the problem has indeed been solved.

    Implementation Review then continues in the form of maintenance  where additional feedback is gathered to improve the solution which is implemented at a reasonable future date.

    Summary

    Problem definition – A concise definition of the problem is made which decribes what the future solution should do

    problem analysis – determine all details that are needed to solve the problem, e.g processes, procedures, data etc.

    Identify and evaluate possible solutions – generate many solutions and learn each solutions strength and weaknesses compared to each other.

    Select and justify the optimal solutions – choose the optimal solution based on criteria which point to the most efficient solution based on speed and storage capacity.

    Implementation and review – the solution is created and reviewed to determine any issues that prevents it from solving the problem. The issues, if any are fixed so that the problem is now completely solved.

    © 2020 Vedesh Kungebeharry.  All rights reserved.

    CAPE 2012 U1 Q3 Solution

    2012 U1 Q3

    Part A

    Algorithms are used to solve computational problems and are a technique for precisely documenting the solution.

    Part B


    i) Bounded, since the number of iterations are constant every time the algorithm is applied. In this case, the loop is executed 16 times.

    ii) Unbounded, since the number of iterations is not set and is dependent on the value of a sentinel variable, in this case X     

    Part C) 

    START
    rcount, bcount,gcount,ncount <--0
    for i<-- 1 to 150 do
    	input vote
    	if (vote = "red") then
    		rcount++
    	else if (vote = "green") then
    		gcount++
    	else if (vote = "blue") then
    		bcount++
    	else
    		ncount++
    	endif
    endfor
    
    output "total votes for color  = " + rcount+gcount+bcount
    output rcount " voted for red"
    output bcount " voted for blue"
    output gcount " voted for green"
    END
    
    

    Part d

    (Flowgorithm file here: https://drive.google.com/drive/folders/1pazPgOeE2OA75OPIpUScROX302NyBhrX?usp=drive_link)

    Alternatively, in Pseudocode:

    © 2020  Vedesh Kungebeharry. All rights reserved.

    Mail Merge

    A mail merge is the term used when a database of recipients and other fields are placed (or merged) onto a template letter to produce a mass mailing.

    Basically , a template document is created using a list of names. e.g:

    Template Document (Primary Document)

    List of names (Data source or Secondary Document)

    Steps to create a mail merge

    These steps vary silghtly from version to version of microsoft word, but the principle is the same. In this case, I’m using the version of microsoft word as current as January 2020.

    1. Create a new document
    2. write and format the basic idea for your letter
    3. save your document. This document is your Primary Document (Template).
    4. Click on Mailings -> Select recipients -> Type new list.
    5. Use the “New Entry” button to add new records. Add as many as you need.
    6. Click on “ok”. Save your list. This document is your secondary document (Data Source).
    7. Finally, from the mailings ribbon, click on Finish and merge -> Edit individual documents. This creates a new document from the previous two. This document is your Merged document (Mass mailing).

    Thats it!

    © 2020  Vedesh Kungebeharry. All rights reserved.