[go: up one dir, main page]

0% found this document useful (0 votes)
23 views117 pages

Computer Science DP1 HL SL

Uploaded by

yaminioak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views117 pages

Computer Science DP1 HL SL

Uploaded by

yaminioak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 117

2021

IBDP COMPUTER SCIENCE

Biswajit Dey
Choithram International School
Computer Science in DP
A little brush up….
Computer Science….the beginning of a new era…..

Before getting into the details of this branch of science one must know what a computer is and what
science is and how it is collaborated with each other to create computer science.

“Computer an electronic device which is capable of receiving information (data) in a particular


form and of performing a sequence of operations in accordance with a predetermined but
variable set of procedural instructions (program) to produce a result in the form of information or
signals”.1

The above definition means computer is a device which can

Receive data (input) Store the data Perform certain operation (process) Produce a result (output)
(input)
“Science is the intellectual and practical activity encompassing the systematic study of the
structure and behaviour of the physical and natural world through observation and experiment”2

The above definition means science from the Latin word scientia (meaning Knowledge)

Organised study Understand form and behaviour Physical and natural world Observation and
experimentation

collection of
data(to
understand form
and behaviour)

result/output(exp processing of
lanation of form
Computer data( Observation
and behaviour) Science and
experimentation

1
Google definition of computer, https://www.google.co.in
2
Google definition of science , https://www.google.co.in
Fig.1 connection between computer and science

Computer Science is the dicipline or field of study that deals with the nature of computing that
determines which problem can be solved.It compares various algorithms to find the correct and efficient
solution of a problem.It utilizes theories on how computers work to analyze,design and tests concepts.

It requires the understanding of the various concepts of computational thinking as well as the operations
of computer or computing devices.

Computer science has a close relationship with other field of study such as mathematics , physics,
chemistry and biology.Other than these diciplines it also interacts with other diciplines such as :

 Library Science (for archiving texts and organizing storage and retrieval of information).
 Management Science (computer data models which helps in planning and forecasting economic
conditions of a business).
 Medicine and Biology (use of computer models and algorithms to diagnose and treat diseases).
 Psychology (computer models to get more insight on human thouhts and emotions to deisgn
effective solutions for human problems).
 Humanities (extensive use of computer to represent historical artifacts digitally).
 Linguistics (use of computers to understand, recognize and translate languages).

IBDP COMPUTER SCIENCE

The Diploma Programme computer science course is engaging, accessible, inspiring and
rigorous3.

 It enables one to think computationally.


 Uses enquiry based learning and problem solving approach.
 Understand to what extent a problem can be solved based on the theoretical and practical
limitations.
 Makes one innovative, explorer and urge to gain further knowledge.
 To understand both individual and society and influence on the culture.
 Raises awareness on moral, social ethical issues and implications of using it.
 Identify problem, design, develop and test a proposed solution.
 It requires one to demonstrate initiative in applying thinking skills to identify and resolve complex
problems.

You must….
Know and Understand
Apply and Use
Construct, Analyse, Evaluate,
Formulate

3
IBDP computer science guide
The IB learner profile4

Learner Profile Computer Science Syllabus

Inquirers Content: SL/HL core, HL extension, case


study. Decomposing systems to find
underpinning algorithms.

Solution: Investigation into appropriate


scenario.

Knowledgeable Content: SL/HL core, HL extension, case


study.

Solution: Justify appropriate techniques in


developing the product or modifying an
existing product.

Thinkers Content: HL extension, formulating


strategic plans in case study.

Solution: Develop an extensible product


so it can be maintained by others.

Communicators Content: SL/HL core, making links to


theory of knowledge.

Solution: Liaise appropriately with client


and/or adviser to develop product that
meets their requirements.

Principled Content: SL/HL core, HL extension, case


study. Proposing solutions that are ethical
and legal.

Solution: Test the product to ensure it is


error free and secure, protect any sensitive
data.

Open-minded Content: SL/HL core, HL extension, case


study. Proposing solutions that are ethical
and legal.

4
The IB learner profile,IBDP Computer Science Guide
Solution: Test the product to ensure it is
error free and secure, protect any sensitive

data.

Caring Content: SL/HL core, HL extension, case


study. Considering the opinions of
different stakeholders when reaching a
decision.

Solution: Liaise with client, reach


consensus in development of product.

Risk-takers Content: Case study, formulate strategic


plans.

Solution: Make and justify decisions about


which techniques to use in developing the
most appropriate product.

Balanced Content: SL/HL core, HL extension in


analysis and judgment-type questions.

Solution: Collection of data and the


subsequent analysis and synthesis of the
information to determine the most
appropriate product.

Reflective Content: Case study, reflecting on possible


decisions related to a strategic decision.

Solution: Evaluate methodologies used to


develop product to recommend future
improvements.

International Mindedness

Computer science itself is an international endeavour—the exchange of information and


ideas across national boundaries has been essential to the progress of the subject. This
exchange is not a new phenomenon but it has accelerated in recent times with the
development of information and communication technologies.
The development of solutions may be at a local, national or global scale and lies at the heart
of the subject. Therefore teachers of computer science should study a range of examples from
different geographical locations as well as at different scales.
Developments such as open source software and the emergence of social networking
epitomize the global nature of the subject. Internet forums exist that welcome ideas and
solutions developed from computer scientists from all continents in driving forward
developments to different software types. These developments have revolutionized the way
that people, and in particular the young, interact.5

Core Syllabus Content

SL/HL Core

Topic 1 : System Fundamentals 20 hrs

Topic 2 : Computer Organization 6hrs

Topic 3 : Networks 9hrs

Topic 4 : Computational thinking,problem-solving 45hrs


and programming

HL Extension

Topic 5: Abstract Data Structures 23hrs

Topic 6: Resource Management 8hrs

Topic 7: Control 14hrs

5
International Mindedness, ,IBDP Computer Science Guide
Topic 1: System Fundamentals

The system life cycle refers to the system/application development life cycle,a term used in software
engineering and information systems to describe the various stages or process a new system to be
developed undergoes.The various stages are :

Analysis

Maintenance Design

Operation Implementation

Fig.1.2 The System Life Cycle

 Analysis: The analysis stage is the initial step of developing/creating a system. This stage deals to
determine where the problem is. It involves a series of steps of breaking down the system to analyse
the situation. At this stage the system analyst meets the user to determine what the user actually
wants.

 Design: The design stage showcases the design functions and operations in a detailed manner. This
stage will describe the system as collection of systems and sub systems. It includes mainly the
hierarchy diagrams, screen layouts, business rule tables, process diagrams, pseudocodes and entity
relationship diagrams. It is intended to give a detailed explanatory so that the system can be
developed with ease.

 Implementation: The real construction of the system to be functional is done at this stage. The
system is created/developed at this stage based on the design proposed at the design stage. At this
stage testing is carried out so as to make sure that all parts of the system work correctly without any
error.

 Operation: At this stage the system is deployed or installed. There are various ways of installing the
system such as direct changeover, phased installation or parallel running.
 Maintenance: It describes the tasks to maintain the system in a production environment.
Maintenance is an important stage as there could be new requirements that may come up with time.
Not only requirements it can also include changes if the key personnel change positions in the
organization. These problems can be resolved by system updates.

Existing System
Anlaysis

Requirement
Maintenance
Specification

New System
Software Design
Installation

Testing & Software


Debugging Implementation

Fig 1.3 Software Life Cycle

The software life cycle or SDLC is almost similar to the system life cycle. It starts with the analysis of
the existing system, then gathering the requirement specification. Based on which the software is
designed. Once the design is finalized the software development takes place. After the development
gets over based on the design specification. The software is validated and verified and several testing
methods are carried out to make the software error free. Finally the software is installed to be used
by the concerned user. Later maintenance is carried out to incur further updates or changes.
How CS IA in IB aligns with the above mentioned life cycle?

Let’s find out…

Criterion A:
Planning

Criterion B:
Solution
overview

Criterion C:
Development

Criterion D:
Functionality
and
extensibility of
product

Criterion E:
Evaluation

Fig 1.4 CS IA Criteria Process

Step 1 – The initial stage for planning begins with the client consultation. An interview is conducted
with the client by creating a predefined set of questions which will cover the requirements of the
client as well as the understanding of the product to be developed. In this step the problem needs to
be defined in extended writing with the rationale behind the selection of the desired solution. One
needs to justify why the choice of the solution is an effective one. This stage will conclude by listing
the success criteria which are the key features that justifies the product.

Description of the
scenario
Success Criteria for the Rationale for the
product proposed product

Planning

Fig 1.4 IA Criterion – Planning


Step 2 - This step begins with the documentation of the Record of Tasks. The record of tasks consists
a chronological order of different stages of product development such as planning, designing,
developing, testing and implementation. This may also consist of indication regarding the issues that
may occur during the development of the product.

As per the System/Software development life cycle this comes under the design part.

The design stage is related to the solution overview of CS IA .The inputs from users and
information gathered in requirement gathering phase are the inputs of this step. The output of this
criteria/phase will be the overall structure and the internal layout of the solution. It means both
logical and physical designs will be produced. Logical diagrams such as ERD (Entity relationship
diagrams), DFD (Data flow diagrams) will be produced. It will also include database table
definitions with fieldnames and data types, queries, classes, subclasses, wireframe (wireframe is an
outline of the physical design of the product. It is also known as the screen blueprint that represents
the skeletal framework of the product).

The design overview also covers the testing plan. The testing plan is a guide that is to be followed
when testing the product. The testing plan aligns with the success criteria mentioned in Step 1.The
features listed in the success criteria must be included in the test plan that means success
criteria should be something that is testable and logical.

Finally the test plan will be used to evaluate the product……6

Data Flow Record of Tasks Entity Relationship


Diagrams/Flowcharts Diagrams

Database Tables Layout Solution Wireframe/Screen


Overview/Design Layout

Test Plan Class, Sub-classes

Fig 1.5 IA Criterion – Solution Overview

Step -3 – This step or criteria involves the techniques used to develop the product. This criteria aligns
with the Based on the design overview created on the above step is implemented or put to action. It
is produced using algorithmic thinking, data structures, software tools and user interface. The
structure of the product is clearly showcased here with descriptive writing and screenshots of the
product in the development stage. The screenshots of the product needs to be clearly explained in

6
For further reference follow the IA section in IBDP CS Guide
details. The screenshot may be the written codes or the queries written for various database
operations.

Any existing code libraries, templates or reference material used in the development of the product
must be mentioned.

Algorithmic Thinking User Interface

Development

Screenshot Acknowledge
Reference

Fig 1.5 IA Criterion – Development

Step - 4 – This step or criteria involves two parts firstly, a video to demonstrate the functionality of
the product/solution. A script to be written based on the explanation given in the video and relates
it to the success criteria/test plan. Secondly, the extensibility of the product means that the solution
should have appropriate folder and data structure, even the file/class should have proper naming
convention.

Step - 5 – This step or criteria relates to the implementation stage. The product/solution is evaluated
based on the success criteria mentioned in criterion A. Any feedback obtained from the client needs
to be mentioned or a briefing could be given about it. The recommendations for future improvement
need to be stated and such improvements needs to be feasible and a proper briefing to achieve those
recommendations.

Breakdown

The section on system fundamentals from the curriculum suggests 20 hours of your time investment.
As well, the section is broken into 2 sub sections: System Organization (10 hours) and System Design
Basics (10 hours). Each of these is further divided up as seen below:

Systems in Organizations: System Design Basics:

(1) Planning and System installation (5) Components of a computer system


(2) User focus (6) System design and analysis
(3) System backup (7) Human interaction with the system
(4) Software development
Specifics

In order to ensure you feel you are adequately prepared for the I.B. computer Science external
assessment (the exams); I list below the specific criteria from the I.B. Computer Science
curriculum on this section of system fundamentals

Systems in Organizations – Planning and System Installation

(1) Identify the context for which a new system is planned


(2) Describe the need for change management
(3) Outline compatibility issues resulting from situations including legacy systems or business
mergers
(4) Compare the implementation of systems using a client’s hardware with hosting systems
remotely
(5) Evaluate alternative installation processes
(6) Discuss problems that may arise as a part of data migration
(7) Suggest various types of testing

Systems in Organizations – User Focus

(8) Describe the importance of user documentation


(9) Evaluate different methods of providing user documentation
(10) Evaluate different methods of delivering user training

Systems in Organizations – System backup

(11) Identify a range of causes of data loss


(12) Outline the consequences of data loss in a specified situation
(13) Describe a range of methods that can be used to prevent data loss

Systems in Organizations – Software Deployment

(14) Describe strategies for managing releases and updates

Systems Design Basics – Components of a computer system

(15) Define the terms: hardware, software, peripheral, network, human resources
(16) Describe the roles that a computer can take in a networked world
(17) Discuss the social and ethical issues associated with a networked world

Systems Design Basics – System design and analysis

(18) Identify the relevant stakeholders when planning a new system


(19) Describe methods of obtaining requirements from stakeholders
(20) Describe appropriate techniques for gathering the information needed to arrive at a
workable solution
(21) Construct suitable representations to illustrate system requirements
(22) Describe the purpose of prototypes to demonstrate the proposed system to the client
(23) Discuss the importance of iteration during the design process
(24) Explain the possible consequences of failing to involve the end-user in the design process
(25) Discuss the social and ethical issues associated with the introduction of new IT systems

Systems Design Basics – System design and analysis

(26) Define the term usability


(27) Identify a range of usability problems with commonly used digital devices
(28) Identify methods that can be used to improve the accessibility of systems
(29) Identify a range of usability problems that can occur in a system
(30) Discuss the moral, ethical, social, economic and environmental implications of the interaction
between humans and machines

Planning and System Installation

1.1 Identify the context for which a new system is planned

New systems arrive to replace an inefficient system which no longer serves the purpose. The benefit
of proposing a new system are:

 Increase in efficiency and productivity.


 Cut costs by automating routine tasks.
 Streamline all business operations.
 Effective communication
 Reducing flaws or errors

The context for a new system must be clearly understood. The context could be background,
environment, framework or the situation surrounding the system. Two important considerations
are the extent and limitations of the new system.

Following are the situations that could be considered.

Will there be any technology that could be affected or changed?


How will the user’s role be changed/affected?
Will any organizational arise due to new system implementation.

Following organizational issues can be anticipated by planning7

 Lack of attention to required training


 Lack of stakeholder and end user participation
 Lack of strategies in both organization and business.
 Lack of allocation of information system and overall use of the system

To eradicate the possibility of such lacking a Feasibility Study is conducted during planning.

7
Core Computer Science, Kostas Dimitriou & Markos Hatzitaskos , Express Publishing
Feasibility Study

Feasibility study helps in identifying strength and weaknesses of an existing system or for a
proposed system. It evaluates the success rate and the projects potential. It is comprehensive
reports that consider different factors.

Constraints resolved by feasibility study are:

 Internal Project Constraints (Technical, Budget, Resource)


 Internal Corporate Constraints (Economical, Marketing)
 External Constraints (Rule and Regulations, Logistics)

A feasibility study will help in uncovering new ideas that could change the scope of the project. It
gives a clear picture of the proposed project.

The variable on which feasibility study is conducted falls under TELOS.

Technical Feasibility – It focuses on the technical resources that are available in an organization. It
determines whether the technology and the technical team can convert the ideas into a working
system. It will study the hardware, software or any other technical resource that may be required for
the proposed system. It determines whether the current technology is efficient to be implemented.

Economic Feasibility – It revolves around assessing the cost or the budget factor for the proposed
system. It determines whether the cost and the benefits from it are reasonable before any financial
resources are allotted. It helps the decision makers to determine positive economic benefits thereby
resolving effectiveness of the cost.

Legal Feasibility – It identifies any aspect of the system proposed has conflicts with any legal
requirements such as zoning laws, data protection acts, social media laws. Ex. A data processing
system must comply with the local data protection acts.

Operational Feasibility – It focuses on the fact that whether the proposed system fits in within the
existing business environment. It solves the problem and satisfies the requirements identified in the
requirement analysis phase of system development.

Scheduling Feasibility – It determines the time that a proposed system would take to complete. A
proposed system will fail if takes too much time to finish. It is important to determine whether the
deadline is mandatory or desirable.

Technical Feasibility

Economic Feasibility

Legal Feasibility

Operational Feasibility

Scheduling Feasibility
1.2 Describe the need for change management

Change Management a term used for all approaches to help, support teams, individuals and
organizations in making change within the organization. Changes could be evolution of technological
components, consumer habits, any acquisitions, mergers and structuring of organization. Methods
may include redefine the use of resources, budget allocations or any other modes of operations.
Constant evolution of technology and globalization results in evolving business environment.

Examples of change management when a new operating system is introduced, the employees must
be trained so that they can easily able to work in their daily work schedule.

1.3 Compatibility issues resulting from situations including legacy systems or business
mergers

The term legacy system refers to an old method, technology or an application program which relates
to an outdated computer system. Such a framework may even now be being used on the grounds that
its information can't be changed over to newer formats. Keeping a legacy system includes different
support difficulties. High maintenance costs, security vulnerabilities, compatibility issues, and difficulty in adapting to modern technologies.

What are the consequences of running on a legacy system? Click Here To Know More.

Can you find out one such legacy system and identify its importance and drawback?

Business Merger

A combination of two entities or more, especially companies, into one.

Mergers can be VERY tricky

If companies/organisations merge across international borders, there may be several issues, such
as:

• Issues of software compatibility


• Language differences
• Time zone differences
• Workforce cultural differences
Four Strategies For Legacy Integration8

There are four main strategies for legacy systems integration, with advantages and disadvantages
for each:

 Keep both systems, and develop them to have the same functionality.
 Replace both systems with a new one.
 Select the best systems from each company and combine them.
 Select one company's systems and drop the other companies.

Activity

INT, S/E When organizations interact, particularly on an international basis, there may
be issues of software compatibility and language differences. Present your opinion
regarding the above statement

1.4 Compare the implementation of systems using a client’s hardware with hosting systems
remotely

There are two models of distributing software Local and Remote (also called SaaS/cloud). Local
hosted system also known as desktop system are those that need to be installed and stored on the
computer where you run, unlike network software, the suite Office by Microsoft, the graphic design
program Photoshop or Windows operating system are examples of this type software. In remote
hosted system you can buy/rent/use software that is installed on a computer somewhere on the
internet and then use it though a browser.

REMOTE OR LOCAL

SaaS (Software as a Service)


Software as a service (SaaS) is a software distribution model in which a third-party provider hosts
applications and makes them available to customers over the Internet. Also known as on-demand
software, hosted software or web based software. SaaS solutions reside on the cloud and need a web

8
https://www.coleyconsulting.co.uk/merge.htm
9
https://pixabay.com/illustrations/cloud-computing-cloud-system-cloud-2153286/
browser and a broadband Internet connection to be accessed. SaaS is less expensive because it has a
low initial cost and requires few investments in installation, maintenance and upgrading. SaaS has
become a common delivery model for many business applications, including office & messaging
software, payroll processing software, DBMS software, management software, CAD software,
development software, gamification, virtualization.10

Answer the following:

Question 1: A medical company is veg satisfied from the technical performance of its current
information technology infrastructure. Is there any reason to change it?

Question 2: What is meant by the term “business merger"?

Question 3: Draw a mind map to show the advantages of using SaaS.

1.5 Evaluate alternative installation processes

When moving from an old system to a new one the


most difficult situation is the choice of
implementation method. The trade-off is between
cost and risk when choosing a desired
implementation technique/method. When
implementing/installing a new system or a piece
of software, there are 4 alternatives of doing it.
11

 Direct changeover

New system is implemented and old system is


replaced completely. is very risky since the
company starts in the new system and removes
the old one at the same time. Cheap method of implementation as you don’t pay for two sets
of staff. Less chances of being faulty as the entire system is tested and checked.

Advantages...
 Takes the minimal time and effort
 The new system is up and running immediately
Disadvantages...
 If the new system fails, there is no back-up system, so data can be lost

OLD SYSTEM NEW SYSTEM

10
https://en.wikipedia.org/w/index.php?title=Software_as_a_service&oldid=634189323
11
https://image.freepik.com/free-photo/people-model-with-many-choices-concept_118019-146.jpg
 Parallel running
The new system is started, but the old system is kept running alongside it. Data has to entered
into both systems. both systems work in parallel for a short period of time. This method is very
popular because of the limited risk. The old system is switched off when staff are sure that they
can use the new system.

For Example: In a billing system both the old system and the new system will
produce an invoice

Advantages…
 if the new system fails, the old systems run a backup (no loss of productivity);
outputs from the two systems can be compared to see if new one is running correctly
Disadvantage…
 running two systems is costly in terms of time and money

OLD SYSTEM

NEW SYSTEM

 Pilot running

The new system is piloted (tested) with a small subset of the organisation. Once it is running
correctly and all bugs have been ironed out, it is implemented across the whole organisation.
Advantages...
If anything goes wrong with the new system, the old system will act as a back-up.
The outputs from the old and new systems can be compared to check that the new system is
running correctly
Disadvantages...
Entering data into two systems, and running two systems together, takes a lot of extra time
and effort

OLD SYSTEM
NEW SYSTEM
PILOT GROUP
 Phased conversion
In this type of changeover, the new system is implemented one part at a time in phases. Each part of
the system is fully tested and is known to work correctly. Ultimately old system is replaced. Staff can
be trained gradually that is currently phased in. Easier to find system errors. If one part of the new
system fails it is still possible to access other parts of the old system that is still in use.

Advantages…
 allows people to get used to the new system.
 training of staff can be done in stages
Disadvantage…
 if the new system fails, there is no fall back for that part of the system
 it can long time to implement the system

OLD SYSTEM NEW SYSTEM

Case study
https://erichmusick.com/writings/technology/1992-london-ambulance-cad-failure.html

1.6 Discuss problems that may arise as a part of data migration

Data migration is the process of transferring data from one storage system or computing
environment to another.12 Data migration occurs for a variety of reasons, including server or storage
equipment replacements, maintenance or upgrades, application migration, website consolidation,
disaster recovery, and data center relocation.

13Data migration can be as simple as putting a file on


a USB flash drive and opening it on another
computer. It is can also be very complex involving big
databases exchanging information across countries
into different time zones.

Problems that can arise:

Corruption: Data can become corrupted in transfer,


data is unusable whilst being transferred, for large
files this can be problematic as well as for files that
people are likely to be using.

File Formats: The way one system saves a file in a format may not be compatible with the new
system.

12
https://www.ibm.com/cloud/learn/data-migration
13
https://image.freepik.com/free-vector/data-transfer_71983-926.jpg
Date / Time / Currency / Language: The
system of storing dates, times, currency,
or even the international languages may
not be compatible in data migration.

Cost: In order to migrate data to new


storage you have to own the new storage
and you need to pay for enough storage
for all your needs (which may not be
possible).

Data Migration Stages

Extract

Validate Data Transform


Migration

Load

Activity

Discuss problems that may arise as a part of data migration.

INT These include incompatible file formats, data structures, validation rules, incomplete
data transfer and international conventions on dates, currencies and character sets.
1.7 Suggest various types of testing

Testing is important !

• Testing is very important in developing a computerized system as it tries to ensure that the system
works as expected.

• A system that does not work as expected (i.e. it has bugs) greatly reduces productivity and end user
satisfaction.

Functional testing tests individual commands, text input, menu functions, etc. confirms that is they
perform and function correctly according to the design specifications. For example, if a choice is made
to add a client, does the program go to the "add client’s module"?

Data testing is when normal, abnormal and extreme data is put into the system. Suppose that there is
a program that accepts a student’s percentage in a math exam and gives a “pass” message if the number
entered is greater than or equal to sixty; otherwise it prints a ”fail” message.14

A good test plan should be created for every system module and include...

 A list of the tests that are to be performed


 The data to be used in the test
 The type of test- (normal / extreme / abnormal / live)
 The expected outcome of the test
 The actual outcome of the test should be logged (Data accepted / rejected).

14
Functional Testing ,Core Computer Science, Kostas Dimitriou & Markos Hatzitaskos , Express Publishing
Static vs Dynamic testing15

Reviews, walkthroughs, or inspections are referred to as static testing, whereas actually executing
programmed code with a given set of test cases is referred to as dynamic testing.

• Static testing is often implicit, like proofreading, such as when the IDEs check source code
or syntax.
• Dynamic testing takes place when the program is run.
• Dynamic testing may begin before the program is 100% complete in order to test particular
sections/modules of code.
• Static testing involves verification, whereas dynamic testing also involves validation.

15
Static vs Dynamic testing, https://ib.compscihub.net/
Types of Testing

Alpha Testing is a type of software testing performed to identify bugs before releasing the
product to real users or to the public. Alpha Testing is one of the user acceptance testing. The
objective of alpha testing is to refine the software product by finding the bugs that were not
discovered during the previous tests.

Beta Testing is performed by real users of the software application in a real environment.
Beta testing is one of the type of User Acceptance Testing. Beta testing helps in minimization of
product failure risks and it provides increased quality of the product through customer validation.
Beta testing doesn’t require lab or testing environment.

Dry-run testing is conducted using pen—and—paper by the programmer. During dry run
testing the programmer mentally runs the algorithm. He examines the source code and decides on
what the output of a run should be (execution).

System data entry modules need to be tested to


make sure that data can be entered correctly.

System output modules needs to be tested to


make sure that results are correct.

Unit Testing is a level of software testing where individual units/ components of a software
are tested. The purpose is to validate that each unit of the software performs as designed. A unit is
the smallest testable part of any software. It usually has one or a few inputs and usually a single
output.16

16
http://softwaretestingfundamentals.com/unit-testing/
Integration Testing is a level of software testing where individual units are combined
and tested to verify if they are working as they intend to when integrated. The main aim here is to
test the interface between the modules.17

Acceptance Testing is a formal testing according to user needs, requirements and


business processes conducted to determine whether a system satisfies the acceptance criteria or not
and to enable the users, customers or other authorized entities to determine whether to accept the
system or not. It is a formal testing according to user needs, requirements and business processes
conducted to determine whether a system satisfies the acceptance criteria or not and to enable the
users, customers or other authorized entities to determine whether to accept the system or not.

Role of Validation and Verification in Testing

Validation: Are we building the right product?

Verification: Are we building the product right?

Validation is about checking the input data to ensure it conforms with the data
requirements of the system to avoid data errors. An example of this is a range check to avoid an input
number that is greater/smaller than the specified range.

17
https://www.edureka.co/blog/what-is-integration-testing-a-simple-guide-on-how-to-perform-integration-
testing/
Verification is performed to ensure that the data entered exactly matches the original
source. An example of this includes double entry of data (such as when creating a password or email)
to prevent incorrect data input.

Watch the following video to know more about why testing is important Click Here18

User Focus

1.8 Describe the importance of user documentation

User documentation is any document that explains how to use the features and functions of a system
to its end-users. It comes in many forms: books, PDFs, websites, videos, etc.

User Documentation is Important

 Whether you read user manuals or not, in general, having a reference guide on how to use a system
is critical to users.

 Without detailed, simple, clear instructions, users might be unaware of particular features or unable
to use features that are not immediately obvious.

 A well-made user documentation guides the user through using the system and thus increases
productivity.

 If the user documentation is simple, system implementation can happen faster because users require
less training to learn how to use the new system

Internal documentation is the code comprehension features and details provided as part of
the source code itself. Proper internal documentation includes:

 Appropriate module headers


 Appropriate comments
 Useful and meaningful variable names
 Useful module, classes, methods and function headers
 Appropriate code indentation
 Appropriate code structuring
 Appropriate use of data types defined by the user

External documentation is typically written as a separate document from the program itself.
It is provided through various types of user supporting documents such as a users' guide, software
requirements specification document, detailed description of the design and implementation
features of the program and test document.19

18
https://www.guru99.com/software-testing-introduction-importance.html
19
External Documentation, Core Computer Science, Kostas Dimitriou & Markos Hatzitaskos, Express
Publishing
1.9 Evaluate different methods of providing user documentation

There are several methods used to provide user documentation. They include:

Help Files are supplied together with the system. They can usually be called up with a button
in the system. Accessible at any time when using the program. Give general instructions on how to
solve some major errors. They can only be used after system has been installed. They often only deal
with very general errors. This kind of assistance is considered an excellent way to increase the
usability of a software application.

Online Support is provided in many


ways, depending on the product or service that is
being documented. Online portals can provide
updated manuals, support pages and FAQ pages.
A live chat technician will ask for the description
of the occurring problem, and try to present a list
of possible solutions.

20Printed Manuals are manuals


printed on paper and supplied together with the
system. They can be read through by users before
starting to work with the new system. Give help
installing the system. Often limited to a little
booklet supplying little information apart from
how to install the system.

Remote Desktop is a function that


enables a specialized person to connect to the
user’s PC across the Internet from virtually any
computer. Remote Desktop will actually allow a
specialized technician to take control of the
user's PC as though he/she/she was sitting
directly in front of it. This solution is ideal if the
user is not very experienced. This solution has
some security disadvantages because the
technician is allowed to have full access over the
user’s PC21.

20
https://www.simflight.com/wp-content/uploads/2012/08/PMDG_777_printed_chief_set-400x356.jpg
21
Remote Desktop, Core Computer Science, Kostas Dimitriou & Markos Hatzitaskos , Express Publishing
1.10 Evaluate different methods of delivering user training

User training can be delivered in a number of different ways depending on a variety of factors,
such as the number of the students, the availability of instructors, the size of the business, and the
training budget. Staff can be trained by self-instruction, formal classes or online training.

Self-Instruction: Users can learn how to


use a new system on their own, provided they have the Self-instruction
right material to learn from. It can take the form of
reading a manual or watching a tutorial. It has flexible
timeline. Training tailored to exactly what users wants
to learn. The disadvantages include lack of guidance or
Formal classes
teacher support and the final result depends on the
motivation of the user and their ability to learn on their
own. Unstructured learning means certain features Online training
might be misunderstood/ignored.

Formal Classes: A formal class offers an interactive setting that promotes open and free
discussion between students and the teacher (instructor). This type of training is useful to train large
amounts of staff as it is effective and relatively cheap, but if the size of the classes is too big, there is
little time to deal with individual problems and questions. Formal classes provide structured learning
environment

Online /Remote Training: An instructor training one user or a small group of users
by some kind of remote connection (Skype, Google Meet, Face time, etc.). This type of Virtual
Classroom is accessible is accessible 24x7 and 365 days in a year. An online educational program
requires participants who are able to access the online learning environment. The use of interactive
learning environments contributes to self-direction and promotes critical thinking, and thus is highly
supported by the literature of adult education and training. Lack of the required infrastructure will
exclude otherwise eligible students from the online course. Students and instructors must possess a
minimum level of IT skills in order to function effectively in an online environment.

System Backup

1.11 Identify a range of causes of data loss

Data loss 22is


any process or event that results in data being corrupted, deleted and/or made
unreadable by a user and/or software or application. It occurs when one or more data elements can
no longer be utilized by the data owner or requesting application. Data loss is also known as data
leakage. The cost of data loss depends on how costly it may be to go on without the data, how costly
it may be to recreate the data, as well as how costly it may be to notify users of data loss.

22
https://www.techopedia.com/definition/29863/data-loss
Leading causes of data loss

Human error
32%
Hardware or System
malfunctions
44%

Software Corruption
14%
Computer Viruses Natural Disasters
7% 3%

Hardware or System malfunctions Natural Disasters


Computer Viruses Software Corruption
Human error

Causes Solutions

Accidental deletion Use of file recovery software

where things such as earthquakes, floods, wars,


etc. can destroy your hardware – they may also
be caused by things like power failure, or fires
Natural Disaster (a little less ‘natural’)

Regular Backups / Store data in different


locations

Need for antivirus software


Computer viruses
Regular backups

Hard disk failure


Firmware corruption
Regular backups

Need for UPS (uninterruptible power


Power failure
Power failure supply)

Some storage devices come with defects, and


Hardware Malfunction may be the cause of data loss
Regular backups

Read the article to know about 10 Common causes of data loss.


1.11 Outline the consequences of data loss in a specified situation

23

23
https://ib.compscihub.net/wp-content/uploads/2018/06/1.1.12.pdf
Let us examine the consequences of a data loss occurring…

 Medical Records: may result in serious consequences for the patient and the family, as medical
records include data such as current or old diseases, allergies, vaccination and previous diseases or
conditions that have run in your family – so if this data was lost it would cause a huge health risk to
the patient.

 Banking Records: banks still hold a lot of your personal information such as name, address, age, etc.
and of course your bank accounts, so if this data is lost or stolen they will have access to all of that

 Government Agencies: will quite possibly be the sector that will own the most information
regarding a certain individual, anything ranging from your address to your social security number
and so on, and would cause serious social and security risks and damage if someone was to gain
access of it

 Credit Card records: losing data may damage the company’s reputation, for example when
companies like Amazon are hacked, important data like personal details and credit card information
might be used against the users and this creates a feeling of insecurity between the company and the
customers

Depends on the situation…


You can be asked to discuss the consequences of data loss for a variety of situations.
Things to keep in mind when discussing this:

– Can the data be replaced?


– How easy is the data to replace?
– Who will be affected by the data loss?
– Are there financial implications to the data loss?
– Are the ‘life-and-death’ consequences to the loss?
– Who is responsible for data recovery?

1.12 Describe a range of methods that can be used to prevent data loss

Key data loss prevention methods

 Failover system
 Multiple Backups
 Firewall Installation
 Removable media
 Offsite/online storage
 Antivirus Installation/protection
In computing, the term is used more specifically and refers to duplicate devices that are used for
backup purposes. The goal of redundancy is to prevent or recover from the failure of a specific
component or system.24
25

A failover system is a computer


system which is on standby
capable of switching to a spare
computer system upon hardware
failure, network failure, or any
other type of error, such as
software malfunction26. Failover is
the constant capability to
automatically and seamlessly
switch to a highly reliable backup
system. This can be operated in a
redundant manner or in a standby
operational mode upon the failure
of a primary server, application,
system or other primary system
component. A failover is automatic
and handles abnormal situations
without human interference. In a
failover system when primary server fails the standby server is made primary.

 Explain each of the data loss prevention methods in your own word.
 Watch the following video and write about your understanding for the same
Security Awareness: Data Loss Prevention

Software Deployment

1.12 Describe strategies for managing releases and updates

Most of the times the purchasing of a product means access to free online
updates, released by the company. These types of updates usually aim to
improve the product, fix various deficiencies or perform minor changes.
With all aspects of our system up and running, our software will still
need updates and we need strategies for managing this:

Release
A product release is the process of launching a new product for a specific
market or user base. In software development, a product release is

24
https://techterms.com/definition/redundancy
25
http://www.howto-expert.com/how-to-create-a-server-failover-solution/
26
https://en.wikipedia.org/w/index.php?title=Failover&o|did=614395973
sometimes done with a beta version so that core developers/users can assist with debugging and
feedback prior to the release of the actual software.

27Update

An update is a software file that contains fixes for


problems found by other users or the software developer.
Installing an update fixes the code and prevents the
problems from happening on your computer. Because
updates fix problems with a program, they are almost
always free and available through the program or the
company’s website.

Patches
A patch is a set of changes to a computer program or its supporting data
designed to update, fix, or improve it. This includes fixing security
vulnerabilities and other bugs, with such patches usually being called bug
fixes or bug fixes. Patches are often written to improve the functionality,
usability, or performance of a program.28

Patches may do any of the following:

– Fix a software bug

– Install new drivers

– Address new security vulnerabilities

– Address software stability issues

– Upgrade the software

27
https://www.orthodonticproductsonline.com/practice-products/software/treatment-planning/ulab-systems-
releases-aligner-planning-software-update/
28
https://en.wikipedia.org/wiki/Patch_(computing)
System Design Basics

Components of a computer system


1.13 Define the terms: hardware, software, peripheral, network, human resources

5 components of a ‘computer system’

Computer
System

Human
Hardware Software
Resource

Networks Peripherals

29Hardware

The physical components that make up a computer


(including but not limited to the CPU, monitor or screen,
keyboard, mouse or touchpad). External hardware
devices include monitors, keyboards, mice, printers, and
scanners. The internal hardware parts of a computer are
often referred to as components, while external hardware
devices are usually called peripherals.

Software
Software is a set of instructions, data or programs used to
operate computers and execute specific tasks. Opposite of
hardware, which describes the physical aspects of a
computer, software is a generic term used to refer to
applications, scripts and programs that run on a
device30.Software programs are stored as binary.

29
https://image.freepik.com/free-vector/it-engineer-isometric-compoisition_1284-25087.jpg
30
https://searchapparchitecture.techtarget.com/definition/software
Peripherals
A computer peripheral is any external device that provides input and output for the computer. For
example, a keyboard and mouse are input peripherals, while a monitor and printer are output
peripherals. Computer peripherals, or peripheral devices, are sometimes called I/O devices because
they provide input and output for the computer.

Human Resources
The department of the system that deals with the
administration, management, and training of
human personnel. It is used to describe both the
people who work for a company or organization
and the department responsible for managing
resources related to employees.

Networks
A network consists of multiple devices
that communicate with one another using
a transmission medium. It can be as small
as two computers or as large as billions of
devices. While a traditional network is
comprised of desktop computers, modern
networks may include laptops, tablets,
smartphones, televisions, gaming
consoles, smart appliances, and other
electronics.

Watch the video to know more about computer system


1.14 Describe the roles that a computer can take in a networked world

 Client is a piece of computer hardware or software (although the humans are often also called
clients) that accesses a service made available by a server. Clients usually connect to servers or one
another creating either client-server networks or peer-to-peer networks.

There are three types of clients:

1. Fat clients – performs the bulk of processing operations itself and does not necessarily rely
on the server.
2. Thin clients – rely on the resources of the server (including applications).
3. Hybrid clients – a mix of the other two architectures.
 Server is a combination of software and hardware that processes and delivers data to clients in a
network. Hardware in a server may vary from server to server based on the purpose of the server –
likewise different servers may have different processing powers, based on how much traffic they
receive. Many types of servers exist, including web servers, mail servers, and file servers. For
example, a Web server may run Apache HTTP Server or Microsoft IIS, which both provide access to
websites over the Internet.

 Router is a device that forwards data packets between


computer networks – clients connect to a router and any
incoming or outgoing connections are managed by the router.
It accepts incoming data packets, reads their destination address
and distributes them across networks, according to a routing
table or routing policy.

 DNS Server stands for Domain Name System Server which


attributes names to network addresses and therefore resolves names by assigning them to the
appropriate network entity. Domain names serve as memorisable names for websites and other
services on the Internet. DNS translates domain names into IP addresses, allowing you to access an
Internet location by its domain name.

 Client-Server Model describes how a server


provides resources and services to one or more
clients. When a client requests a connection to a
server, the server can either accept or reject the
connection. If the connection is accepted, the server
establishes and maintains a connection with the client
over a specific protocol. Examples of servers include
web servers, mail servers, and file servers. Each of
these servers provide resources to client devices, such
as desktop computers, laptops, tablets, and
smartphones.

 Firewall acts as a barrier between a trusted


system or network and outside connections, such as
the Internet. However, a computer firewall is more of
a filter than a wall, allowing trusted data to flow
through it. A firewall can be created using either
hardware or software. designed to prevent
unauthorized access to or from a private network. All
messages entering or leaving the intranet pass
through the firewall, which examines each message
and blocks those that do not meet the specified
security criteria.
1.15 Discuss the social and ethical issues associated with a networked world

A social issue is a problem that influences a considerable number of the individuals within a society.
A problem or situation that requires a person or organization to choose between alternatives that
must be evaluated as right (ethical) or wrong (unethical).

Reliability

Integrity

Inconsistency

Security

Privacy

Anonymity

The Digital Divide and Equality ofAccess

Surveillance

Globalization and cultural diversity

Standarnds and protocols

Digital Citizenship

Activity:

An introduction of a new system may affect the life of thousands, millions, or even
billions of users (take for example the Internet). Justify the statement based on the
factors mentioned above and social, ethical significance. You can present your
response in various formats such as a video/audio/presentation/written/image
Complete the following table to explain the pros and cons of an IT system.

Cause Positive Effect Negative Effect

Constant exposure to
communication technology

Internet

Use of smartphones

Gaming

Smartphone

Question : There is a vast amount of scientific information and educational material


available on the WWW. Share your insights on students having unrestricted and
unsupervised access to a PC that is connected to the Internet.

System Design and Analysis


1.16 Identify the relevant stakeholders when planning a new system

Stakeholder

 A person, group or organization that has interest or concern in an organization.


 Some examples of key stakeholders are creditors, directors, employees,
government (and its agencies), owners (shareholders), suppliers, unions, and the
community from which the business draws its resources.
 Not all stakeholders are equal. A company's customers are entitled to fair trading
practices but they are not entitled to the same consideration as the company's
employees.

Internal Stakeholders External Stakeholders

Employees Suppliers

Society

Manager Company Government

Shareholders

Customers
Owner
When identifying stakeholder for a new system, be sure to ask:

 Who will be affected by the new system?


 Who will the new system affect?
 Who will the end-users be?
 What are their needs?

Utilitarianism
• When designing a new system, we usually try to design it for the greatest good for the greatest
number of people. This is approach is called utilitarianism.

TOK Utilitarianism, the greatest good for the greatest number. The means justify the ends.
Present your arguments on the above statement.

Watch the video to know more about Utilitarianism

1.17 Describe methods of obtaining requirements from stakeholders

What does the client want?


Before designing a new system, it is crucial to determine exactly what the client’s requirements are.

Methods of obtaining requirements

 Surveys
Survey methodology refers to a domain of applied statistics that
focuses on taking samples from a population, as well as improving on
the various data collection techniques (e.g. questionnaires). 31It is
conducted in order to gather large size of information in a short period
of time.

Advantages:

– Large amount of data from a large group can be gathered


– Takes little time to analyse (if done electronically)
– Simple

Disadvantage:

– It is hard to ask the 'right question'


– Information gathered is limited by questionnaire, can be biased
– Quality of responses not ensured

 Interviews

Conducted in order to reflect emotions and experiences, and explore issues with a greater focus. The
possibility to direct the process of data collection.

31
https://en.wikipedia.org/w/index.php?title=survey_methodology&o|did=621707547
Advantages:

– Allows a lot of very detailed information to be gathered


– The possibility to collect the specific type of information
required
– The possibility to collect the specific type of information
required.

Disadvantage:

– Great amount of time required in order to arrange and conduct interviews and primary
data collection.
– Additional costs might be incurred associated with arranging and conducting interviews,
travelling etc.
– Potential for interviewee bias

 Observation

It Involves walking around the organisation watching how things are


done with his/her own eyes. It is considered as a time—and-motion
study that can show where procedures and processes could be made
more efficient, or where possible bottlenecks may be present.

Advantages:

– Possibility of gathering first-hand, unbiased information.

Disadvantage:

– Often people might not work the way they normally do when being observed.

 Documentation review

Conducted in order to study issues that have developed over a specific period of time.32

Advantages:

– Detailed information about the present system can be gathered.


– It can be seen where the old system has problems.

Disadvantages:

– Time consuming.
– Just looking at the forms/outputs may be confusing.

32
https://research-methodology.net/research-methods/survey-method/
Activity

Split off into pairs - one taking the role of customer, one taking the role of developer. The
customer comes up with an app/software project they want the developer to “design”. The
developer must ask questions to ascertain:

 A scope document: Explicitly list “in scope” and “out of scope” items
 Identify stakeholders
 Requirement specification: Functional and non-functional items

Reverse roles when ready.

1.18 Describe appropriate techniques for gathering the information needed to arrive at a
workable solution

Before you start …

Before you start making a new system, you need to make sure you know exactly what’s going on at
the moment and what other information you might need.

There are four techniques we can use to gather these bits of information:

– Examining current systems


– Looking at competing products
– Organizational capabilities

– Literature searches (web/books)

Information systems used in modern companies play a critical role and most companies use data and
information as assets to gain competitive advantage. We should keep in mind that a modern
information system should be planned to :

 increase client trust


 preserve brand strength
 preserve organization reputation
 maintain corporate resiliency
 enhance organizational piece

Competing products

Next, have a look at what the competitors are doing. The aim is not copy them, but to get an idea of
what is possible/being done at the moment.

Intellectual property

Intellectual property is something unique that you physically create. An idea alone is not intellectual
property. For example, an idea for an app doesn’t count, but the lines of code you’ve written do.
Organisational abilities

A big consideration before creating a new system is determining what the organisation would be
capable of.

 Can they afford a new system/new equipment?


 Can the staff use the new system? Training needed?
 Can they have any ‘downtime’ to upgrade?

Literature search

According to Auston et al (1992) literature search refers to the identification, retrieval and
management of various sources in order to find information on a topic, areas that might be
interesting for further studies, derive conclusions, as well as develop guidelines for practices.33 In IB
terms, the term “literature” refers to book, magazines, web sites, journals, videos, academic papers…

1.19 Construct suitable representations to illustrate system requirements

System requirements are specified through a document called a requirements specification


document. This document defines the specific customer requirements of a computer system. It is
included within the system analysis and may be later used to test the system, after implementation,
in order to evaluate it.

Three types of illustrations:

System Flowchart

A flow chart is a type of diagram


representing a process using different
symbols containing information about
steps or a sequence of events. Each of
these symbols is linked with arrows to
illustrate the flow direction of the
process. It provides a “system” view
rather than an application view. Manual
as well as computer processes are
represented. The system flowchart
might be used when observing and
documenting how users interact with an
existing system.

33
http://www.n|m.nih.gov/nichsr/Iitsrch.html
 Document - To represent documents being passed around the system. Can be used to denote
electronic but typically used to denote paper documents (a printed receipt or a voucher would
examples).
 The arrow creates a dependency. One can’t start until the other has ended.
 Data storage disk - An electronic file on the computer
 Action or process - As it sounds. When deciding if you have to create a process bubble, keep to the
general rule that a computer will always require a process to store or receive information.

Problem 1 - Consider “customer at a cafe”....

Customer gives order to sales person


Sales person enters the order into a computer. That is saved to a computer file, displayed on a
screen for a kitchen hand to make the order, and a receipt is printed that the cashier gives the
customer.
The kitchen hand prepares the food, presses an “order finished” button and gives it to the
customer.
The order finished button records the order as finalised.

Construct a system flowchart for the above given scenario

Problem 2- Consider “Going to the movies”...

A customer uses a phone app to order movie tickets online. The cinema online server receives
the order and stores in a database and sends back a ticket QR code for display on the phone
screen.
On arrival at the cinema, customer shows the QR ticket code to a computer
The system checks if the order is valid, and then prints a cinema ticket, otherwise it gives the
customer an error screen.
The customer shows the printed cinema ticket to the door person to gain entry.

Construct a system flowchart for the above given scenario

Data Flow Diagram

A data flow diagram (DFD) maps out the flow of information for any process or system.It uses defined
symbols like rectangles, circles and arrows, plus short text labels, to show data inputs, outputs,
storage points and the routes between each destination. Data Flow diagrams (DFDs) come in two
flavours:
DFD context diagram – shows the “context” (environment?) your system is part of, particularly
external entities it has a relationship with.
DFD level 0 diagram – shows inside the main / top level process of the system: the core functional
parts and the flow of data between them.

Data Flow diagrams: Context diagrams

Example: Online fresh food store34

34
Examples from http://editorialzone.blogspot.com/2010/09/data-flow-diagrams-of-online-
shopping.html
Example: Hotel Reservation

Level 0
Level 1

Level 2
Here is a video to know more about DFD using SmartDraw.

Structure Chart

Diagram representing the organization of a system, usually with showing the different parts in
hierarchical order.

Simplistically:

 Programs are made up of modules


 Modules are made up of subroutines and functions
 Subroutines & functions are made up of algorithms
 Algorithms are made up of lines of code
 Lines of code are made up of statements and data

35

1.19 Describe the purpose of prototypes to demonstrate the proposed system to the client

A prototype is either a working or non-working preliminary version of the final product or a simple
version of the final system that is used as part of the design phase to demonstrate how the product
will work.

35
https://en.wikipedia.org/wiki/Structure_chart
Purposes of a prototype

 Fail early and inexpensively – by building


a prototype, you can quickly weed out the
approaches that don’t work to focus on the
ones that do.

 Gather more accurate requirements –


interviews and focus groups can fall short
because many people find it difficult to
conceptualize a product before they see it.
By developing a working prototype, you can
demonstrate the functionality to help
solidify requirements for the final design.

 Technically understand the problem – by


developing a functional prototype, you are
forced to address both the foreseen and the
unforeseen technical challenges of a
device’s design.

 Increases system development speed.

 Resolve conflicts

Wireframing & prototyping

Wireframe: outlines the arrangement of textual and media elements. Wireframing tools allow both
parties—the designers and the client—discuss and comment on a sketch.
Search for “free wireframe tools” and you will find a bunch of useful tools you can use to help you
with this.
Some possibilities:
https://www.adobe.com/products/xd (free plan available?)
https://mockflow.com/ (limited free plan, maximum 3 pages without upgrade)
https://moqups.com/ (limited free plan, 1 project (limited to 300 objects) and 5MB of storage)
https://www.lucidchart.com/ (limited free plan available)
https://balsamiq.com/wireframes/ (30 day free trial)

1.20 Discuss the importance of iteration during the design process

Iteration

The action or a process of iterating or repeating.

Meaning 1: a procedure in which repetition of a sequence of operations yields results successively


closer to a desired result (linked to prototyping).
Meaning 2: the repetition of a sequence of computer instructions a specified number of times or
until a condition is met (links to loops, an alternative to recursion).

IB (MYP) Design Cycle


1.20 Explain the possible consequences of failing to involve the end-user in the design process

Not involving the end-user = problems

• User may be unsatisfied with system


• System may be unsuited for user's problem, affecting productivity

36

Involvement, collaboration and active participation are critical because a project with
poorly-defined stakeholder goals is unlikely to be successful. The developed system may
either solve a different problem, or deal with issues that are outside of the project's scope.

1.20 Explain the possible consequences of failing to involve the end-user in the design process

Automated Teller Machines (ATM) replaced bank tellers, E-pass systems replaced highway
toll collectors, internet travel sites replaced small travel agencies, automated voice systems
replaced service representatives, email replaced mail carriers, voice recognition systems
replaced typists, and reporters are being replaced by blogs and ”citizen journalists” and
social media users. Machines are replacing humans in countless tasks, forcing millions of

36
https://ib.compscihub.net/wp-content/uploads/2018/06/1.2.10.pdf
individuals into unemployment. A counterargument is that jobs don‘t vanish, but change.
Finally, advances in robotics and artificial inteligence may eventually replace an increasingly
large amount of workers with smart robots. This could create social disturbance similar to
that during the Industrial Revolution (when the introduction of machines had a similar
impact on society).

Introducing new information technology systems and applications (or constantly


developing old ones) certainly has a great impact on society and starts to pose ethical
questions about the extent to which this uncontrollable development can or should continue.
Take the creation of Facebook and Twitter, for instance. These social networks became
increasingly popular, penetrating users’ social and personal lives, ultimately becoming a
vital component of them. Facebook changed the way social interactions occur. It is important
to mention that social interaction is also an essential element of social change that affects
ideas, beliefs, moral values etc. Other |T developments may have a more indirect social
impact, but still, since the primary purpose of developing information technology systems
should be to improve human life, this impact should be examined. Continuous development
of computerized systems may absorb people and cause them to drift apart from the physical
world and become enclosed in virtual environments. Participation in virtual environments
may completely disorient some users. In addition, automated environments, such as the
”smart home”, which takes care of everyday tasks like checking the refrigerator contents and
making appropriate orders of supplies, may deprive people of socialization and interaction
opportunities that these tasks once offered to them. Considering these possible outcomes,
further moral and ethical questions arise. A surprising finding is that in a business
environment, the introduction of a new improved information system often places more
stress on the personnel because they have to study, learn, and familiarize themselves with
the new system while completing their regular duties. The extent to which IT advances are
beneficaI must be determined in order to be sure that it will not affect human society
negatively.37

Human interaction with the system


1.21 Define the term usability

38Accessibility in the sense considered here refers to the design of


products, devices, services, or environments so as to be usable by
people with disabilities. The concept of accessible design and
practice of accessible development ensures both "direct access" (i.e.
unassisted) and "indirect access" meaning compatibility with a
person's assistive technology (for example, computer screen readers).39

37
Core Computer Science, Kostas Dimitriou & Markos Hatzitaskos , Express Publishing
38
http://staff.washington.edu/tft/a11ylogo/images/a11ylogo_highres.png
39
https://en.wikipedia.org/wiki/Accessibility
How do you know how to use a mobile?

Did you read an instruction booklet? Did you attend a course on how to use a mobile
phone? Did you take an exam? If not, why not?

Usability is the measure of a product's potential to accomplish the goals of the user. In
information technology, the term is often used in relation to software applications and Web
sites, but it can be used in relation to any product that is employed to accomplish a task (for
example, a toaster, a car dashboard, or an alarm clock). Some factors used in determining
product usability are ease-of-use, visual consistency, and a clear, defined process for
evolution.40

SUS (System Usability Scale)


In systems engineering, the system usability scale (SUS) is a simple, ten-item attitude scale
giving a global view of subjective assessments of usability. It was developed by John Brooke
at DEC in the UK in 1986 as a tool to be used in usability engineering of electronic office
systems.

40
https://whatis.techtarget.com/definition/usability
Ergonomics
The scientific discipline concerned with the understanding of interactions among humans
and other elements of a system, and the profession that applies theory, principles, data and
methods to design in order to optimize human well-being and overall system performance.
Simply put: How well the form fits the function.

41

Watch the following video on Accessibility insights of Windows and present your
understanding in a summary of not more than 200 words.

1.21 Identify a range of usability problems with commonly used digital devices

The overall usability of a device using the eight quality components of usability42

 Complexity/Simplicity: Amount of effort to find a solution or get a result.


 Effectiveness: Comparison of user performance against a predefined level.
 Efficiency: Task completion time after the initial adjusting period

41
https://i2.wp.com/innovativept.net/wp-content/uploads/2017/10/IMG_7591.png?fit=1200%2C855
42
Core Computer Science, Kostas Dimitriou & Markos Hatzitaskos , Express Publishing
 Error: Number of errors, type of errors and time needed to recover from errors.
 Learnability: Time used to accomplish tasks on the first PPN!‘ use.
 Memorability: Time, number of button clicks, pages, and steps used by users when they
return to the device after a period of not using it.
 Readability/Comprehensibility: Reading speed.
 Satisfaction: Attitude of users toward applications after using them.

Activity
Identify the usability problems in the following device and analyze the problems using
the above eight quality components

1. Personal Computer
2. Tablet
3. Smartphone
4. Gaming Consoles
5. Digital Camera

1.21 Identify methods that can be used to improve the accessibility of systems

Types of disabilities

There are four different types of disabilities that can


affect the way people use and interact with digital
devices.

Go through the following cases that deals with


solution for people with disabilities:

Case study:

Microsoft Xbox controller

How does voice recognition work?

How does TTS (Text-to-speech) work?


1.21 Identify a range of usability problems that can occur in a system

Consider the following systems and analyse the usability considerations

 Ticketing
 Online payroll (paying salaries/wages)
 Scheduling (transport)
 Voice recognition
 Systems that provide feedback

1.22 Discuss the moral, ethical, social, economic and environmental implications of the
interaction between humans and machines

Moral issue can be understood as an issue to be resolved not only by considering the
technical stuff but also by keeping moral values in mind. To be more precise, let us consider
the definition in general.

“Moral issue is a working definition of an issue of moral concern is presented as any issue with
the potential to help or harm anyone, including oneself.”43

Ethical issues occur when a given decision, scenario or activity creates a conflict with a
society’s moral principles. Both individuals and businesses can be involved in these conflicts,
since any of their activities might be put to question from an ethical standpoint. Individuals
are subject to these issues in their relationships with other individuals or in their
relationships with organizations and same goes for organizations.

Social issue or problem is an issue that has been recognized by society as a problem that is
preventing society from functioning at an optimal level. It is important to understand that
not all things that occur in society are raised to the level of social problems. Four factors have
been outlined that seem to characterize a social issue or problem. These include:

 The public must recognize the situation as a problem.


 The situation is against the general values accepted by the society.
 A large segment of the population recognizes the problem as a valid concern.
 The problem can be rectified or alleviated through the joint action of citizens and/or
community resources.

Economical issue is a problem or situation that is concerned with the organization of the
money, industry, and trade of a country, region, or society.

43
https://www.tutorialspoint.com/engineering_ethics/engineering_ethics_moral_issues.htm
Environmental issue is a problem or situation that is concerned with the protection of the
natural world of land, sea, air, plants, and animals.

Why is working from home better than working from an office? Justify your answer
based on the above factors.
Topic 2: Computer Organization

Breakdown

The section on computer organization from the curriculum suggests 6 hours of your time investment.
The details are seen below.

Specifics

Computer Architecture

2.1 Outline the architecture of the central processing unit (CPU) and the functions of the arithmetic
logic unit (ALU) and the control unit (CU) and the registers within the CPU

2.2 Describe primary memory. Distinguish between random access memory (RAM) and read-only
memory (ROM), and their use in primary memory

2.3 Explain the use of cache memory

2.4 Explain the machine instruction cycle

Secondary Memory

2.5 Identify the need for persistent storage

Operating Systems and Application Systems

2.6 Describe the main functions of an operating system

2.7 Outline the use of a range of application software

2.8 Identify common features of applications

Binary Representation

2.9 Define the terms: bit, byte, binary, denary/decimal, hexadecimal

2.10 Outline the way in which data is represented in the computer

Simple Logic Gates

2.11 Define the Boolean operators: AND, OR, NOT, NAND, NOR and XOR

2.12 Construct truth tables using the above operators

2.13 Construct a logic diagram using AND, OR, NOT, NAND, NOR and XOR gates
Computer Architecture

2.1 Outline the architecture of the central processing unit (CPU) and the functions of the arithmetic
logic unit (ALU) and the control unit (CU) and the registers within the CPU
The terms bit (b), Byte (B) and their multiples

Computer systems are binary systems. That means that all the data and instructions

that are stored in a computer system are stored in sequences of binary digits that can

take only two possible values, 1 and 0. Thus a binary digit (bit) is the basic unit of

information in computer systems and can have only two values: either 1 or 0. Eight

bits form a byte.

1 Byte = 8 bits

A bit is denoted by the small letter b, whereas a byte is denoted by the capital letter

B. Thus, 13 = 8b. One byte can store a single character (ex. the letter A).

In a 64-bit computer each memory location holds 64 bits. A 64-bit Memory (Address)

Bus transfers 64 bits at any one time (which are the contents of a memory location in

a 64-bit computer system).

In computer systems we describe everything in bits and bytes. As such, they are used

to denote file sizes stored on memory or disks (ex. a 12MB file) or even connection

speeds (ex. 50Mbps). However, since files can become quite large and connection

speeds quite fast, multiples of bits and bytes are used. The following table depicts the

prefixes that can be used to denote multiples of bits and bytes.

Key abbreviations

 CPU = Central Processing Unit


 ALU = Arithmetic Logic Unit
 CU = Control Unit
 MAR = Memory Address Register
 MDR = Memory Data Register

Computers require input hardware, processing hardware and output hardware. The hardware that
defines a computer is the CPU and memory. Without these a computer could not function.
The CPU and memory work together to run programs.
44

CPU - executes programs using the fetch-decode-execute cycle

Memory - stores program operations and data while a program is being executed. There are
several types of memory, including: registers, cache, RAM and virtual memory.

Storage - stores programs and files long term, even when they are not in use. Devices such as hard
drives, USB memory sticks or SD cards are used to store files such as photos, music and software
applications long term.

Graphics
Most computers have a CPU and a separate graphics processing unit (GPU) for images. The GPU can
be around 10 times faster than the CPU. It is optimised to produce high-quality 3D graphics for games
and films. The GPU is responsible for handling images and frees up the CPU to do all other tasks.

44
https://www.bbc.co.uk/bitesize/guides/zmb9mp3/revision/1
CPU (Central Processing Unit)

The key component of a computer system, which contains the circuitry necessary to fetch, decode
and execute program instructions from and to main memory (RAM). The CPU is the ”brain” of a
computer system and can process data very quickly but can only process data by following
instructions. A computer processor does moronically simple things — it moves a byte from memory
to register, adds a byte to another byte, moves the result back to memory. The only reason anything
substantial gets completed is that these operations occur very quickly.
To quote Robert Noyce, “After you become reconciled to the nanosecond, computer operations are
conceptually fairly simple.”

45

45
https://www.pcgamesn.com/wp-content/uploads/2019/01/Intel-i7-9700K-CPU.jpg
Activity

Watch the following video and in a series of steps note down the process of transformation
from sand to silicon chip.

The Making of a Chip

The CPU contains the:

Arithmetic Logic Unit (ALU)

Control Unit (CU)

Memory Data Register (MDR)

Memory Address Register (MAR)

Block Diagram of CPU


ALU (Arithmetic Logical Unit)

Short for arithmetic logic unit, the ALU is a complex digital circuit; one of many components within
a computer's central processing unit. It performs both bitwise and mathematical operations on
binary numbers and is the last component to perform calculations in the processor. The ALU uses
operands and code that tells it which operations to perform for input data. After the information is
processed by the ALU, it's sent to the computer's memory.

Multiple Arithmetic Logic Units are in CPUs, GPUs and FPUs. In some computer processors, the ALU
is divided into an AU and LU. The AU performs the arithmetic operations, and the LU performs the
logical operations.46

CU (Control Unit)

A control unit or CU is circuitry that directs operations within a computer's processor. It lets the
computer's logic unit, memory, as well as both input and output devices know how to respond to
instructions received from a program. Examples of devices that utilize control units include
CPUs and GPUs.

A control unit works by receiving input information that it converts into control signals, which are
then sent to the central processor. The computer's processor then tells the attached hardware what
operations to carry out. The functions that a control unit performs are dependent on the type
of CPU, due to the variance of architecture between different manufacturers. The following
diagram illustrates how instructions from a program are processed.47

Machine Cycle
Step 2 Decode
Step 3 Execute
instructions to
commands
commands
Step 1 Control Unit ALU
Fetch Step 4 Store
Instructions results in
from Main Memory memory
memory

CPU needs its own ‘memory’


 Registers: they are small, very fast circuits that store intermediate values from calculations
or instructions inside the CPU.
 There are many registers, but the three most important ones are:
o MAR
o MDR
o Accumulator

46
https://www.computerhope.com/jargon/a/alu.htm
47
https://www.computerhope.com/jargon/c/contunit.htm
48Busses

Buses are circuits on the motherboard that connect


the CPU to other components. There are many buses
on the motherboard. A bus moves instructions and
data around the system. The speed of a bus is
measured in megahertz (MHz). The faster the bus,
the faster data is communicated. The speed of the
motherboard is defined by the bus speed.

Buses are limited by their width in bits. They are


usually 8, 16 or 32-bits wide. This tells us how many
bits can be sent by the bus at any one time, eg a 32-
bit bus can send 32 bits at once.49

Why is a computer bus called a bus?


You can think of a computer bus like public
transportation or a school bus. These types of buses
are capable of transporting people from one
destination to another destination. Like these buses,
a computer bus transmits data from one location or
device to another location or device.

The three most important busses are:

 Data bus (links RAM to CPU via MDR)


 Control bus (links RAM to CPU via CU)
 Memory bus/Address bus (links RAM to CPU via MAR)

MDR (Memory Data Register)


 MDR is connected to the data bus.
 MDR holds data that will be written to the RAM or that was read from RAM.
 Relationship between MAR & MDR: The MAR gives the address the data of the MDR will be
read from or written to.

MAR (Memory Address Register)


 MAR is connected to the address bus.
 MAR contains a memory address.
 MAR’s sole function contains the RAM address of the instruction the CPU wants next.

48
http://3.bp.blogspot.com/_5R5dQL7afpk/THEQNmLhk6I/AAAAAAAAAFY/vZhoGc5x75Y/s1600/pci-diagram.gif
49
https://www.bbc.co.uk/bitesize/guides/zmb9mp3/revision/4
2.2 Describe primary memory. Distinguish between random access memory (RAM) and read-only
memory (ROM), and their use in primary memory

Memory

Memory is the area where the computer stores or remembers data. Memory provides the CPU with
its instructions. There are different types of memory, and each one plays an important role in the
running of a computer system. Memory is sometimes called primary memory.

Memory is either volatile or non-volatile. Volatile memory only stores information to run programs
while the computer is on. It is reset and emptied once the computer is turned off. Volatile memory
requires electricity to store data using transistors and capacitors.50

Important to note

There is a key difference between memory and storage. Programs are kept on a storage device
and copied into the computer's memory before they are executed. Storage is also called secondary
storage.

Storage and read only memory (ROM) use non-volatile memory to retain data - even when the
computer has been switched off. In older computers, paper, punched tape and floppy disks have
been used for non-volatile memory.

50
https://www.bbc.co.uk/bitesize/guides/zmb9mp3/revision/6
RAM
Random access memory. This is volatile memory that is
constantly being written to and read from. It does not
retain its contents without a constant supply of power.
When a computer is turned off, everything stored in its
RAM is lost.51

ROM

Originally its contents were static (hence ‘read only’) and could
not be changed – not true anymore (flash upgrades). Non-
volatile = does not lose its contents if power is lost. Stores the
BIOS (Basic Input Output System) – a small program that
allows the computer to know what to do to find the operating
system to ‘boot’ the computer after power is restored.

2.3 Explain the use of cache memory

Cache Memory

A type of small, high-speed memory inside the CPU used to hold frequently used data, so that the CPU
needs to access the much slower RAM less frequently. It is the fastest memory that provides high-
speed data access to a computer microprocessor. The need for the cache memory is due to the
mismatch between the speeds of the main memory and the CPU. The CPU clock is very fast, whereas
the main memory access time is comparatively slower. Hence, no matter how fast the processor is,

51
http://s3.amazonaws.com/digitaltrends-uploads-prod/2014/05/ddr4_2.jpg
the processing speed depends more on the speed of the main memory (the strength of a chain is the
strength of its weakest link). It is because of this reason that a cache memory having access time
closer to the processor speed is introduced.52

Level 1 (L1) cache or Primary Cache

L1 is the primary type cache memory. The Size of the L1 cache very small comparison to others that
is between 2KB to 64KB, it depends on computer processor. It is an embedded register in the
computer microprocessor(CPU). The Instructions that are required by the CPU that are firstly
searched in L1 Cache. Example of registers are accumulator, address register, Program counter
etc.

Level 2 (L2) cache or Secondary Cache

L2 is secondary type cache memory. The Size of the L2 cache is more capacious than L1 that is
between 256KB to 512KB.L2 cache is Located on computer microprocessor. After searching the
Instructions in L1 Cache, if not found then it searched into L2 cache by computer microprocessor.
The high-speed system bus interconnecting the cache to the microprocessor.

Level 3 (L3) cache or Main Memory

The L3 cache is larger in size but also slower in speed than L1 and L2, its size is between 1MB to
8MB.In Multicore processors, each core may have separate L1 and L2, but all core shares a common
L3 cache. L3 cache double speed than the RAM.

Activity

Watch the following video on CPU Cache Explained - What is Cache Memory? and reflect
on your understanding by creating an audio clip.

2.4 Explain the machine instruction cycle

Step 2 Decode
Step 3 Execute commands
instructions to
commands
Step 1 Control Unit ALU
Fetch Step 4 Store
Instructions results in
from Main Memory memory
memory

52
https://ecomputernotes.com/fundamental/disk-operating-system/what-is-cache-memory
Step 1: Fetch instruction from primary memory to control unit53

The CPU is responsible for knowing which instruction it needs to take from the primary memory in
order to operate correctly. To do that it sends the appropriate address through the memory
(address) bus to the primary memory. The instruction that resides in the specific address is then
copied into the data bus and sent to the control unit (CU).

Step 2: Decode instruction in control unit

The instruction that has been received by the CU is then decoded. Decoding an instruction allows
the CPU to be aware of any additional data that are necessary for the execution of the instruction.
Any required data that need to be loaded from the primary memory in order for the instruction to
be executable are then fetched. The addresses of these data are placed into the memory (address)
bus and the data from these addresses are received by the CPU through the data bus.

Step 3: Execute instruction

The CPU executes the instruction using the necessary data that have been loaded and calculates a
result. Depending on the result, additional data may be needed. These data are fetched from the
primary memory for further calculations. As before, the addresses of these data are placed into the
memory (address) bus and the data from these addresses are received by the CPU through the data
bus.

Step 4: Store result of execution and check for next instruction

After executing the instruction and computing the result the CPU then stores the result in the
primary memory. To do so, it specifies the address where the result will reside in the primary
memory, using the memory (address) bus and sends the data through the data bus. The CPU then
checks for the next instruction and repeats the steps describe the above by fetching, decoding,
executing and finally storing the result.

Secondary memory

2.5 Identify the need for persistent storage

Storage is non-volatile disk space, and is sometimes called auxiliary memory, secondary memory
or external memory. Storage devices, like an external hard drive are used to store files like photos,
program files and any other information that needs to kept long term. The data on a storage drive
needs to be loaded into RAM before it can be used.

53
Core Computer Science, Kostas Dimitriou & Markos Hatzitaskos , Express Publishing
Operating systems and application systems

2.6 Describe the main functions of an operating system


What is Operating System?54

An operating system is a program on which application programs are executed and acts as an
communication bridge (interface) between the user and the computer hardware.

The main task an operating system carries out is the allocation of resources and services, such as
allocation of: memory, devices, processors and information. The operating system also includes
programs to manage these resources, such as a traffic controller, a scheduler, memory management
module, I/O programs, and a file system.

Functions of Operating System

 Memory Management –

The operating system manages the Primary Memory or Main Memory. Main memory
is made up of a large array of bytes or words where each byte or word is assigned a
certain address. It Allocates the memory to a process when the process requests it
and deallocates the memory when the process has terminated or is performing an
I/O operation.

 Device Management –

An OS manages device communication via their respective drivers. It performs the


following activities for device management. Keeps tracks of all devices connected to
system. designates a program responsible for every device known as the Input/
Output controller. Decides which process gets access to a certain device and for how
long. Allocates devices in an effective and efficient way. Deallocates devices when
they are no longer required.

 Processor Management –

In a multi programming environment, the OS decides the order in which processes


have access to the processor, and how much processing time each process has. This
function of OS is called process scheduling. Allocates the CPU that is processor to a
process. De-allocates processor when a process is no more required.

 Security –

The operating system uses password protection to protect user data and similar
other techniques. it also prevents unauthorized access to programs and user data.

54
https://www.geeksforgeeks.org/functions-of-operating-system/
 Error detecting aids –

Operating system constantly monitors the system to detect errors and avoid the
malfunctioning of computer system.

 Coordination between other software and users –

Operating systems also coordinate and assign interpreters, compilers, assemblers


and other software to the various users of the computer systems.

 Job accounting –

Operating system Keeps track of time and resources used by various tasks and users,
this information can be used to track resource usage for a particular user or group of
user.

 File Management –

A file system is organized into directories for efficient or easy navigation and usage.
These directories may contain other directories and other files. An Operating System
carries out the following file management activities. It keeps track of where
information is stored, user access settings and status of every file and more… These
facilities are collectively known as the file system.
Can you guess the names of each of the above OS ?

2.7 Outline the use of a range of application software

A computer system has the ability to run at least one software application, which has been installed
by the manufacturer, to complete some predefined tasks. For example, a digital camera is on its
own a computer system. It consists of both hardware and software components and follows
the input, process, output and storage model.
Common application software

 Word processors
 Spreadsheets
 Database Management Systems (DBMS)
 Email clients
 Web browsers
 Computer Aided Design (CAD)
 Graphic Processing Software

Activity

Explore each of the application and find out the fact why these applications are called
application software and how they differ from each other. You can also make video clip
to showcase the outcome of your exploration.

2.8 Identify common features of applications

Common features of most programs are:

 Toolbars
 Menus
 Dialogue Boxes
 GUI components

Difference between CLI and GUI

55CLI is that the word form used


for Command Line Interface. CLI
permits users to put in writing
commands associate degree
exceedingly in terminal or console
window to interact with an
operating system. CLI is a platform
or medium wherever users answer
a visible prompt by writing a
command and get the response
from system, for this users have to
be compelled to kind command or
train of command for performing
the task. CLI is suitable for the pricey computing wherever input exactitude is that the priority.

55
https://www.wikihow.com/Use-the-Command-Line-Interface
56

GUI stands for Graphical User Interface.


GUI permits users to use the graphics to
interact with an operating system. In
graphical user interface, menus are
provided such as: windows, scrollbars,
buttons, wizards, painting pictures,
alternative icons etc. It’s intuitive, simple
to find out and reduces psychological
feature load. In GUI, the information is
shown or presented to the user in any form
such as: plain text, videos, images, etc.

Binary representation

2.9 Define the terms: bit, byte, binary, denary/decimal, hexadecimal

Given each bulb can have two states, “on or off”, or 2 possible combinations, how many total possible
combinations are possible with 8 light bulbs?

Given there are 8 bulbs, and 2 possible states of each, this should scale to 8^2 = 256 possibilities.

Rather than lightbulbs, in computer science we use 1 to represent ON, and 0 to represent OFF.

The 0 or 1 is known as a bit.

A cluster of 8 bits is known as one byte with values 0 to 255 (being 256 possible values)

56
https://www.industronic.com/blog/wp-content/uploads/2016/06/WI_Benutzeroberflaeche-Allgemein.jpg
Common byte storage capacities

Definition: binary
 Computers use binary - the digits 0 and 1 - to store data.
 Because it only has 2 symbols (0 & 1) it is also called BASE-2 numbering
 Binary also refers to the format in which numbers are transmitted and calculated in a
computer system.

Definition: denary / decimal


Denary is a numbering system with 10 symbols: 0123456789It is, therefore, often referred to as
BASE-10 numbering.
Relationship between ‘normal’ numbers (denary) and binary

How to convert from binary to denary:


Definition: hexadecimal

 Hexadecimal is a numbering system with 16 symbols: 0123456789ABCDEF


 It is, therefore, often referred to as BASE-16 numbering.
 Hex, as it is often called, is used to represent very large numbers quickly, such as those used
in colour representation.

Activity

Use your problem solving skills and try to

i. convert 5F to decimal.
ii. 01001011 to hexadecimal

Question: Does binary represent an example of a lingua franca? Let’s have a group
discussion and explore the different perspectives of the above inquiry.

2.10 Outline the way in which data is represented in the computer

Many different representations:

• String (“I love Java”)


• Integer (12, 34, 3345…)
• Characters (ASCII vs Unicode)
• Colours (Hex)
ASCII

As powerful as computers can be using bits and bytes, humans don’t intuitively operate on
that level, we use characters and words, so there needed to be a way for letters (and thereby
words) to be represented somehow within a computer.

To achieve this, an arbitrary table was decided on in the 1960s called the ASCII table. This
table still forms the basis of much of today’s character representation system. The
significance of this table is that a “string of letters” is really just a sequence of binary that,
according to this lookup table, can be used to represent alphanumeric text.

Activity

Use the above ASCII conversion chart and find the binary conversion of your name.
Unicode

ASCII was incredibly useful and opened up a world of computing accessible to a lot of people,
but there are still significant limitations. ASCII was built on an 8 bit / 1-byte conversion table.
That means there are only 256 possible characters that can be used for conversion. While
this is generally fine for Latin based languages such as English, it imposes restrictions on
how multilingual computing is capable of being.

The solution to overcome this was the development of the UNICODE standard, which was
published in 1991. UNICODE is a 16-bit lookup table (65536 possible values). While this
means it takes 2 bytes to store every letter, the cost of data storage has fallen significantly
enough that that is not a major problem. The upside is it means all Asian characters etc. can
now be represented.

To look at the Unicode table for yourself, check out Unicode table

Watch the excellent video on introduction to Unicode : A whole new possibilities.

Simple logic gates

2.11 Define the Boolean operators: AND, OR, NOT, NAND, NOR and XOR

What is logic?

• Its how a machine will solve problems.


• Machines (at basic level) do not understand semantics like humans – no grey areas

1 0

True/On/Yes False/Off/No
Logic Gates

AND OR NOT

Truth Table

NAND NOR XOR

Truth Table
Logic Gates Symbols and Shapes

Combining gates Examples


Where can we find these gates in the real world?

Explore the following simulation tool Wolfram Alpha Boolean Algebra Calculator to
understand more about logic gates.

2.12 Construct truth tables using the above operators

It is a mathematical table that shows all possible outcomes that would occur from all possible
scenarios that are considered factual (i.e. is true), hence the name.

Here is a video that explains how to approach truth tables.

How many combinations do we need to test in the table?

Question: A chemical factory is equipped with three safety mechanisms. These safety mechanisms are
used to warn the local authorities for a potential accident. If safety mechanism A or safety mechanism B
are in the OFF position and if safety mechanism C is in the ON position, then there is no reason to worry
about an upcoming accident.

Write the logical expression and the truth table for the above scenario
Question: An alarm system has three inputs Q, W, R and one output I. When signal at Q is FALSE then the
output at l is the same as input signal R. When signal at Q is TRUE then the output at l is the same as input
signal W. Construct the truth table for this alarm system and then write the equivalent Boolean
expression.

Write the logical expression and the truth table for the above scenario

2.13 Construct a logic diagram using AND, OR, NOT, NAND, NOR and XOR gates

Y = NOT (A AND B) OR C

Activity

Using the following simulation tool construct the following logic.ly

1. Draw the logic circuit for the expression (p AND NOT q) OR NOT s
2. Draw the logic circuit for the expression (p OR NOT q) and NOT
3. Draw the logic circuit for the expression (p AND q) OR (q XOR (p AND r AND q))
Topic 3: Computational Thinking

What is a problem in computer science?

i) A problem can be a difficulty or hindrance. Something is a problem if it hinders


