Skip to document

CSC1B 10-2014-EXAM - This is the 2014 memo for the Final Exam for Computer Sciences

This is the 2014 memo for the Final Exam for Computer Sciences
Course

Computer Science (CSC1B)

103 Documents
Students shared 103 documents in this course
Academic year: 2013/2014
Uploaded by:
Anonymous Student
This document has been uploaded by a student, just like you, who decided to remain anonymous.
University of South Africa

Comments

Please sign in or register to post comments.

Preview text

FACULTY OF SCIENCE

ACADEMY FOR INFORMATION TECHNOLOGY

MODULE CSC1B

Introduction to data structures (C++)

CAMPUS APK

NOVEMBER EXAMINATION

DATE: 201 4- 11-11 SESSION 08:00 – 12:
ASSESSOR(S) DR DA COULTER
INTERNAL MODERATOR DR DT VAN DER HAAR
DURATION 2 HOURS MARKS 100

SURNAME, INITIALS (or ID NUMBER):________________________________________________

STUDENT NUMBER: ______________________________________________________________
CONTACT NR: __________________________________________________________________
NUMBER OF PAGES: 5 PAGES
REQUIREMENTS: NON-PROGRAMMABLE CALCULATORS ARE PERMITTED

Q

Q

Q

Q

Total

QUESTION 1

Draw the following in your answer book

1.

Use UML to model the following scenario: A multi-agent system (MAS) contains many different agents which are independent programs each capable of performing an assigned task. There are many different types of agent such learning agents, reflexive agents and utility agents. Each kind of agent performs its task in its own way. An MAS is capable of adding and removing agents to itself. When the MAS is asked to perform a task it delegates that task to its agents.

(5)

Write the most correct option in your answer books

1.

In an inheritance based implementation it is a good idea for destructors to be....

A

private

B

protected

C

virtual

D

explicitly invoked

E

static

1.

An abstract base class cannot be...

A

instantiated

B

deleted

C

passed reference

D

dereferenced

E

derived from

1.

It is better to use friend functions than member functions during operator overloading unless you are forced to do otherwise.

True False 無 1

1.

In order to differentiate between the prefix and postfix version of increment and decrement operators a(n) ... parameter is added. A int

B

value

C

reference

D

bool

E

optional

1.

Under which of the following circumstances is the copy constructor for the Q1 class not called? A passed by value

B

returned by value

C

passed by reference

D

when thrown

E

when caught

Write your answers to the following in your answer books

1 When should struct s be used as opposed to class es? (2)

1.

Assume that a class called Q1 exists. Within the member functions of Q1 what type does the reserved word this have? (2)

1.

Define the following principles / techniques of object orientation  Encapsulation  Inheritance  Composition / Aggregation

(3)

1 Describe how polymorphism may be achieved. (3)

. [ 20 ]

1 The Sino-Japanese ideogram Wu/Mu in this case represents a question which is flawed.

2.

If a given class has dynamically allocated data as part of its state then it must support three operations which are collectively known as the Big Three. Name and describe these operations.

(6)

2 Draw a series of images which depict the removal of an internal node (i. a node which is neither the first node nor the last node) from an unordered singly linked list.

(5)
[30]
QUESTION 3

In your answer books please write the necessary C++ code for the following statements, and answer the remaining questions. Unless otherwise indicated you may assume that the necessary header files are included**. Most of the marks in this section are awarded for the file handling operations.**

3.

The text file operations is made up of lines in the following format:

OP NUM1 NUM2 EOL

Where OP is either the character ‘+’ or ‘*’ representing addition or multiplication. NUM and NUM2 are textual representations of integers while EOL is the system’s representation of the end of the line.

Write code which reads in all of these lines and outputs the result of applying the operation to the two numbers. For example if the text file contained...

  • 5 2
  • 3 5

... the output would be: 7 15

Please show code for the opening / closing of the file.

(5)
3.

Define a structure which stores the data from each line in the previous question. Show the line of code used to write one of these structures (called s1) to a file called operations in append mode. You do not need to show the opening or closing of the file.

(5)
3.

Assume that operations has had an unknown number of records written to it. Show how you would calculate the number of records within the file. You do not need to show the opening or closing of the file.

(5)
3.

Describe how bit masking is used to represent the different modes a file stream object may be opened in.

(5)
3.

Consider the following function which saves the contents of a C-string to a file:

Analyse the above function asymptotically using Big-O notation. State any assumptions made.

(10)
.
[30]
QUESTION 4

The Utopian Game Development Association requires a dynamically linked library (DLL) called ujmath for their upcoming AAA sports title called Ball of Duty. The library must export the following function  d2D which takes four integers and returns a double representing the distance between two points in 2D space according to the following formula

( ) √( ) ( )

4 Write an appropriate header file for the library (6)

4.

Give the command line instructions required to compile the DLL itself assuming the source code to the library resides in a file called UJMath

(10)
4.

Give the command line instructions required to compile an executable called game (from the source file Game) which implicitly links to the DLL.

(4)
.
[20]
Was this document helpful?

CSC1B 10-2014-EXAM - This is the 2014 memo for the Final Exam for Computer Sciences

Course: Computer Science (CSC1B)

103 Documents
Students shared 103 documents in this course
Was this document helpful?
FACULTY OF SCIENCE
ACADEMY FOR INFORMATION TECHNOLOGY
MODULE CSC1B10
Introduction to data structures (C++)
CAMPUS APK
NOVEMBER EXAMINATION
DATE: 2014-11-11 SESSION 08:00 12:00
ASSESSOR(S) DR DA COULTER
INTERNAL MODERATOR DR DT VAN DER HAAR
DURATION 2 HOURS MARKS 100
SURNAME, INITIALS (or ID NUMBER):________________________________________________
STUDENT NUMBER: ______________________________________________________________
CONTACT NR: __________________________________________________________________
NUMBER OF PAGES: 5 PAGES
REQUIREMENTS: NON-PROGRAMMABLE CALCULATORS ARE PERMITTED
Q1
Q2
Q3
Q4
Total
/2…