Download 06-06995

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Binary search tree wikipedia , lookup

Transcript
06-19323
Fundamentals of Computer Science 1: Data Structures Algorithms
Examination Paper 2006/2007
(Answer any three questions)
QUESTION 1
(a)
Define data, information, abstraction and an abstract data type.
[5%]
(b)
Give two possible levels of abstraction, each with a minimum of two attributes, for the
following:
i)
an international airport
ii)
your personal book collection
iii)
a four part TV drama.
[9%]
(c)
State three features necessary in a programming language to support data abstraction.
[3%]
QUESTION 2
Consider a proposal to solve the collision problem in an External Hash Table organisation by
constructing overflow binary search trees instead of overflow linearly linked lists.
(a)
(b)
How might each entry in the Hash Table be viewed in implementing this proposal?
[3]
Illustrate the two alternative organisations referred to above i.e. collision with linearly linked
lists and collision handling using binary search trees, by using a mapping Hash function of
H(key) = key MOD 11 (the remainder after dividing the key by 11) to store the following
strict sequence of integer key values.
36, 100, 15, 116, 63, 78, 17, 111, 4, 127, 129,
56, 82, 52, 140, 107, 89, 122, 45
[10]
(c)
State one way by which the efficiency of insertion and access to keys in these two
organisations could be improved.
[4]
QUESTION 3
(a)
(i)
Construct a binary search tree (BST) from the following strict sequence of integer
values 12, 8, 16, 12, 20, 8, 22, 16, 18
[4%]
(ii)
Draw TWO distinct BST trees resulting from removing the root from the following
BST 8
7
10
5
8
9
8
11
10
[5%]
(b)
(i)
State, giving reasons, whether or not the tree you have grown in answering (a)(i)
above is a height balanced (AVL) tree.
[2%]
(ii)
Describe briefly how the integer 23 might be inserted into the following AVL tree to
maintain its properties:
25
21
20
29
22
Draw the resulting AVL tree.
[6%]
QUESTION 4
A large insurance company wishes to set up an on-line telephone directory for its staff which must
be able to locate quickly a member of staff by name or by telephone number.
(a)
Outline specifications for the following three possible abstract data types for this system –
Directory, StaffMember and TelephoneNumberIndex . Use the function-mapping
notation (based on your domain sets) used in the course lectures or any other clearly defined
notation, and include operations for findByName and findByNumber in your set of
operations.
[8%]
(b)
Give a brief outline for the implementation for the operations findByName and
findByNumber.
[4%]
(c)
Suppose the company subsequently also wishes to locate its members by Room Number.
What additional abstract data types and/or operations would be required to achieve this new
requirement? Give a brief answer.
[5%]
Fundamentals of Computer Science 1: Data Structures/Algorithms
Questions to Learning Outcomes
Question 1 – Learning Outcomes Refs – 1, 2
Question 2 – Learning Outcomes Refs – 1, 3, 4
Question 3 – Learning Outcomes Refs – 3, 4, 5
Question 4 – Learning Outcomes Refs – 1, 2, 3
Learning Outcomes
Ref
1
2
3
4
5
N.B.
Objective, Learning Outcome
Understand the internal representation of basic data structures (linear
and non-linear lists) and associated algorithms as well as hashtables
(implementation for sets).
Judge the suitability of a particular type of data type for a given
application.
Select appropriate internal data structures to ensure efficient
searching, insertion and deletion of data types
Understand how to build binary trees, heaps, graphs together with
their internal representations and relevant algorithms.
Appreciate differences between basic complexity classes of
algorithms (constant, linear, quadratic, logarithmic).
The above Learning Outcomes were distributed to the students at the
beginning of the Module