you from doing something or makes doing something more difficult.

Example: The problem with creating this report is I do not have the data from last

year.

ii) A problem can be a task or something to be done.

 Add the numbers 37 and 45.


 Add the numbers 15 and 74.
 Sort the list of students in this class by last name.
 Sort the list of students in this class by PID.

In computer science, we will focus on the second definition of a problem being a task.
Whenever we have to deal with a problem, we have to make one or more decisions.

Fig 1. - Decision making Process


There are many mathematical problems that remain unsolved. Some mathematical
unsolved problems include

 The Goldbach conjecture


 The Riemann hypothesis
 The conjecture that there exists a Hadamard matrix for every positive
multiple of 4
 The twin prime conjecture

However, we can posit that all these will, one day, be solved, and almost certainly by using
the decision—making process below.

Fig 2. - Decision making process is not linear. Sometimes it is necessary to return to a


previous stage

Programming involves the creation of a series of steps that will solve a problem. It is a
process of solving a problem in phases. It is very important to understand that a computer
program is a sequence of instructions that explains to the computer how to solve a specific
problem. Some problems are very complicated, while other problems are easy to solve.

Compare the following problems:

 Write a program that will calculate the probability of an earthquake in USA the
following 34 minutes.
 Write a program that will output ”Hello world”.

