Tutorial Kit (CIS-400 L) - Vol. 2
Tutorial Kit (CIS-400 L) - Vol. 2
UNIVERSITY
ALPHA SEMESTER TUTORIAL KIT (VOL. 2)
PROGRAMME:CIS
400
LEVEL
DISCLAIMER
The contents of this document are intended for practice and learning purposes at the
undergraduate level. The materials are from different sources including the internet and the
contributors do not in any way claim authorship or ownership of them. The materials are also not
to be used for any commercial purpose.
1
LIST OF COURSES
CSC411: Software Engineering
CSC413: Algorithm & Complexity
Analysis CSC415: Artificial Intelligence
CSC431: Computational Science & Numerical Methods
I CSC432: File Processing
CSC433: Computer Graphics and
Animation MIS412: Knowledge
Management
MIS415: Project Management
2
COVENANT UNIVERSITY
CANAANLAND, KM 10, IDIROKO ROAD
P.M.B 1023, OTA, OGUN STATE, NIGERIA.
TITLE OF EXAMINATION: B.Sc EXAMINATION
COLLEGE: Science and Technology
DEPARTMENT: Computer and Information Sciences
SESSION: 2015/2016 SEMESTER: ALPHA
COURSE CODE: CSC411 UNIT: 3 COURSE TITLE: SOFTWARE ENGINERRING
INSTRUCTION: Answer Question 1 and any other Three (3) questions TIME: 3Hhrs
1a i)Define the following: i) Software Engineering ii) Software Product iii) Software Process
iv) Software Engineering Methods
[6mks]
ii). What are the differences between generic software product development and custom software
development? [2mks]
b. Draw a context model for a patient information system in a hospital. You may make any
reasonable assumptions about the other hospital systems that are available, but your
model must include a patient
admissions system and an image storage system for X-rays, as well as other diagnostic
records [5mks]
c). Based on your experience with a bank ATM, draw a data-flow diagram modelling the data
processing involved when a customer withdraws cash from the machine.
[7mks]
d). Use the Testing Scenario below to generate at least five (5) Test Cases for a System Test on
Project Management System (PMS).
A final year student in CIS department is working on a project. The student is stock and needs to
get copies of previous projects related to his work. CIS department has a system called PMS
that manages previous projects. He logs on to the system and is able to use the search facility
of PMS to find e-copies of related projects. He is allowed to download only three copies per
day. If he needs more then he uses a module in PMS that request for permission and registers
his request. If granted he has privilege to download only two more for that day. [5mks]
3
2a. Develop a sequence diagram showing the interactions involved when a student registers for
a course in a university.
Courses may have limited enrolment, so the registration process must include checks that
places are available.
Assume that the student accesses an electronic course catalogue to find out about available
courses. [5mks]
3a. Discuss the following software development process models. Include appropriate diagrams.
i)Waterfall Model ii) Spiral Model [10mks]
5ai) Discuss the differences between verification and validation, and explain why validation is
a particularly difficult
process. [4mks]
ii) Explain why it is not necessary for a program to be completely free of defects before it is
delivered to its customers.
To what extent can testing be used to validate that the program is fit for its
purpose? [6mks]
4
b) Explain why program inspections are an effective technique for discovering errors in a
program. [5mks]
6a. Explain the Software Testing Process. Include the appropriate diagram
[6mks]
Marking Guide
1a i)Define the following: i) Software Engineering ii) Software Product iii) Software
Process iv) Software Engineering Methods
[6mks]
6
effective way
[1 ½ mks]
ii). What are the differences between generic software product development and
custom software development?
b.Draw a context model for a patient information system in a hospital. You may make
any reasonable assumptions about the other hospital systems that are available, but
your model must include a patient admissions system and an image storage system for
X-rays, as well as other diagnostic records [5mks]
[5mks]
c). Based on your experience with a bank ATM, draw a data-flow diagram modelling
the data processing involved when a customer withdraws cash from the
machine. [7mks]
7
[7 mks]
d). Use the Testing Scenario below to generate at least five (5) Test Cases for a System
Test on Project Management System (PMS).
A final year student in CIS department is working on a project. The student is stock and
needs to get copies of previous projects related to his work. CIS department has a
system called PMS that manages previous projects. He logs on to the system and is
able to use the search facility of PMS to find e-copies of related projects. He is allowed
to download only three copies per day. If he needs more then he uses a module in
PMS that requests for permission and registers his request. If granted he has privilege
to download only two more for that day.
[5mks]
Test case for PMS
i) Test the login mechanism using correct and incorrect logins to check that valid users
are accepted and invalid users are rejected. [1mk]
ii) Test the search facility using different queries against known sources to check that
the search mechanism is actually finding documents. [1 mk]
iii) Test the system presentation facility to check that information about the projects is
displayed properly. [1 mk]
iv) Test the mechanism for requesting for permission to download additional projects
[1mk] v) Test the system mechanism that grants permission download additional
projects to ensure that only additional two projects are allowed for download after the
initial three. [1 mk]
2a. Develop a sequence diagram showing the interactions involved when a student
registers for a course in a university. Courses may have limited enrolment, so the
registration process must include checks that places are available. Assume that the
student accesses an electronic course catalogue to find out about available courses.
[5mks]
[5 mks]
8
b.i) Discuss the major challenges facing Software Engineering.
[6mks]
∙ The heterogeneity challenge: Increasingly, systems are required to operate as
distributed systems across networks that include different types of computers and
with different kinds of support systems. It is often necessary to integrate new
software with older legacy systems written in different programming languages. The
heterogeneity challenge is the challenge of developing techniques for building
dependable software that is flexible enough to cope with this heterogeneity. [2 mks]
∙ The trust challenge: As software is intertwined with all aspects of our lives, it is
essential that we can trust that software. This is especially true for remote software
systems accessed through a web page or web service interface. The trust challenge
is to develop techniques that demonstrate that software can be trusted by its users.
[2 mks]
ii) State the differences between the following: i) User Requirement and System
Requirements ii) Functional and Non-functional Requirements [4mks]
∙ System requirements set out the system’s functions, services and operational
constraints in detail. The system requirements document (sometimes called a
functional specification) should be precise. It should define exactly what is to be
implemented. It may be part of the contract between the system buyer and the
software developers. [1 mk]
∙ Functional requirements - these are statements of services the system should provide,
how the system should react to particular inputs and how the system should behave
in particular situations. In some cases, the functional requirements may also
explicitly state what the system should not do. [1 mk]
9
Non-functional requirements often apply to the system as a whole. They do not
usually just apply to individual system features or services. [1 mk]
3a. Discuss the following software development process models. Include appropriate
diagrams. i) Waterfall Model ii) Spiral Model [10mks]
Waterfall Model
The first published model of the software development process was derived from more
general system engineering processes. Because of the cascade from one phase to
another, this model is known as the waterfall model or software life cycle. The principal
stages of the model map onto fundamental development activities:
i) Requirements analysis and definition - the system’s services, constraints and goals
are established by consultation with system users. They are then defined in detail and
serve as a system specification. [1/2 mk]
ii) System and software design - the systems design process partitions the requirements
to either hardware or software systems. It establishes an overall system architecture.
Software design involves identifying and describing the fundamental software system
abstractions and their relationships. [1/2 mk]
iii) Implementation and unit testing - during this stage, the software design is realized as
a set of programs or program units. Unit testing involves verifying that each unit meets
its specification. [1/2 mk]
iv) Integration and system testing - the individual program units or programs are
integrated and tested as a complete system to ensure that the software requirements
have been met. After testing, the software system is delivered to the customer. [1/2 mk]
v) Operation and maintenance - normally (although not necessarily) this is the longest
life-cycle phase. The system is installed and put into practical use. Maintenance
involves correcting errors which were not discovered in earlier stages of the life cycle,
improving the implementation of system units and enhancing the system’s services as
new requirements are discovered. [1/2 mk]
[2/ ½ mks]
10
Spiral Model
The spiral model of the software process was originally proposed by Boehm. Rather
than represent the software process as a sequence of activities with some backtracking
from one activity to another, the process is represented as a spiral. Each loop in the
spiral represents a phase of the software process. Thus, the innermost loop might be
concerned with system feasibility, the next loop with requirements definition, the next
loop with system design and so on. Each loop in the spiral is split into four sectors:
1. Objective setting Specific objectives for that phase of the project are defined.
Constraints on the process and the product are identified and a detailed management
plan is drawn up. Project risks are identified. Alternative strategies, depending on these
risks, may be planned. [½ mk]
2. Risk assessment and reduction - for each of the identified project risks, a detailed
analysis is carried out. Steps are taken to reduce the risk. For example, if there is a risk
that the requirements are inappropriate, a prototype system may be developed. [½ mk]
3. Development and validation - after risk evaluation, a development model for the
system is chosen. For example, if user interface risks are dominant, an appropriate
development model might be evolutionary prototyping. If safety risks are the main
consideration, development based on formal transformations may be the most
appropriate and so on. [½ mk]
4. Planning - the project is reviewed and a decision made whether to continue with a
further loop of the spiral. If it is decided to continue, plans are drawn up for the next
phase of the project. [½ mk]
The main difference between the spiral model and other software process models is the
explicit recognition of risk in the spiral model. Informally, risk simply means something
that can go wrong. For example, if the intention is to use a new programming language,
a risk is that the available compilers are unreliable or do not produce sufficiently efficient
object code. Risks result in project problems such as schedule and cost overrun so risk
minimisation is a very important project management activity. [½ mk]
[2 ½ mks]
11
b. Suggest who might be stakeholders in a university student records system. Explain
hy it is almost inevitable that the requirements of different stakeholders will conflict in
some way. [5mks]
In a fast-moving business environment, this can cause real problems. By the time the
software is available for use, the original reason for its procurement may have changed
so radically that the software is effectively useless. Therefore, for business systems in
particular, development processes that focus on rapid software development and
delivery are essential. [1 mk]
12
Rapid software development processes are designed to produce useful software quickly.
Generally, they are iterative processes where specification, design, development and
testing are interleaved. The software is not developed and deployed in its entirety but in
a series of increments, with each increment including new system functionality. [1 mk]
Agile methods should not be used when the software is being developed by teams who
are not co located – if any of these teams use agile methods, it is very difficult to
coordinate their work with other teams[1 mk]. Agile methods should probably also be
avoided for critical systems where the consequences of a specification error are
serious. [1 mk]In those circumstances, a system specification that is available before
development starts makes a detailed specification analysis possible. However, some
ideas from agile approaches such as test first development are certainly applicable to
critical systems [1 mk].
b i)Suggest four (4) reasons why the productivity rate of programmers working as a pair
is roughly the same as two programmers working individually.
[4mks]
Reasons why pair programming is as efficient as the same number of programmers
working individually:
∙ Pair programming leads to continuous informal reviewing. This discovers bugs more
quickly than individual testing. [1 mk]
∙ Information sharing in pair programming is implicit – it happens during the process.
Individual programmers have to spend time explicitly sharing information. [1 mk]
∙ Pair programming encourages refactoring (the code must be understandable to
another person). This reduces the costs of subsequent development and change. [1
mk]
∙ In pair programming, people are likely to spend less time in fine-grain optimization as
this does not benefit the other programmer. [1 mk]
ii)Extreme programming expresses user requirements as stories, with each story written
on a card. Discuss the advantages and disadvantages of this approach to requirements
description. [4mks]
Advantages of stories:
∙ They represent real situations that commonly arise so the system will support the most
common user operations. [1 mk]
∙ It is easy for users to understand and critique the stories. [ ½ mk]
∙ They represent increments of functionality – implementing a story delivers some
value to the user.
[½
mks]
13
Disadvantages of stories
∙ They are liable to be incomplete and their informal nature makes this incompleteness
difficult to detect.
[½
mk]
∙ They focus on functional requirements rather than non-functional requirements. [½ mk]
∙ Representing cross-cutting system requirements such as performance and reliability is
impossible when stories are used. [½ mk]
∙ The relationship between the system architecture and the user stories is unclear so
architectural design is difficult. [½ mk]
5ai) Discuss the differences between verification and validation, and explain why
validation is a particularly difficult process. [4mks]
ii) Explain why it is not necessary for a program to be completely free of defects before
it is delivered to its customers. To what extent can testing be used to validate that the
program is fit for its purpose? [6mks]
Testing cannot completely validate that a system is fit for its intended purpose as this
requires a detailed knowledge of what that purpose will be and exactly how the system
will be used. As these details inevitably change between deciding to procure a system
and deploying that system, the testing will be necessarily incomplete. In addition, it is
practically impossible for all except trivial system to have a complete test set that covers
all possible ways that the system is likely to be used. [3 mks]
bi) Explain why program inspections are an effective technique for discovering
errors in a program. [5mks]
14
i)They can find several faults in one pass without being concerned about interference
between program faults. [1 ½ mks]
ii)They bring a number of people with different experience of different types of errors.
Hence, the team approach offers greater coverage than any individual can bring. [1 ½
mks]
iii)They force the program author to re-examine the program in detail - this often reveals
errors or misunderstandings. [1 ½ mks]
The types of errors that inspections are unlikely to find are specification errors or errors
that are based on a misunderstanding of the application domain (unless there are
domain experts in the team) [½ mk]
6a. Explain the Software Testing Process. Include the appropriate
diagram [6mks]
Test cases are specifications of the inputs to the test and the expected output from the
system plus a statement of what is being tested [1 mk]. Test data are the inputs that
have been devised to test the system. Test data can sometimes be generated
automatically [1 mk]. Automatic test case generation is impossible. The output of the
tests can only be predicted by people who understand what the system should do.
Exhaustive testing, where every possible program execution sequence is tested, is
impossible. Testing, therefore, has to be based on a subset of possible test cases.
Ideally, software companies should have policies for choosing this subset rather than
leave this to the development team. [1 mk]
[3 mks]
bi) Differentiate between White Box and Black Box Testing
[5mks]
[1 mks]
[1mk]
[1 mk]
15
[1 mk]
[1 mk]
ii) Explain why interface testing is necessary even when individual components
have been extensively validated through component testing and program
inspections.
[4mks]
There are several reasons why interface testing is a necessary stage after unit testing:
∙ The interface to the module may have been incorrectly specified. The validation
process is based on this specification rather than actual usage of the module or
sub-system. [2 mks]
• The assumptions made by other modules about the behaviour of a given module (A
say) in response to particular interface stimuli may be incorrect. That is, these modules
expect A to behave in a way in which it was never designed to operate. [1mk]
• Interface testing can reveal omissions in the interface design. It may be discovered,
when integrated with other modules, that the interface must be augmented in some way.
[1mk]
16
COVENANT UNIVERSITY
CANAANLAND, KM 10, IDIROKO ROAD
P.M.B 1023, OTA, OGUN STATE, NIGERIA.
TITLE OF EXAMINATION: B.Sc DEGREE EXAMINATION
COLLEGE: SCEINCE AND TECHNOLOGY
SCHOOL: NATURAL AND APPLIED SCIENCES
DEPARTMENT: COMPUTER AND INFORMATION SCIENCES
SESSION: 2014/2015 SEMESTER: ALPHA COURSE CODE: CSC 411 CREDIT UNIT: 3 Units
COURSE TITLE: SOFTWARE ENGINEERING
INSTRUCTION: ANSWER QUESTION ONE (1) AND ANY OTHER THREE (3)
QUESTIONS Time: 3 Hours
1. Attempt any two case studies from the options (a-c) given as follows:
a. Describe a package of software-controlled instruments for Weather station. Briefly explain the weather
station object classes. Demonstrate all classes with diagram.
(12.5marks)
b. What do you understand by Form-based specification and Tabular specification? Give an example of
computing insulin dose: Safe sugar level for a sugar patient.
(12.5marks)
c. By giving example of library: 1. Explain requirements based testing 2. Summarize the LIBSYS
requirements 3. LIBSYS tests
(12.5marks)
2.
a. Write down the key attributes of ‘good’ software. Summarize the key challenges which software
engineering is facing.
(5marks)
b. Summarize the ethical and profession responsibilities of a software engineer.
(5marks)
c. Describe (with diagram) the spiral model. Show all stages of spiral model.
(5marks)
3.
a. What do you understand by context model? Explain context model by giving an example. (5marks)
b. Define the process model. Draw process model for equipment procurement process.
(5marks)
c. Explain state machine model and give an example of Microwave oven (draw state machine model for
microwave oven).
(5marks)
17
4.
a. Define the architectural design and software architecture. Summarize the architecture and system
characteristics. (5marks)
b. Summarize the questions for architecture design decision. Discuss different types of architecture models.
(5marks)
c. What do you understand by the repository model? Give an example of CASE tool architecture. Summarize
repository model characteristics.
(5marks)
5.
a) Why is there a need for rapid action software development? Explain the Characteristics of RAD
processes. (5marks)
b) Show the diagram for an iterative development process. Summarize advantages and disadvantages of
iterative development processes.
(5marks)
c) What do you understand by agile method? Summarize the principles of agile methods.
(5marks)
6.
a. What do you understand by non-functional requirement classifications? Show a tree diagram of the non
functional requirements classification.
(5marks)
b. What is the difference between testing and debugging? Summarize the structure of a software test plan.
Explain each step in brief.
(5marks)
c. Summarize in brief: 1) Performance testing 2) Stress Testing 3) Component testing and 4) Object class
testing (5marks)
18
1b
Form based specifications
∙ Definition of the function or entity.
∙ Description of inputs and where they come from.
∙ Description of outputs and where they go to.
∙ Indication of other entities required.
∙ Pre and post conditions (if appropriate).
∙ The side effects (if any) of the function.
Tabular specification
∙ Used to supplement natural language.
∙ Particularly useful when you have to define a number of possible alternative courses of action.
19
1c
LIBSYS tests
20
Ans 2 a
The software should deliver the required functionality and performance to the user and should be maintainable,
dependable and acceptable.
∙ Maintainability: Software must evolve to meet changing needs;
∙ Dependability: Software must be trustworthy;
∙ Efficiency: Software should not make wasteful use of system resources;
∙ Acceptability: Software must accepted by the users for which it was designed.
This means it must be understandable, usable and compatible with other systems.
Confidentiality: Engineers should normally respect the confidentiality of their employers or clients irrespective of
whether or not a formal confidentiality agreement has been signed.
Competence: Engineers should not misrepresent their level of competence. They should not knowingly accept work,
which is out with their competence.
Intellectual property rights: Engineers should be aware of local laws governing the use of intellectual property such
as patents, copyright, etc. They should be careful to ensure that the intellectual property of employers and clients is
protected.
Computer misuse: Software engineers should not use their technical skills to misuse other people’s computers.
Computer misuse ranges from relatively trivial (game playing on an employer’s machine, say) to extremely serious
(dissemination of viruses).
21
2c:
Process is represented as a spiral rather than as a sequence of activities with backtracking.
∙ Each loop in the spiral represents a phase in the process.
∙ No fixed phases such as specification or design loops in the spiral are chosen depending on what is
required.
∙ Risks are explicitly assessed and resolved throughout the process.
__________________________________________________________
Ans 3a.
Context model
∙ Context models are used to illustrate the operational context of a system they show what lies outside the
system boundaries.
∙ Social and organisational concerns may affect the decision on where to position system boundaries. ∙
Architectural models show the system and its relationship with other systems.
3 b. Process models show the overall process and the processes that are supported by the system. Data flow
models may be used to show the processes and the flow of information from one process to another.
22
They show the system’s responses to stimuli so are often used for modelling real time systems.
State machine models show system states as nodes and events as arcs between these nodes. When an event occurs,
the system moves from one state to another.
Statecharts are an integral part of the UML and are used to represent state machine models.
____________________________________________
4 a. The design process for identifying the subsystems making up a system and the framework for subsystem control
and communication is architectural design.
23
Performance: Localise critical operations and minimise communications. Use large rather than fine-grain
components.
Security: Use a layered architecture with critical assets in the inner layers.
Safety: Localise safety critical features in a small number of subsystems.
Availability: Include redundant components and mechanisms for fault tolerance.
Maintainability: Use fine grain, replaceable components.
Ans 4b
Ans 4c
• Shared data is held in a central database or repository and may be accessed by all subsystems;
∙ Each subsystem maintains its own database and passes data explicitly to other subsystems. When
large amounts of data are to be shared, the repository model of sharing is most commonly used.
24
Advantages
• Efficient way to share large amounts of data;
• Subsystems need not be concerned with how data is produced. Centralised management e.g. backup, security, etc.
• Sharing model is published as the repository schema.
Disadvantages
• Subsystems must agree on a repository data model.
Inevitably a compromise;
• Data evolution is difficult and expensive;
• No scope for specific management policies;
• Difficult to distribute efficiently
_______________________________________________________
Ans 5 a
Because of rapidly changing business environments, businesses have to respond to new opportunities and
competition.
This requires software and rapid development and delivery is not often the most critical requirement for software
systems.
Businesses may be willing to accept lower quality software if rapid delivery of essential functionality is possible.
_____________
The processes of specification, design and implementation are concurrent. There is no detailed specification and
design documentation is minimised.
The system is developed in a series of increments. End users evaluate each increment and make proposals for later
increments.
System user interfaces are usually developed using an interactive development system.
5b.
25
Advantages:
Accelerated delivery of customer services: Each increment delivers the highest priority functionality to the
customer.
User engagement with the system: Users have to be involved in the development, which means the system is more
likely to meet their requirements and the users are more committed to the system.
Problems:
Management problems
• Progress can be hard to judge and problems hard to find because there is no documentation to demonstrate what
has been done.
Contractual problems
• The normal contract may include a specification; without a specification, different forms of contract have to be
used.
Validation problems
• Without a specification, what is the system being tested against?
Maintenance problems
• Continual change tends to corrupt software structure making it more expensive to change and evolve to meet new
requirements.
________________
5c
Dissatisfaction with the overheads involved in design methods led to the creation of agile methods. These methods:
• Focus on the code rather than the design;
• Are based on an iterative approach to software development;
• Are intended to deliver working software quickly and evolve this quickly to meet changing requirements.
Agile methods are probably best suited to small/medium sized business systems or PC products.
26
6a.
These define system properties and constraints e.g. reliability, response time and storage requirements. Constraints
are I/O device capability, system representations, etc.
∙ Process requirements may also be specified mandating a particular CASE system, programming language or
development method.
∙ Nonfunctional requirements may be more critical than functional requirements. If these are not met, the
system is useless.
Classifications:
Product requirements
• Requirements which specify that the delivered product must behave in a particular way e.g. execution speed,
reliability, etc.
Organizational requirements
• Requirements which are a consequence of organizational policies and procedures e.g. process standards used,
implementation requirements, etc.
External requirements
• Requirements which arise from factors which are external to the system and its development process e.g.
interoperability requirements, legislative requirements, etc.
27
6b.
28
∙ Exercises the system beyond its maximum design load. Stressing the system often causes defects to come to
light.
∙ Stressing the system test failure behaviour.
∙ Systems should not fail catastrophically. Stress testing checks for unacceptable loss of service or data. ∙ Stress
testing is particularly relevant to distributed systems that can exhibit severe degradation as a network becomes
overloaded.
Component testing
Component or unit testing is the process of testing individual components in isolation.
It is a defect testing process.
Components may be:
• Individual functions or methods within an object;
• Object classes with several attributes and methods;
• Composite components with defined interfaces used to access their functionality.
COVENANT UNIVERSITY
CANAANLAND, KM 10, IDIROKO ROAD
P.M.B 1023, OTA, OGUN STATE, NIGERIA. TITLE OF
EXAMINATION: B.Sc EXAMINATION
COLLEGE: College of Science and Technology
DEPARTMENT: Department of Computer and Information Sciences
SESSION: 2015/2016 SEMESTER: ALPHA COURSE CODE: CSC 413 CREDIT UNIT:
3 COURSE TITLE: Algorithm & Complexity Analysis
INSTRUCTION: Answer ANY 4 questions TIME: 3 HOURS
30
(4) Merge the two hulls into a common convex hull, H, by computing
the upper and lower tangents for HA and HB and discarding all the
points lying between these two tangents.
Hint: the time to compute the upper and lower tangents is linear.
3. (a) Explain the term recursion? Differentiate between direct and indirect recursive
algorithms. (3 marks)
(b) Write a recursive algorithm for computing the Fibonacci series. (21/2 marks) (c)
Describe the Tower of Hanoi puzzle. Write an algorithm to solve this puzzle and
comment on its running time. (6 marks) (d) Consider the recursive algorithm given below:
Algorithm Parallel-Product (A[1..n])
if n = 1 then return
��
for i = 1 to 2⁄ do
��
A[i] = A[i] * A[i + 2⁄ ];
��
Call Parallel-Product (A[1.. 2⁄ ])
i) Write the recurrence equation.
ii) Find the time complexity for the algorithm by solving the recurrence equation using
repeated substitution method. (6 marks)
4. (a) State the worst case, best case and average case of the sequential search
algorithm below. for i = 1 to n do
if A [i] ≥ q then
return index i
return n + 1
(3 marks)
(b) Given the Binary search algorithm below;
public int binarySearch (int target,int[] array, int low, int high)
{
if (low > high)
return -1;
else {
int middle = (low + high)/2;
if (array[middle] == target)
return middle;
else if(array[middle] < target)
return binarySearch(target, array, middle + 1, high); else
return binarySearch(target, array, low, middle - 1); }
}
i. Is it an improvement over the sequential search algorithm in 4a above? Give
reasons for your answer.
ii. Comment on the conditions for the best case, average case and worst case of the
binary search algorithm. (5 marks) (c) Consider the two algorithms above for computing
x raised to the power of y. Which algorithm is more efficient with respect to running
time? Give reasons for your answer. (71/2 marks)
31
Algorithm 1 Algorithm 2
long powerA (int x, unsigned int n) long powerB (int x, unsigned int n) { {
int temp; long prod = 1;
if( n == 0) if( n == 0)
return 1; return prod;
temp = powerA(x, n/2); for(i=1; i <= n; i++) if (n%2 == 0) prod *= x
return temp*temp; return prod
else }
return x*temp*temp;
}
(d) Explain the possible reason for the time efficiency of your preferred algorithm in
terms of the algorithmic paradigm employed. (2 marks)
5. (a) What is a heap? Give an example. (21/2 marks) (b) Give at least five operations
that can be performed on a heap with their time complexity. (5 marks)
(c) Given an array of 6 elements: 15, 19, 10, 7, 17, 16, sort it in ascending order using
heap sort. (7 marks) (d) Complete the table below. (3 marks)
Name Worst e
Case od
Bubble Sort
Selection Sort
Insertion Sort
Merge Sort
Quick Sort
6. (a) With the aid of clear diagram, explain the following; (7 marks) i. Path ii. Bipartite
graph iii. Cycle
iv. Complete graph v. Digraph vi. Weighted graph vii. Spanning tree
(b) Given the graph in figure 1, give an incidence matrix representation of the graph.
(21/2 marks)
32
Figure 1
The weighted graph in figure 2 shows cities and the distance between them in
kilometers.
Figure 2
(c) Run the Depth-First Search (DFS) algorithm. Present a DFS tree and calculate the
total distance of the route from Milan to Innsbruck. (3 marks) (d) Run the Breadth-First
Search (BFS) algorithm. Present a BFS tree and calculate the total distance of the route
from Milan to Innsbruck. (5 marks)
33
COVENANT UNIVERSITY
CANAANLAND, KM 10, IDIROKO ROAD
P.M.B 1023, OTA, OGUN STATE, NIGERIA. TITLE OF
EXAMINATION: B.Sc EXAMINATION
COLLEGE: College of Science and Technology
SCHOOL: School of Natural & Applied Sciences
DEPARTMENT: Department of Computer and Information Sciences
SESSION: 2015/2016 SEMESTER: ALPHA COURSE CODE: CSC 413
CREDIT UNIT: 3 COURSE TITLE: Algorithm & Complexity Analysis
INSTRUCTION: Answer ANY 4 questions TIME: 3 HOURS Marking
Scheme
1a. Write short notes on the following 1/2 mark each = 3 marks i. An algorithm is a sequence
of computational steps that transform the input into the output.
ii. Analysis of algorithms is the theoretical study of computer program performance and
resource usage. To analyze an algorithm is to determine the amount of resources (such
as time and storage) necessary to execute it.
iii. Time Complexity - the time complexity of an algorithm quantifies the amount of
time taken by an algorithm to run as a function of the input size.
Space Complexity of an algorithm is total space taken by the algorithm with
respect to the input size.
iv. An algorithm is said to be correct if, for every input instance, it halts with the correct
output. We then say that a correct algorithm solves the given computational
problem.
An incorrect algorithm might not halt at all on some input instances or it might
halt with an answer other than the desired one.
b. 11/2 mark (1-3) + 1 mark (4-5) = 61/2 marks O-notation (upper bounds):
O(g(n))= { f(n) : there exist constants c>0, n0>0 such that 0 ≤ f(n) ≤ cg(n)for all n≥n0}
34
n≥n0}
Θ-notation (tight bounds)
Θ(g(n)) = O(g(n)) ∩Ω(g(n))
ο-notation
ο(g(n))= { f(n) :for any constant c>0, there is a constant n0>0 such that 0 ≤ f(n)<cg(n)
for all n≥n0}
ω-notation
ω(g(n ))= { f(n) :for any constant c> 0, there is a constant n0>0 such that 0 ≤cg(n)<f(n) for
all n≥n0}
c. 2 marks each = 6 marks i. Proof that if f(n) = 15n3 + n2 + 4, f(n) = O(n3)
Let c1 = 15, c2 = 20 and n0 = 1.
35
Must show that c1g(n) ≤ f (n) and f (n) ≤ c2g(n).
c1g(n) = 15n3 ≤ 15n3 + n2 + 4 = f (n).
f (n) = 15n3 + n2 + 4 ≤ 15n3 + n3 + 4n3 = 20n3 = c2g(n)
ii. Show ∃ c, n0: 30n+8 ≤ cn, ∀n>n0 .
Let c=31, n0=8. Assume n>n0=8. Then
cn = 31n = 30n + n > 30n+8, so 30n+8 < cn.
iii. Show that 100n + 5 ≠ Ω (n2)
∃ c, n0 such that: 0 ≤ cn2 ≤ 100n + 5
100n + 5 ≤ 100n + 5n (∀ n ≥ 1) = 105n
cn2 ≤ 105n⇒ n(cn – 105) ≤ 0
Since n is positive ⇒ cn – 105 ≤ 0 ⇒ n ≤ 105/c
⇒contradiction: n cannot be smaller than a constant
2a. Definition = 2 marks Adv & Disadv = 2 marks Examples = 1 mark Divide-and-conquer is a
top-down technique for designing algorithms that consists of dividing the problem into smaller
sub problems hoping that the solutions of the sub problems are easier to find and then
composing the partial solutions into the solution of the original problem.
Divide-and-conquer paradigm consists of following major phases:
⚫ Breaking the problem into several sub-problems that are similar to the original problem
but smaller in size,
⚫ Solve the sub-problem recursively (successively and independently), and then ⚫
Combine these solutions to sub problems to create a solution to the original problem.
Advantages Disadvantages
Solving difficult problems Conceptual difficulty
Algorithm efficiency Recursion overhead
Parallelism Repeated sub problems
Memory access
Roundoff control
Examples of its application in well-known algorithms include; Binary search, Powering a
number, Matrix multiplication, merge sort and heap sort.
36
case 1 of Master theorem
T(n) = Θ(nlg7) =O(n2.81)
d. 6 marks
The recursive relation is
T(n) = 2T(n/2) + M(n), where M(n) is linear in n.
Solution: a = 2, b = 2, c = 1 🡪 a = bc 🡪 Case 2
Hence T(n) ε O(n log n)
3 a. Recursion is the process of defining a problem (or the solution to a problem) in terms of (a
simpler version of) itself. An algorithm is said to be recursive if the same algorithm is invoked in
the body.
Recursion occurs where the definition of an entity refers to the entity itself. Recursion can be
direct when an entity refers to itself directly or indirect when it refers to other entities which
refers to it. A (Directly) recursive routine calls itself. Mutually recursive routines are an example
of indirect recursion. A (Directly) recursive data type contains pointers to instances of the data
type. (3 marks)
Figure 1
37
The algorithm for solving the puzzle is given by:
Tower_Of_Hanoi(N, source, destination, helper):
If N==1:
Move disk from source to destination
Else:
Tower_Of_Hanoi (N-1, source, destination, helper)
Move disk from source to destination
Tower_Of_Hanoi (N-1, helper, destination, source)
T(n) ε O(2n)
d. (6 marks)
The time complexity of the Parallel-Product algorithm can be expressed as
b.
i. Yes, the binary search algorithm is an improvement over the sequential search algorithm. This
is because it employs the Divide and Conquer approach which explains why it has increased
efficiency.
ii. Condition for best case – the element is the first element in the array
38
average case – the element is the middle element in the array worst case –
the element is the last element in the array
c.
c. Algorithm 1
. Recurrence equation
T(n) = T(n/2) + Θ(1)
Using Master Theorem
a=1, b=2
=n0=1
case 2(k=0)
T(n) = Θ(lgn) 4 marks
Algorithm 2
The major operation in the algorithm is the for loop as other operation are O(1). The for loop will
be executed n times. The algorithm is O(n). 21/2 marks
Therefore Algorithm 1 is more time efficient 1mark
d. Algorithm 1 employs the Divide and Conquer approach which explains why it has increased
efficiency over the iterative version in Algorithm 2. 2 marks
Start with the rightmost node at height 1 - the node at position 3 = Size/2.
It has one greater child and has to be percolated down:
After processing array[3] the situation is:
40
The last node to be processed is array[1]. Its left child is the greater of the children.
The item at array[1] has to be percolated down to the left, swapped with array[2].
As a result
the situation is:
The children of array[2] are greater, and item 15 has to be moved down further, swapped with
array[5].
41
1.1. Store 19 in a temporary place. A hole is created at the top
hole)
Now 10 can be inserted in the hole
42
43
3. DeleteMax 16
3.1. Store 16 in a temporary place. A hole is created at the top
hole)
3.4. Insert 7 in the hole
44
4.3. Store 10 in the hole (10 is greater than the children of the hole)
5. DeleteMax the top element 10.
5.1. Remove 10 from the heap and store it into a temporary location.
5.3. Store 7 in the hole (as the only remaining element in the heap
45
7 is the last element from the heap, so now the array is sorted
d. (3marks)
Name Worst Case Stable Method
Selection No Selec on
Sort
6.
a) I mark each = 7 marks
i. a path in a graph is a sequence of vertices such that from each of its vertices there is
an edge to the next vertex in the sequence.
ii. a bipartite graph (or bigraph) is a graph whose vertices can be divided into two
disjoint sets U and V such that every edge connects a vertex in U to one in V; that
is, U and V are independent sets.
iii. A cycle is a path such that the start vertex and end vertex are the same.
46
iv. In a complete graph each pair of vertices is joined by an edge, that is, the graph
contains all possible edges.
1 1 0 0 0 1 1 1 0
2 1 1 0 0 0 0 0 1
47
b)
5 0 0 0 1 1 0 0 1
(21/2 marks)
3 0 1 1 0
4 0 0 1 1
c) (3 marks)
d) (5 marks)
48
COVENANT UNIVERSITY
CANAANLAND, KM 10, IDIROKO ROAD
P.M.B 1023, OTA, OGUN STATE, NIGERIA. TITLE OF
EXAMINATION: B.Sc EXAMINATION
COLLEGE: College of Science and Technology
SCHOOL: School of Natural & Applied Sciences
DEPARTMENT: Department of Computer and Information Sciences
SESSION: 2014/2015 SEMESTER: ALPHA COURSE CODE: CSC 413
CREDIT UNIT: 3 COURSE TITLE: Algorithm & Complexity Analysis
INSTRUCTION: Answer ANY 4 questions TIME: 3 HOURS
2. (a). List the complexity classes in ascending order. (4 marks) (b) i. Prove that if f(n)
= 15n3+ n2+ 4, f(n) = O(n3)
ii. Show that 30n+8 is O(n).
iii. Show that 100n + 5 ≠ Ω (n2) (3 marks) (c) Consider the program with n nested loops
below which checks all possible truth assignments to the n Boolean variables for the
function f( ) and computes the number of times it is true. What is its running time? (21/2
marks)
49
sat = 0
for X1 = true, false do
for X2 = true, false do
.
.
.
for Xn = true, false, do
if (f(X1, X2, ... , Xn) = true)
then sat = sat+1
(d) Find the time complexity of the following loop segments. (8 marks) i. for ( int i =
0; i < n; i++ ) {
for ( int j = 0; j < 3; j++ ) {
// some O(1) expressions
}
}
ii. // Here c is a constant greater than 1
for (int i = 2; i <=n; i = pow(i, c)) {
// some O(1) expressions
}
iii. for ( int i = 0; i < n; i++ ) {
for ( int j = 0; j < i; j++ ) {
// some O(1) expressions
}
}
iv. for (int i = 1; i <= m; i += c) {
// some O(1) expressions
}
for (int i = 1; i <= n; i += c) {
// some O(1) expressions
}
3. (a) Define the concept “Divide and Conquer”. State its advantages and
disadvantag
es. (5
marks)
(b) What is the general divide and conquer recurrence relation? (21/2 marks) (c)
Strassen’s algorithm shows how to multiply two n by n matrices by multiplying 7 pairs of
n/2 by n/2 matrices, and then doing n2operations to combine them. What is the running
time of the Strassen’s matrix multiplication algorithm (5 marks) (d) Comment briefly on
the merge sort algorithm. Hence, describe its recurrence relation. (5 marks)
4. (a) What are recursive algorithms? Differentiate between direct and indirect recursive
algorithms. (5 marks) (b) Write a recursive algorithm for computing the factorial function
F(n) = n! for an arbitrary non negative integer n. (21/2 marks) (c) Given the Fibonacci
algorithm below;
long fibonacci (int n) {
if( n == 1 || n == 2)
return 1;
else
return fibonacci(n – 1) + fibonacci(n – 2);
50
}
i. State its recurrence equation
ii. Hence, find its running time using the characteristics equation. (5 marks) (d) Tower
of Hanoi is a puzzle that consists of three pegs and five disks. Figure 1 shows the
starting position of the puzzle. The goal is to reposition the stack of disks from peg A to
peg C by moving one disk at a time, and, never placing a larger disk on top of a
smaller disk. Show that this problem can be solved in O(2n) time. (5 marks)
Figure 1
5. (a) State the worst case, best case and average case of the sequential search
algorithm below. for i = 1 to n do
if A [i] ≥ q then
return index i
return n + 1
(3 marks)
(b) Given the Binary search algorithm below;
public int binarySearch (int target,int[] array, int low, int high)
{
if (low > high)
return -1;
else {
int middle = (low + high)/2;
if (array[middle] == target)
return middle;
else if(array[middle] < target)
return binarySearch(target, array, middle + 1, high); else
return binarySearch(target, array, low, middle - 1); }
}
iii. Is it an improvement over the sequential search algorithm in 5a above?
Give reasons for your answer.
iv. Comment on the conditions for the best case, average case and worst case
of the binary search algorithm. (5 marks) (c) Write an efficient algorithm for computing
x raised to the power of y. (4 marks) (d) Sort the following numbers in ascending order
using Insertion Sort
{18, 6, 9, 1, 4, 15, 12, 5, 6, 7, 11} (51/2 marks)
6. (a) Define the sorting problem. (11/2 marks) (b) Write short notes on the following. (4
marks) i. Internal sort
51
ii. External sort
iii. In Place sort
iv. Stable sort
(c) Calculate the worst case and best case of the quick sort algorithm below? (6
marks) quicksort(A, i, k):
if i < k:
p := partition(A, i, k)
quicksort(A, i, p - 1)
quicksort(A, p + 1, k)
Hint: the time to build the partition is linear.
(d) Complete the table below. (6 marks)
Name Average Worst Me
Case Case
Bubble Sort
Selection Sort
Insertion Sort
Shell Sort
Merge Sort
Heap Sort
MARKING SCHEME
1a. Write short notes on the following 1/2 mark each = 31/2 marks v. Time Complexity - the time
complexity of an algorithm quantifies the amount of time taken by an algorithm to run as a
function of the input size.
vi. Space Complexity of an algorithm is total space taken by the algorithm with
respect to the input size.
vii. Worst case
Provides an upper bound on running time
An absolute guarantee that the algorithm would not run longer, no matter
what the inputs are
Best case
Provides a lower bound on running time
Input is the one for which the algorithm runs the fastest
Average case
Provides a prediction about the running time
Assumes that the input is random
The running time for any given size input will be the average number of
operations over all problem instances for a given size.
viii. An algorithm is said to be correct if, for every input instance, it halts with the correct
output. We then say that a correct algorithm solves the given computational
problem.
52
An incorrect algorithm might not halt at all on some input instances or it might
halt with an answer other than the desired one.
c.
d. Algorithm design techniques (or strategies or paradigms) are general approaches to solving
problems algorithmically, applicable to a variety of problems from different areas of computing.
General design techniques are:
53
(i) Brute force (ii) Divide and conquer (iii) Decrease and conquer (iv) Transform and
conquer (v) Greedy technique (vi) Dynamic programming (vii) Backtracking (viii)
Branch and bound 4 marks
2a.
T(n) Name Problems
O(logn) logarithmic
O(n) linear
O(nlogn) Linear-logarith
O(n3) cubic
O(n!) factorial
b. i. Proof.
Let c1 = 15, c2 = 20 and n0 = 1.
Must show that c1g(n) ≤ f (n) and f (n) ≤ c2g(n).
c1g(n) = 15n3 ≤ 15n3 + n2 + 4 = f (n).
f (n) = 15n3 + n2 + 4 ≤ 15n3 + n3 + 4n3 = 20n3 = c2g(n)
c. To determine the complexity we must find out exactly how many times the function is
evaluated. Recalling that since we are dealing with nested loops, we multiply together the
number of times each of the loops is executed. Since each loop is executed twice, this is:
54
2(2(2(. . . (2(2)) . . .))) = 2*2*2* . . . * 2*2 = 2n.
d. Find the time complexity of the following loop segments. 8 marks (2 marks each)
i. The inner loop will execute exactly 3 times for each of the n
iterations of the outer loop, and so the total number of times the
statements in the innermost loop will be executed is 3n or O(n) times
ii. Time Complexity of the loop is O(LogLogn) because the loop variables is increased
exponentially by a constant amount.
iii. On the 1st iteration of the outer loop (i = 0), the inner loop will iterate 0 times On
the 2nd iteration of the outer loop (i = 1), the inner loop will iterate 1 time On
the 3rd iteration of the outer loop (i = 2), the inner loop will iterate 2 times .
.
On the FINAL iteration of the outer loop (i = n - 1), the inner loop will
iterate n - 1 times
So, the total number of times the statements in the inner loop will be
executed will be equal to the sum of the integers from 1 to n - 1, which is:
((n - 1)*n) / 2 = n2/2 - n/2 = O(n2) times
iv. Time complexity is O(m) + O(n) which is O(m+n)
55
a=7,b=2
lg7
=n
case 1 of Master theorem
T(n) = Θ(nlg7) =O(n2.81)
d. Merge sort is divide and conquer strategy that works by dividing an input array in
to two halves,sorting them recursively and then merging the two sorted halves to get
the original array sorted
��, �� = 1
��(��) = { + ��, �� >
�� 1
2�� ( 2)
4. a. An algorithm is said to be recursive if the same algorithm is invoked in the body. Recursion
occurs where the definition of an entity refers to the entity itself. Recursion can be direct when
an entity refers to itself directly or indirect when it refers to other entities which refers to it. A
(Directly) recursive routine calls itself. Mutually recursive routines are an example of indirect
recursion. A (Directly) recursive data type contains pointers to instances of the data type.
56
1^
Therefore, Recursive Fibonacci algorithm is O(2n)
i.e. Recursive Fibonacci is exponential
d.
Analysis of towers for Hanoi problem
The recursive relation is
T(n) = a if n = 1
T(n) = 2T(n - 1) + b if n > 1
57
O(2n)
b.
i. Yes, the binary search algorithm is an improvement over the sequential search algorithm. This
is because it employs the Divide and Conquer approach which explains why it has increased
efficiency.
ii. Condition for best case – the element is the first element in the array
average case – the element is the middle element in the array worst case –
the element is the last element in the array
c. Algorithm 1 Algorithm 2
long powerA (int x, unsigned int n) long powerB (int x, unsigned int n) { {
int temp; long prod = 1;
if( n == 0) if( n == 0)
return 1; return prod;
temp = power(x, n/2); for(i=1; i <= n; i++) if (n%2 == 0) prod *= x
return temp*temp; return prod
else }
return x*temp*temp;
}
58
d.
{18, 6, 9, 1, 4, 15, 12, 5, 6, 7, 11}
{ 6, 18, 9, 1, 4, 15, 12, 5, 6, 7, 11}
{ 6, 9, 18, 1, 4, 15, 12, 5, 6, 7, 11}
{ 1, 6, 9, 18, 4, 15, 12, 5, 6, 7, 11}
{ 1, 4, 6, 9, 18, 15, 12, 5, 6, 7, 11}
{ 1, 4, 6, 9, 15, 18, 12, 5, 6, 7, 11}
{ 1, 4, 6, 9, 12, 15, 18, 5, 6, 7, 11}
{ 1, 4, 5, 6, 9, 12, 15, 18, 6, 7, 11}
{ 1, 4, 5, 6, 6, 9, 12, 15, 18, 7, 11}
{ 1, 4, 5, 6, 6, 7, 9, 12, 15, 18, 11}
{ 1, 4, 5, 6, 6, 7, 9, 11, 12, 15, 18}
b.
• Internal Sort
– The data to be sorted is all stored in the computer’s main memory.
• External Sort
– Some of the data to be sorted might be stored in some external, slower, device. •
In Place Sort
– The amount of extra space required to sort the data is constant with the input size. •
A Stable sort preserves relative order of object with equal keys in the sorted output as they
appear in the input unsorted array.
Telescoping:
T(N-1) = T(N-2) + c(N-1)
T(N-2) = T(N-3) + c(N-2)
T(N-3) = T(N-4) + c(N-3)
T(2) = T(1) + c.2
Add all equations:
59
T(N) + T(N-1) + T(N-2) + … + T(2) =
= T(N-1) + T(N-2) + … + T(2) + T(1) + c(N) + c(N-1) + c(N-2) + … +
c.2 T(N) = T(1) + c(2 + 3 + … + N)
T(N) = 1 + c(N(N+1)/2 -1)
Therefore T(N) = O(N2)
Best-case analysis:
The pivot is in the middle
T(N) = 2T(N/2) + cN
Divide by N:
T(N) / N = T(N/2) / (N/2) + c
Telescoping:
T(N/2) / (N/2) = T(N/4) / (N/4) + c
T(N/4) / (N/4) = T(N/8) / (N/8) + c
……
T(2) / 2 = T(1) / (1) + c
Add all equations:
T(N) / N + T(N/2) / (N/2) + T(N/4) / (N/4) + …. + T(2) / 2 =
= (N/2) / (N/2) + T(N/4) / (N/4) + … + T(1) / (1) + c.logN
After crossing the equal terms:
T(N)/N = T(1) + cLogN = 1 + cLogN
T(N) = N + NcLogN
Therefore T(N) = O(NlogN)
d.
Name Average Case Worst Case Memory Stable Method
Bubble Sort Yes Exchanging
Selection No Selec on
Sort
60
COVENANTUNIVERSITY
--------------------------------------------------------------------------------------------------------------------------------------
1c. Differentiate between the concept of Good Old Fashioned Artificial Intelligence (GOFAI)
and Situated and Embodied Intelligence (SEAI) [4 marks]
2b. Identify 3 different problems within the Covenant University environment that AI can be
used to solve. Mention the specific AI techniques that will be essential to tackle the identified
problems [6 marks]
2c. Analyse the following problems with respect to the 7 problems characteristics
61
3a. Describe the Simple Hill Climbing Search. Identify its three disadvantages [5.5 marks].
3b. Using appropriate examples, differentiate between informed search and un-informed search
techniques [4 marks]
3d. A Robot Tractor has the task to plough a number of farms in a specific farm settlement. The
objective is to serve as many farmers in the neighbourhood as possible with its limited fuel
and energy level. Describe how a specific heuristic technique that you know can be used to
control this Robot Tractor. [5 marks]
4b. Consider the task of developing a Cognitive Food Selection Assistant (CFSA) that advises
students on choice of meals per time.
i) Describe the forms of knowledge that the CFSA must contain [3 marks]
ii) Suggest the types of reasoning it should do using relevant examples [3 marks]
4c. Using Predicate Logic, show 3 possible rules that the CFSA can use as basis
for reasoning [4.5 marks].
5b. Differentiate between a Deterministic Task environment and a Stochastic Task Environment
6a) Consider the expert task of Malaria diagnosis. Show the Design and Description of an
Expert System that can adequately replicate this functionality.
i) Show the architecture of the Expert System and the description of its components
[5 marks]. ii) Also show sample If-Then-rules that the expert system can use for its
reasoning [2.5 marks] 6b. Why is learning crucial for Intelligent Systems [2 marks]
62
Marking Scheme – CSC 415
1a.
A.I as a model of human intelligence is premised on the following definitions: (any two required)
i. The exciting new effort to make computers think i.e. machines with minds in the
full and literal sense
ii. The automation of activities that we associate with human thinking activities
such as decision-making, problem solving, learning etc.
iii. The art of creating machines that performs functions that require intelligence
when performed by people
iv. The study of how to make computers do things which at the moment people do
better A.I as a model of rationality: (any two required)
1b.
(i) Search – provides a way of solving important problems for which no more direct
approach is available as well as a framework into which any direct techniques that
are available can be embedded
(ii) Use of Knowledge – Provides a way of solving complex problems by exploiting the
structures of the objects that are involved.
(iii) Abstraction – Provides a way of separating important features and variations
from the many unimportant ones that would otherwise overwhelm any process.
[4.5 marks]
1c. Differentiate between the concept of Good Old Fashioned Artificial Intelligence (GOFAI)
and Situated and Embodied Intelligence (SEAI)
o GOFAI SEAI
63
2. They typically are Based on the concept of systems
logic-based reasoning that can sense and act
systems intelligently
1d) AI Complete are the set of most difficult AI problems that will require computers to possess
a higher level of intelligence – one similar to human level- to be able to solve them. They are
also called AI-Hard.
64
Has poor modular Has good modular approximation
approximation
[4 marks]
2b. The examples given by students will be assessed based on the quality of individual
presentations. It is expected that student would identify the need for deployment of intelligent
systems/agent in several aspect of University’s activities. Examples include intelligent tutoring
system, question-answering system, expert system for medical diagnosis, campus route
advisory system, cognitive assistant, intelligence surveillance system etc.
realised/implemented. [6 marks]
2c. Analyse the following problems with respect to the 7 problems characteristics
S/no Water Jug 8-Puzzle
1. Is problem No No
decomposable or not?
[3 marks]
2d)
Mundane Tasks
65
- Natural Language processing (understanding, generation,
- Robot control
Formal tasks
Expert Tasks:
- Medical analysis
- Financial analysis
[4.5 marks]
3a)
66
3b)
Uninformed search: This is a search strategy in which there is no information about the number
of steps or the path from the current state to the goal – all they can do is distinguishing a goal
state from a non-goal state. It is sometimes called blind search. Examples include; Breadth-first
search, Uniform path cost search, Depth first search, Depth-limited search, Iterative deepening
search, and Bidirectional search [2 marks].
Informed search: This is a search strategy in which we see how information about the state
space can prevent algorithm from blundering about in the dark. It uses problem specific
knowledge to find solution more efficiently. It also shows how optimization problems can be
solved. Examples include: best-first search, Greedy search, A*search, Heuristic search, Iterative
improvement search (such as hill-climbing and simulated annealing) [2 marks].
3c)
2. Time bm bd
5. Trapped/Dead Yes No
end
3d)
An ideal heuristic to use to solve this problem will be the branch and bound heuristic
technique. Application:
67
Problem definition
Let C(F) be a function that returns the number of farms that is served in the farm
neighbourhood Let the energy level of the Robot based on the amount of fuel be Et
We need to utilise Et in a way that of C(F) → M, where M is the maximum of value of C(F)
i.e. M is the largest number of farmers that can be served by the energy level Et of the
Search problem: Therefore, the search problem is to find the longest path in the graph that will
ensure utilise the energy of the Robot Tractor.
Branch and bound Technique: Begin by estimating the size of individual farms S, and Et
required. Devise a path to serve as many farms as possible giving up a path whose estimated
work done (expended energy) cum number of farms served is shorter than the longest path
found so far, compared to the amount of work done.
Explanation: The branch and bound heuristic could be used to explore the different possible
paths to administer the energy of the Robot in order to serve the interest of farmers in the
neighbourhood. When it is obvious that a particular chosen path has taken up more energy for
fewer number of farms compared to a previously explored path, that path should be
discontinued. By so doing, the search process can be accelerated to quickly find the optimal
path that will yield the maximum throughput in theirs of serving as many farms as possible.
{hint: student may not be very formal in their presentation, but award full marks if explanation
is correct} [5 marks]
∙ Representational Adequacy: It is the ability to represent all the kinds of knowledge that are needed in that
domain [1 mark].
∙ Inferential Adequacy: It is the ability to manipulate the representational structures in such a way as to
derive new structures corresponding to the new knowledge inferred from old [1 mark].
∙ Inferential Efficiency: It is the ability to incorporate into the knowledge structures additional information
that can be used to focus the attention of the inference mechanism in the most promising directions [1
mark].
68
∙ Acquisitional Efficiency - the ability to acquire new information easily. It should be possible to make direct
insertion into the database and the addition of new knowledge [1 mark].
4b)
- Data on different types of food and the time of the day when they are most
- Different types of eating habits and corresponding food options – e.g. vegetarian,
regular eating etc. - Different types of food and their classification e.g. pasta, local food,
cereal, protein etc. - Data on food nutrients, resident vitamins, and calories
ii) Suggest the type of reasoning it should do using relevant examples [2 marks]
Deductive reasoning: that is based on some know facts, the CFSA should recommend
appropriate food. A situation where given a case and a rule, the result is inferred.
∙ If breakfast time (7 – 10 a.m.) THEN food options should be any of (bread, tea and egg ) or
(yam, egg and tea) or (maize cereal and milk)
Inductive reasoning: if some historical data on eating pattern of the user is available THEN an
appropriate food should be recommended for the user. A situation where the rule is inferred
given the case and the result.
∙ If breakfast food 2 days ago is X and breakfast food yesterday is Y, THEN most appropriate
breakfast for today is Z
Adductive reasoning: A situation where, the case is inferred, given the rule and the result.
∙ If the food taken 2 days ago is X and food taken yesterday is Y, THEN it is breakfast
food Mentioning any 2 attracts full marks
4c. Possible rules for the CFSA using First-order logic [4.5 marks].
Answer will be accessed based on individual attempts. Correct attempts will emulate
the following: Rules:
1. If time is morning then food options are Yam and Egg or Bread and Tea
2. If person is vegetarian then food options is without meat
69
3. If person is African then food options at lunch is local food
FOL:
i) V x, y, z: time(x) Λ food_options (y) =>
(recommended_food(z, yam_egg) V recommended_food(z, yam_egg)) ii) V x, y,
z: person(x, Vegetarian) Λ food_option (y) => ┐recommended_food (z, meat) iii) V x, y, z:
person(x, African) Λ food_option (y) => recommended_food (z, local_food)
First-order logic, Production systems (Prolog, Jess, CLIPS), Frames, Semantic Networks,
Ontology [Any four attracts full marks] [3 marks]
∙ Performance measures: that will be used to assess whether the agent has fulfilled its goal – provide
correct and relevant answers to specific questions on admission into Covenant University.
∙ Environment: description of the environment that the agent will operate – potential student/parent/user/
administrator, databases, knowledgebase of information on CU
∙ Actuators: actions or events that will activate the agent – visual displays, touch screen, set of frequently
asked questions (FAQs), user query.
∙ Sensor: what the agent will use to accept inputs from the environment - keyboard entry of topics of
interest [5.5 marks]
5b)
Deterministic - If the next state of the environment is completely determined by the current
state and the action executed by the agent, then we say the environment is deterministic [2
marks]
Stochastic – here the next state of the environment is not completely determined by the
current state and the action executed by the agent. [2 marks]
5c)
Simple Reflex Agent: This is the simplest kind of agent where agents select actions on the
basis of the current percept, ignoring the rest of the percept history [1 marks].
Model-based Reflex Agent: This type of agent maintains some sort of internal state that
depends on the percept history and thereby reflects at least some of the unobserved aspects of
the current state [1 marks].
Goal-based Agent: This type of agent makes use of some sort of goal information that describes
situations that are desirable as well as a current state description, to arrive at its conclusion [1
marks].
70
Utility-based Agent: This type of agent not only makes use of use of goal information for its conclusion but
also considers the alternatives that guarantee high-quality behaviour in its environment [1 marks].
Learning Agent: This type of agent is able to learn from feedback obtained from the environment in the
course of solving a problem [1 marks].
5d)
A database allows the storage and retrieval of data in a way that is efficient. However, it can only
guarantee retrieval accuracy i.e. it can retrieve verbatim what has been stored in it, but cannot support
making inference or deductions based on what is stored.
A knowledgebase allows data to be organized in way that direct data retrieval, inferences and deductions
can be made based on what is stored. [3 marks]
6a)
The student is expected to describe the different components of the Expert System Architecture
in a way that is specific to malaria diagnoses. Attempts will be accessed on merit of
presentation.
Figure 1 shows the most important modules that make up a rule-based expert system. The user
interacts with the system through a user interface which may use menus, natural language or
any other style of interaction). Then an inference engine is used to reason with both the expert
knowledge (extracted from our friendly
71
expert) and data specific to the particular problem being solved. The expert knowledge will
typically be in the form of a set of IF-THEN rules. The case specific data includes both data
provided by the user and partial conclusions (along with certainty measures) based on this
data. In a simple forward chaining rule-based system the case specific data will be the
elements in working memory.
[2.5 marks
]
6b) Learning is essential to Machine Intelligence because machines can only exhibit
intelligence after knowledge as been acquired through learning which then forms the
basis for intelligence [2 marks]
72
∙ Genetic Algorithms: Based on the functioning of the biological process of evolution. It artificially
emulates the concepts of variation, selection based on the fitness function and inheritance.
∙ Artificial Neural Networks: emulates the human biological brain network to solve problems. Use
adaptive learning to solve complex classification and regression problems
∙ Swarm Intelligence: It is the collective behaviour of decentralized, self-organized systems, natural or
artificial. It is an attempt to emulate the collective intelligent behaviour of some known biological
ecosystems. Natural examples of SI include ant colonies, bird flocking, animal herding, bacterial
growth, and fish schooling.
∙ Artificial Immune Systems: These are class of computationally intelligent systems inspired by the
principles and processes of the vertebrate immune system. The algorithms typically exploit the
immune system's characteristics of learning and memory to solve a problem.
COVENANTUNIVERSITY
1a. Explain your understanding of Artificial Intelligence as: i) a model of human intelligence and
ii) model of rational behaviour [5 marks]
1b. Differentiate between Artificial Intelligent systems and Artificial Life systems [5
marks] 1c. Discuss the relevance of heuristic search techniques in solving A.I.
problems [2.5 marks] 1d. Differentiate between AI problems and non-AI problems
[5 marks]
2a. Assume you have the task to design a software agent that will efficiently distribute available
bandwidth to different users with varying bandwidth requirements on a Corporate Computer
Network, so that as many persons as possible are served. Discuss a suitable heuristic that
the software agent can use in order to achieve optimal bandwidth distribution for users on
network [6.5 marks]
[4 marks] 2c. Highlight the main A.I tasks domains, citing relevant
examples [5 marks]
74
2d. Give 2 examples of AI-Complete (Hard AI) problems [2 marks]
3a. Find a good state space representation for the Water Jug Problem [5.5 marks]
3b. Compare the Breath-first and the Depth-First search Algorithm [4 marks]
3c. Using relevant examples compare informed search and un-informed search
techniques [4 marks] 3d. Give an outline of the Iterative Deepening Search Algorithm [4
marks]
4d. Consider the task of developing an Intelligent Tutoring System (ITS) for the AI course.
Describe the components of the IT, and show the Performance, Environment, actuators,
Sensors (PEAS) description of such an intelligent Tutoring System [5.5 marks].
learning [2 marks]
6. Consider the expert task of recommending the most appropriate books on specific subjects
for students to read. Assume you have been assigned the task of designing an Expert System
that can perform this task.
a. Discuss the architecture of the Expert System and the description of its components [5
marks]. b. Using relevant examples, describe the inference mechanism that the expert system
would use [2.5 marks] c. Discuss the implementation tools and artefacts you would use to
realize the Expert System. [3 marks] d. Highlight the possible limitations of your system based
on your chosen system design choices. [4 marks] CSC415 Marking Scheme – Ar ficial Intelligence
1a.
75
The no on of A.I as a model of human intelligence is based on the following defini ons: (any two
required)
v. The exci ng new effort to make computers think i.e. machines with minds in the full and
literal sense
vi. The automa on of ac vi es that we associate with human thinking ac vi es such as
decision-making, problem solving, learning etc.
vii. The art of crea ng machines that performs func ons that require intelligence when
performed by people
viii. The study of how to make computers do things which at the moment people do
be er
[2.5 marks]
v. The study of mental facul es through the use of computa onal models vi. The study of
computa ons that make it possible to perceive reason and act. vii. A field of study that
seeks to explain and emulate intelligent behaviours in terms of computa onal processes
viii. The branch of computer science that is concerned with the automa on of intelligent
behaviour.
[2.5 marks]
1b.
Ar ficial Intelligent (A.I.) Systems – the basis for intelligence is from reasoning on knowledge that have
been stored in them or just acquired in the course of usage. They are typically reasoning systems that
require a good knowledge base to make inferences. [2.5 marks]
Ar ficial Life Systems (ALife) – are called situated and embodied ar ficial intelligent (SEAI) systems
because they possess addi onal characteris cs that make them to learn and adapt to their
environment dynamically and independently. The characteris cs of ALife system include – synthesis,
self-organizing, self-regula ng, adap ve, and complex [2.5 marks]
1c.
The complexity of most A.I problems is NP, which require a brute-force search.
∙ Heuris c search techniques take advantage of knowledge to produce good but less than op mal
solu on.
∙ A heuris c is a technique that improves the efficiency of a search process, possibly by sacrificing
claims of completeness. It is a control structure that is not guaranteed to find the best answer
but will always find a good answer.
∙ Heuris cs are rules of the thumbs that can guide for correctness unlike algorithms. ∙
Heuris cs help to find good though non-op mal solu ons to NP problems.
∙ Heuris cs methods such as Nearest neighbour heuris c, error bounds, branch and bound have
been used to solve many NP problems.
76
(Any 2 points men oned a racts full marks) – 2.5 marks
1d.
A.I Problems Non-A.I Problems
[5 marks]
2a.
An ideal heuris c to use to solve this problem will be the branch and bound heuris c
Problem defini on
We need to distribute bandwidth of size P among the members of Set N, such that C ϵ N is the largest
subset of N, i.e. the largest number of users that can be allocated bandwidth
Search problem: Hence, the search problem is to find the longest path in the network that will ensure
distribu on of bandwidth of size P.
Branch and bound Technique: Begin by genera ng complete paths to distribute P, keeping track of the
longest path found so far and the amount of P that has been distributed. Give up exploring any path as
soon as its par al length becomes shorter than the longest path found so far, compared to the amount
of P that has been distributed.
Explana on: The branch and bound heuris c could be used to explore the different possible paths to
allocate the units of memory P to different nodes in the network based on their bandwidth
requirements. When it is obvious that a par cular chosen path has taken up more bandwidth to fewer
number of network nodes compared to a previously explored path, that path should be discon nued. By
so doing, the search process can be accelerated to quickly find the op mal path that will yield the
maximum possible ways of distribu ng P to network nodes.
77
{hint: student may not be very formal in their presenta on, but award full marks if explana on is
correct}
[6.5 marks]
∙ Decomposable problems: problems that can be decomposed into smaller or easier components. ∙
Ignorable problems: solu on steps can be ignored when considered not necessary (e.g. theorem
proving).
∙ Recoverable problems: in which solu ons steps can be undone.
∙ Irrecoverable problems: in which solu ons steps cannot be undone.
∙ Certain-outcome problems: lead to definite outcome.
∙ Uncertain-outcome problems: produces a probability to lead to a solu on (the hardest problems to
solve are those that are irrecoverable, uncertain- outcome) e.g. advising a lawyer who is
defending a client who is standing trial for murder.
∙ Problems that require absolutely good solu on and those that require rela vely good solu on e.g.
travelling salesman algorithm (Any-path/Best path) problem.
∙ Problem that require a solu on as state or path.
[4 marks] lis ng any 4 a racts full marks
2c. A.I task domains
Mundane Tasks
Formal tasks
Expert Tasks
78
2d.
AI Complete are the class of most difficult AI problems that cannot be solved by simple algorithmic
approaches. Examples include Computer vision, natural language understanding, machine transla on,
dealing with unexpected circumstances while solving real problems. [2 marks]
3a. Find a good state space representa on for the Water Jug Problem [5.5 marks]
• A state: (x, y)
x = 0, 1, 2, 3, or 4 y = 0, 1, 2, or 3.
[1.5 marks]