A Google search of the first problem returns 72,200,000 results. It will take you something
like 4178 days reading for 10 seconds, half of the results. And the funny thing is that it is
practically impossible to write a decent program to address the particular problem.

On the contrary Google will return 1,280,000 results for the second problem, and you will
find a perfect answer by clicking the first link.
Luckily, all problems that you are going to face during CS IB exams are easily
solvable by experienced students and it is easy to write an algorithmic solution!

What’s the best way to solve a problem?

An algorithm is a sequence of instructions or a set of rules to get something done. You


probably know the fastest route from school to home, for example, turn left, drive for five
miles, turn right. You can think of this as an ‘algorithm’ – as a sequence of instructions to get
you to your chosen destination. There are plenty of algorithms (i.e. routes) that will
accomplish the same goal; in this case, there are even algorithms (such as in your satnav) for
working out the shortest or fastest route.

How are algorithms used in the real world?

Search engines such as Bing or Google use algorithms to put a set of search results into
order, so that more often than not, the result we’re looking for is at the top of the front page.
Your Facebook news feed is derived from your friends’ status updates and other activity, but
it only shows that activity which the algorithm (EdgeRank) thinks you’ll be most interested
in seeing. The recommendations you get from Amazon, Netflix and eBay are algorithmically
generated, based in part on what other people are interested in. Given the extent to which
so much of their lives is affected by algorithms, it’s worth pupils having some grasp of what
an algorithm is.

What is computational thinking?

Computational thinking allows us to take a complex problem, understand what the


problem is and develop possible solutions. We can then present these solutions in a way that
a computer, a human, or both, can understand.

There are four key techniques (cornerstones) to computational thinking:

 decomposition - breaking down a complex problem or system into smaller, more


manageable parts
 pattern recognition – looking for similarities among and within problems
 abstraction – focusing on the important information only, ignoring irrelevant detail
 algorithms - developing a step-by-step solution to the problem, or the rules to follow
to solve the problem
Fig 3. - Components of computational thinking

Computational thinking involves taking that complex problem and breaking it down into a
series of small, more manageable problems (decomposition). Each of these smaller
problems can then be looked at individually, considering how similar problems have been
solved previously (pattern recognition) and focusing only on the important details, while
ignoring irrelevant information (abstraction). Next, simple steps or rules to solve each of
the smaller problems can be designed (algorithms).

Finally, these simple steps or rules are used to program a computer to help solve the complex
problem in the best way.

Thinking Computationally

Thinking computationally is not programming. It is not even thinking like a computer, as


computers do not, and cannot, think.

Simply put, programming tells a computer what to do and how to do it. Computational
thinking enables you to work out exactly what to tell the computer to do.
For example, if you agree to meet your friends somewhere you have never been before, you
would probably plan your route before you step out of your house. You might consider the
routes available and which route is ‘best’ - this might be the route that is the shortest, the
quickest, or the one which goes past your favourite shop on the way. You'd then follow the
step-by-step directions to get there. In this case, the planning part is like computational
thinking, and following the directions is like programming.

Another example might occur when playing a video game. Depending on the game, in order
to complete a level you would need to know:

 what items you need to collect, how you can collect them, and how long you have in
which to collect them
 where the exit is and the best route to reach it in the quickest time possible
 what kinds of enemies there are and their weak points

From these details you can work out a strategy for completing the level in the most efficient
way.

If you were to create your own computer game, these are exactly the types of questions you
would need to think about and answer before you were able to program your game.
Fig 4. - A gaming console

Both of the above are examples of where computational thinking has been used to solve a
complex problem:

 each complex problem was broken down into several small decisions and steps (eg
where to go, how to complete the level – decomposition)
 only the relevant details were focused on (eg weather, location of exit –
abstraction)
 knowledge of previous similar problems was used (pattern recognition...
 ...to work out a step by step plan of action (algorithms)
What is a flowchart?

A flowchart is a diagram that depicts a process, system or computer algorithm. They are
widely used in multiple fields to document, study, plan, improve and communicate often
complex processes in clear, easy-to-understand diagrams. Flowcharts, sometimes spelled as
flow charts, use rectangles, ovals, diamonds and potentially numerous other shapes to define
the type of step, along with connecting arrows to define flow and sequence.

Fig 5. - Flowchart symbols


Fig 6. - An example of Flowchart

Fig 7. - An example of Flowchart


Pseudocode

The main purpose of pseudocode is to help programmers develop computer programs.


Because pseudocode is written for humans the syntax used is not as strict as the one used in
computer languages. Pseudocode normally omits details that are not important for human
understanding of the algorithm. Computers can’t interpret a solution in pseudocode form
thus it should be converted to a computer language.

Please refer to the approved notation guide for pseudocode syntax.

Sample pseudocode

loop A from 1 to 2
output "THIS WILL BE PRINTED TWICE"
End loop
C = 1
loop while C < 5
output "THIS MESSAGE WILL BE PRINTED FOUR TIMES"
C = C +1
End loop
Fig - 8. The same algorithm expressed as a flowchart is presented:
Thinking Logically

The addition process does not require any decision to be taken. The following algorithm is
straight forward:

Input A
Input B
C=A+B
Output C
Some problems require the use of decisions. Suppose there is a pedestrian crossing that is
equipped with a light signal. If the signal is green, then crossing the road is safe and the
pedestrian can cross. If the signal is red, then the pedestrian should stop and wait. The
following figure illustrates the flowchart and the algorithm that corresponds to this scenario.

Two different alternative procedures (WAIT, PASS) could be followed.

Fig 9. - Conditional Operations

Decisions and conditional statements

A conditional statement performs different instructions depending on a Boolean test. The


if—then—else conditional statement is common across many programming languages and
human logic. Although some variations are common, the structure in pseudocode form is:

IF (Boolean condition) THEN


(Consequent)
ELSE
(Alternative)
END IF

When an If is used In an algorithm a Boolean condition is evaluated (x>0, X=Y etc.). If the
condition is true, the (Consequent) statement or statements will be executed. Otherwise, the
execution continues to the (Alternative) statement or statements. If there is no else branch,
the algorithm continues after the end if.

Sample IF ELSE pseudocode

A = input-.("Type a number")
If A=0 then
Output “1”
End If
If A+2 > 6 then
output “2"
End If
If NOT (A+2>6) AND NOT (A=0) then
Output "3"
End If

//A way to use if—end if


//It finds if a numbered entered is positive,

X = input ("Please enter a number")


If x > 0 then
output "Positive"
End If
if X = 0 then
output "0"
End If
If x < 0 then
output "Negative"
End if

Iteration associated with a given decision in a specified problem

Iteration is the process of repeating a series of instructions. It is extremely useful in


programming and is used to repeat a statement or a block of statements within an algorithm.
Iteration is expressed using the "from to loop” and the ”while loop” statements.

From to Loop (for loop)

//user selects the number of times


I = 0
X = input("How many times do you want to see the message")
loop I from 1 to X
output ("it will be printed (number entered) times")
End loop

While Loop

//use of while loop


//to print a message
//user selects the number of times
I = O
X = input("How many times do you want to see the message")
loop while I < x
I=I+1
output ("it will be printed (number entered) times")
End while
Thinking Ahead

Inputs and outputs required in a solution

Input is something that put into a program while output is something that is produced by
the program after a process.

It is known that Velocity (V) is defined as the speed of an object in a given direction. We use
the equation V = s/t to calculate an object's average velocity V.

So V equals velocity and is the output of our solution.

s equals the total displacement from the object‘s starting position, and it is one of the inputs
required in the solution.

t equals the time elapsed, and it is one of the inputs required in the solution.

Need for pre and post conditions

When cooking a meal for dinner a“ the necessary ingredients should be available before
cooking. This is the pre—condition of the algorithm cooking. After cooking a table is needed
to facilitate eating. This is the post—condition for a proper dinner.

Exception is an act or event that disrupts the anticipated flow of the program’s execution.
The exceptions take place during the execution of the program and can be effectively
handled by specific mechanisms that most modern programming languages provide. The
term exception at this point of the syllabus refers to an occasion or case that is not
compatible with the general rule.

Example Problem

A company has the following policy to calculate the end—of year bonus for its employees: If
the employee has worked for the company for 9 months or more then the bonus equals to
30% of his/her monthly safary. If the employee has worked for the company for less than 9
months and his/her salary is less than €2000 then the bonus equals to 20% of his/her
monthly salary. If the employee has worked for the company for less than 9 months and
his/her salary is equal or more than €2000 then the bonus equals 10% of his/her monthly
salary.

Solution

MONTHS = 0
SALARY = 0
BONUS
TOTAL
SALARY = input("what is the salary of the employee?")
MONTHS = input("I-low many months did he/she work?")

if MONTHS >= 9 then


BONUS = (30/100)*(SALARY)
TOTAL = BONUS +(SALARY * MONTHS)
else if MONTHS < 9 AND SALARY < 2000 then
BONUS = (20/100)*(SALARY)
TOTAL = BONUS+(SALARY * MONTHS)
else if MONTHS < 9 AND SALARY >= 2000 then
BONUS = (10/100)*(SALARY)
TOTAL = BONUS+(SALARY * MONTHS)
end if

output "TOTAL IS:" , TOTAL ,"Euros"


output "BONUS IS:" , BONUS ,"Euros"

Analyse an algorithm presented as a flow chart

Flowchart Representation Algorithm to solve a specific problem


Analyse an algorithm presented as pseudocode

Trace an algorithm

Suppose we want to trace the following algorithm


//Trace the algorithm

loop COUNT from O to MAX—6


if COUNT = 0 AND MAX > 0 then
output "Hello"
else if COUNT > 2 then
output "Go for it"
else
output "OK"
end if
end loop
SUM = SUM + COUNT
output "Total = ", SUM

The following table is the trace table for the algorithm:

MAX SUM COUNT OUTPUT COMMENTS

10 0 0 Hello COUNT= 0 AND MAX>0 TRUE

10 0 1 Ok COUNT = 0 AND MAX > 0 FALSE


COUNT > 2 FALSE

10 0 2 Ok COUNT=0 ANDMAX>O FALSE


COUNT>2FABE

10 0 3 Go for it COUNT=0 ANDMAX>0 FALSE


COUNT>2 TRUE

10 0 4 Go for it COUNT=0 AND MAX>0 FALSE


COUNT > 2 TRUE

10 0 4 Exit from Loop

10 5 5 Total = 5
Calculating the output of an algorithm

//Find the output of the following algorithm

MAX = 10
SUM = 0
COUNT = 0
loop COUNT from 0 to MAX - 4
SUM = MAX - 4
COUNT = MAX - 3
loop SUM from 3 to 4
if COUNT = 0 AND MAX > 0 then
output "Hello"
else if COUNT < 4 then
output "Go for it"
else
output "OK"
end if
end loop
end loop

SUM = SUM + COUNT


output "Total = ", SUM
output "MAX = ", COUNT

Answer:
OK
OK
Total = 13
MAX = 8

Identify the error

The following program is supposed to output all the common factors of two numbers. It contains an
error. Identify this error.

//This program is supposed


//to print the common factors of two numbers
//Find the error!!

FIRST = 14
SECOND = 12
output "Common factors of numbers" , FIRST ," and ", SECOND
loop COUNT from 1 to SECOND
if (FIRST mod COUNT = 0) 0R (SECOND mod COUNT = 0) then
output COUNT
end if
end loop
Wrong Output: Common factors of numbers 14 and 12
1
2
3
4
6
7
12

Answer:
if (FIRST mod COUNT = 0) OR (SECOND mod COUNT = 0) then should be
changed to
if (FIRST mod COUNT = 0) AND (SECOND mod COUNT = 0) then

Correct Output:
Common factors of numbers 14 and 12
1
2

Composite Variable

The places to store values described previously were all atomic in nature; that is, each place
could hold only one piece of data, which cannot be divided into smaller parts. We have also
used a string of letters within quotations to represent a message to be written out. As you
might expect, letters within quotations are called strings. If we were to store a string, the
number of locations required would depend on the number of characters in the string. Thus
a string is not atomic because it contains more than one value, but we tend to think of strings
as atomic anyway because we do not access the individual letters. In this section, we describe
two ways of collecting data items together, giving the collection a name, and accessing the
items individually or as a collection.

An array is a named collection of homogeneous items in which individual items are


accessed by their place within the collection. The place within the collection is called
an index. Although people usually start counting at one, most programming languages start
at zero— so that is what we will do here. Below figure shows an array with 10 items indexed
from 0 through 9.
Fig 10. - An array of ten numbers

If the array is called numbers, we access each value by the expression numbers[position]
where position, the index, is a value between 0 and 9

A = new Array()
N = 0
loop N from 0 to 9
A[N] = N+1
End loop
loop N from 0 to 9
output " Array position ", N ," contains the value", A[N]
End loop

Output:
Array position 0 contains the value 1
Array position 1 contains the value 2
Array position 2 contains the value 3
Array position 3 contains the value 4
Array position 4 contains the value 5
Array position 5 contains the value 5
Array position 6 contains the value 7
Array position 7 contains the value 8
Array position 8 contains the value 9
Array position 9 contains the value 10
Parallel Array

Also known as structure an array (SoA), multiple arrays of the same size such that the i-th
element of each array is closely related and all i-th elements together represent an object or
entity. An example parallel array is two arrays that represent x and y coordinates of n points.

Below is another example where we store the first name, last name and heights of 5 people
in three different arrays.

Fig 11. -Parallel Array

In the following example 10 students’ names and their equivalent grades will be used. The
array NAMES of type String will be used to hold the names of the students, while the array
GRADES of type Integer will hold the equivalent grades. The index of each array is the same
for the same student. It is very important when using parallel arrays to always access each
array at the same index when storing or retrieving values. This process guarantees the
reference of corresponding data elements.
Fig 12. - Sample pseudocode on parallel array

Output
--------------
Student List
--------------

No 1 --Student May --Mark 99


No 2 --Student Eri --Mark 55
No 3 --Student Elen --Mark 77
No 4 --Student Rit --Mark 45
No 5 --Student Rato --Mark 89
No 6 --Student More --Mark 98
No 7 --Student Epi --Mark 76
No 8 --Student Ent --Mark 45
No 9 --Student Ronal --Mark 33
No 10 --Student Bib --Mark 75

--------------
Statistics
--------------

Minimum mark 33 Student Ronal


Maximum mark 99 Student May
Class average 69.2

Two dimensional arrays

“Although two dimensional arrays do not appear in the SL syllabus it is strongly recommended
to study them. The understanding of the structure and function of 2D arrays enhances various
algorithmic skills.”

A one dimensional array should be considered as a single line of elements. However, in many
cases, data comes in the form of a data table. A typical example is a table that depicts the
average monthly temperature for 10 cities.

Fig 12. - 2D Array

2D arrays are indexed by two subscripts. The indices must be integers. The first one refers
to the row and the second to the column. TEMP [1] [1] refers to February temperature of
City 2. The value is 27. Each element in a two dimensional array must be of the same data
type.

TEMP =
[[10,11,12,13,10],
[10,13,14,12,12],
[13,13,14,15,12],
[16,17,17,17,16],
[22,23,24,24,24],
[26,25,24,25,26],
[29,28,26,27,26],
[29,28,27,28,28],
[24,23,24,25,25],
[20,21,22,23,24],
[15,16,17,18,18],
[12,11,13,11,11]]

MONTH = 0
CITY = 0

loop MONTH from 0 to 11


output MONTH +1, "Month"

loop CITY from 0 to 4


output "City", CITY+1, TEMP[MONTH] [CITY]
End loop
End loop

Sample Example using Java

class GFG {
public static void main(String[] args)
{

int[][] arr = { { 1, 2 }, { 3, 4 } };

for (int i = 0; i < 2; i++) {


for (int j = 0; j < 2; j++) {
System.out.print(arr[i][j] + " ");
}

System.out.println();
}
}
}

Comparison of one-dimensional arrays, two dimensional arrays, parallel arrays and


arrays of objects.

Suppose a programmer wants to develop a program that will use a data structure to store
lesson grades information for five students. Each student is represented by a record. Five
different data fields are used for each student. Two data fields of type string will be used to
store Name and Surname while two integer data fields will be used to store the grades for
Math and Chemistry respectively. The following table illustrates the scenario described:
A one dimensional array is not able to store all the necessary information because it can only
store one data type and apparently it can only store one field. So, the programmer should
use five different one dimensional arrays, which shall be used as parallel arrays.

A two dimensional array cannot solve the problem because it can only store one data type.
50, the programmer will need one two dimensional array to store data for Name and
Surname fields and one two dimensional array to store data for Math grade field and
Chemistry grade field. The programmer will use these two arrays as parallel arrays.

The creation of an array of Student objects named A can facilitate the situation. Each Student
object will have the following data fields: Name, Surname, Math_grade and Chemistry_grade.
The programmer will construct an array of student objects with the following objects:

Studentl [Name: "James" , Surname:"Smith” , Math_grade:89 , Chemistry_grade:78]

Sequential Search

Binary Search

Binary search (or half interval search) algorithm is a searching method used only in sorted
m. It relies on divide and conquer strategy to accomplish its purpose. In every search
iteration, half of the elements of the array are eliminated as possible solutions. Binary search
is very efficient for large arrays. Its performance makes it ideal when resorting is not
required.

In each iteration, the algorithm

1. Compare the search value with the value of the middle element of the array.

a. If the values match, then the value was found.

b. If the search value is less than the middle element of the array, then the algorithm

repeats its action on the sub-array to the left of the middle element.

c. if the search value is greater than the middle element of the array, then the algorithm

repeats its action on the sub-array to the right of the middle element.

2. If the remaining array to be searched is empty, then the value was not found.

VALUES = [11,12,15,16,112,118,123,145] //sorted array elements


TARGET = 15 //search value

MIN = 0
HIGH = 7 // Number of array elements - l
FOUND = false
ANSWER = 0
MID =0

loop while FOUND = false AND MIN <= HIGH


MID = ((MIN + HIGH) div 2)
If VALUES[MID] = TARGET then
FOUND = true
ANSWER = MID
Else if TARGET > VALUES [MID] then
MIN = MID + 1
Else
HIGH = MID - 1
End if
End while
If FOUND = true then
output TARGET , "FOUND AT ARRAY INDEX" , ANSWER
Else
output TARGET , " was not found"
End if
Implementation of Binary search using JAVA

// Java implementation of iterative Binary Search

class BinarySearch {
// Returns index of x if it is present in arr[],
// else return -1
int binarySearch(int arr[], int x)
{
int l = 0, r = arr.length - 1;
while (l <= r) {
int m = l + (r - l) / 2;

// Check if x is present at mid


if (arr[m] == x)
return m;

// If x greater, ignore left half


if (arr[m] < x)
l = m + 1;

// If x is smaller, ignore right half


else
r = m - 1;
}

// if we reach here, then element was


// not present
return -1;
}

// Driver method to test above


public static void main(String args[])
{
BinarySearch ob = new BinarySearch();
int arr[] = { 2, 3, 4, 10, 40 };
int n = array.length;
int x = 10;
int result = ob.binarySearch(arr, x);
if (result == -1)
System.out.println("Element not present");
else
System.out.println("Element found at "
+ "index " + result);
}
}
Linear and Binary search simulation here.

Sorting Algorithms

A Sorting Algorithm is used to rearrange a given array or list elements according to a


comparison operator on the elements. The comparison operator is used to decide the new order
of elements in the respective data structure.

Bubble sort

Bubble sort is a simple sorting algorithm that repeatedly steps through the array to be
sorted. It compares adjacent items (pairs of adjacent array elements) and exchanges them if
they are not in the correct order (ascending or descending). The algorithm makes multiple
passes until no swaps are necessary and the elements of the array are sorted.

ELEMENTS = [1,663,8,2,4,1,22,66,20,122]
loop I from 0 to 8// Number of elements - 2
loop J from 0 to (8-I)
if ELEMENTS[J] < ELEMENTS[J + 1] then //for descending order
OR
if ELEMENTS[J] > ELEMENTS[J + 1] then //for ascending order

TEMP = ELEMENTS[J]
ELEMENTS[J] = ELEMENTS[J+1]
ELEMENTS[J+1] = TEMP
Endif
Endloop
Endloop

output "Sorted elements"

loop E from 0 to 9
output ELEMENTS [E]
end loop

Trace Table for Bubble Sort


Bubble sort simulation here.
Selection Sort
The selection sort algorithm sorts an array by repeatedly finding the minimum element
(considering ascending order) from the unsorted part and putting it at the beginning. The
algorithm maintains two subarrays in a given array.

1) The subarray which is already sorted.


2) Remaining subarray which is unsorted.

In every iteration of selection sort, the minimum element (considering ascending order)
from the unsorted subarray is picked and moved to the sorted subarray.

Following example explains the above steps:

arr[] = 64 25 12 22 11

// Find the minimum element in arr[0...4]


// and place it at beginning
11 25 12 22 64

// Find the minimum element in arr[1...4]


// and place it at beginning of arr[1...4]
11 12 25 22 64
// Find the minimum element in arr[2...4]
// and place it at beginning of arr[2...4]
11 12 22 25 64

// Find the minimum element in arr[3...4]


// and place it at beginning of arr[3...4]
11 12 22 25 64

//=== Selection Sort ====


ELEMENTS = [1,5,3,86,256,420,9,510,51,24,60]
MIN= O
I = 0
TEMP= 0
loop MIN from 0 to 9
I = MIN
loop CURRENT from MIN+1 to 10
if ELEMENTS[CURRENT] > ELEMENTS[I] // for descending order
OR
if ELEMENTS[CURRENT] < ELEMENTS[I] // for ascending order
I = CURRENT
End if
End loop
TEMP = ELEMENTS[I]
ELEMENT[I] = ELEMENTS [MIN]
ELEMENTS [MIN] = TEMP
End loop
output “SORTED ARRAY”
loop C from 0 to 10
output ELEMENTS[C]
End loop

Selection Sort simulation here.

Watch the following video on how the selection sort works.

Collections

An array is a perfect choice when a programmer wishes to store the same type of information; a group
of strings for example and he/she knows in advance the number of items that he/she wishes to store.
But what happens when the programmer wishes to store integers, arrays, objects, booleans and strings
in one data structure? The answer is to use collections because some collections allow custom
specification of the collection Item elements.

Collections store a set of elements. The elements may be of any type (numbers, objects, arrays,
Strings, etc.). A collection provides a mechanism to iterate through all of the elements that it
contains. The following code is guaranteed to retrieve each item in the collection exactly once.

// STUFF is a collection that already exists


STUFF.resetNext()
loop while STUFF.hasNext()
ITEM = STUFF.getNext()
// process ITEM in whatever way is needed
end loop

Standard Operations in Collections


Example on how to use Collections
For understanding implementation of collection in Java read the article here. Please
note that the collection in Java is not included in your syllabus but it is a useful resource.

Use of collection of objects

Suppose a programmer wants to create a collection of vehicle objects‘ Each vehicle object
has the following data fields: Colour, Type and Engine. The programmer wants to manipulate
the following objects:

Vehiclel [Colour "red” - Type: "car” - Engine:2000]


Vehicle2 [Colour: "green" - Type: ”bus" - Engine:4000]
Vehicle3 [Colour ”blue” - Type: "motorcycle" - Engine2800]

The following program adds the objects in the collection and outputs the one that is of type
“bus”.

Vehicle1 = new vehicle (setColour =”red”, setType=”car”,


setEngine=2000)
Vehicle2 = new vehicle (setColour =”green”, setType=”bus”,
setEngine=4000)
Vehicle3= new vehicle (setColour =”b1ue”,
setType=”motorcycle”,setEngine =800)

VEHICLES = new Collection()


VEHICLES.addItem(Vehic1e1)
VEHICLES.addItem(Vehicle2)
VEHICLES.addItem(Vehic1e3)
VEHICLES.resetNext()

output "This Vehicle is a bus"


loop while VEHICLES.hasNext()
Vehicle v = VEHICLES.getNext()
if VehicleV.getType ="bus" then
output VehicleV
End if
End loop

Use of collection of arrays

//Array1.length returns the length of the Array used


Monday = [“Tom", “John”, “Mary”, “Bob”]
Tuesday = [“Bob”, “Tom”, “Eri”]

X=0

Arrayl = new Array()


ABSENCES = new Collection()
ABSENCES.addItem(Monday)
ABSENCES.addItem(Tuesday)
ABSENCES.resetNext()

loop while ABSENCES.hasNext()


Arrayl = ABSENCES.getNext()
loop N from 0 to Array1.length — 1
if Array1[N1=”Bob” then
X=X+1
End if
End loop
End loop

output " Bob found ", X ," times"

Discuss the importance of sub-programmes and collections within programmed


solutions.

A sub-program is a unit that contains a sequence of computer instructions that perform a


specific and predefined task. Code reuse is very useful because it allows programmers to
take advantage of existing code and solutions developed by other programmers (or by
themselves) to speed up their tasks. Code reuse saves time and resources and allows the
completion of demanding projects in the shortest period of time. Authors of new programs
can take advantage of software libraries, which contain subprograms that can be used by
different types of programs

Advantages of breaking a program into sub-programs:

- Breaking down a complex programming job into simpler jobs.


- Distributing a very large programming problem among various programmers all over
the world.
- Enabling code reuse across multiple programs.
- Facilitation of abstraction by hiding implementation details from users of the
subprogram.
- Improving maintainability and traceability.
- Reducing programming code duplication within the same program.

Advantages of using collections:

 The methods of collections are predefined algorithms that the programmer can
immediately use.
 Performance is increased by the data management capabilities provided by the
collection.
 Software reuse is facilitated because the use of methods is based on a common
language and a standard interface.

Example of using Collections

Two parallel arrays named FIRE_STATIONS and PERSONNEL hold the names of the fire
stations in a city and the number of their personnel. The arrays are as shown:

Each week one fire station is on night duty. A collection named FIRE_DUTY retrieves the
names from the array FIRE_STATIONS and uses an automatic procedure to keep track of
the fire station on night duty. The mayor of the city activates this automatic procedure every
Monday morning by writing "true” in an input device located in his/her office. The
procedure iterates through the collection FIRE_DUTY and changes the name of the fire
station on night duty. When the procedure reaches the end of the collection, it returns to the
first fire station and the procedure starts from the beginning. This process is repeated for
one year (52 weeks). The Mayor has also asked for an alarm message when the selected on
duty station is understaffed which means that it has the minimum personnel if compared to
all stations. He has also asked for an emergency procedure that will stop the entire process
immediately by writing "false” in the input device.
FIRE_STATIONS = ["ALPHA", "BETA", "‘THETA", "CENTER", "RAILWAY",
"HARBOR","SUBURB"]
PERSONNEL = [2, 13, 23, 44, 23, 11, 43]
FIRE_DUTY = new Collection()
STATION_ON_DUTY = ""
M = 0
MIN = PERSONNEL[O]
UNDERSTAFFED = ""
INPUT_DEVICE = ""

FIRE_DUTY . resetNext ()
loop I from 0 to 6
FIRE_DUTY . addI tern (FIRE_STATIONS { 1'. 1 )
End loop

loop M from 0 to 6
if MIN >= PERSONNEL [M] then
MIN = PERSONNEL [M]
UNDERSTAFFED = FIRE_STATIONS [M]
End if
End loop

I = 0
loop while I <= 52
input INPUT_DEVICE
if INPUT_DEVICE == "true" then
if FIRE_DUTY.hasNext() then
STATION_0N_DUTY = FIRE_DUTY.getNext()
if STATION_ON_DUTY = UNDERSTAFFED then
output "This station is understaffed"
End if
output STATION_ON_DUTY
Else
FIRE_DUTY.resetNext()
STATION_0N_DUTY = FIRE_DUTY.getNext()
if STATION_ON_DUTY = UNDERSTAFFED then
output "This station is understaffed"
End if
output STATION_ON_DUTY
End if
Else if INPUT_DEVICE == "false” then
I=53
output "Emergency stop of procedure"
End if
I = I+1
End loop
The mayor of the previous example asked for an extra functionality. He believes that a fire
station should have at least 25 firefighters. The program should calculate the fire stations
that have less than 25 firefighters and display a message. This message should include the
number of personnel that the particular station lacks.

How will you solve it?

Construct an algorithm and write a program in java based on the following problem
given below.

Calculate the Body Mass Index, which is an indicator of body fatness. The formula
used for adults is Formula: weight (kg) / [height (m)]

You might also like