0% found this document useful (0 votes)
3 views

201 Data Structures Exams Trial

The document is an examination paper for the BSc Health Information Management program at the University of Cape Coast, focusing on Data Structures and Information Management. It includes multiple-choice questions and open-ended questions related to data structures, sorting algorithms, and binary trees. The paper is divided into two sections, with Section A containing 40 multiple-choice questions and Section B requiring detailed answers to specific questions.

Uploaded by

danilobest2004
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

201 Data Structures Exams Trial

The document is an examination paper for the BSc Health Information Management program at the University of Cape Coast, focusing on Data Structures and Information Management. It includes multiple-choice questions and open-ended questions related to data structures, sorting algorithms, and binary trees. The paper is divided into two sections, with Section A containing 40 multiple-choice questions and Section B requiring detailed answers to specific questions.

Uploaded by

danilobest2004
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

UNIVERSITY OF CAPE COAST

COLLEGE OF HEALTH AND ALLIED SCIENCES SCHOOL OF ALLIED


HEALTH SCIENCES

DEPARTMENT OF HEALTH INFORMATION MANAGEMENT

BSC HEALTH INFORMATION MANAGEMENT

END OF FIRST SEMESTER EXAMINATION 2019/2020 ACADEMIC YEAR

Level 200

HIM 201 /DATA STRUCTURES AND INFORMATION MANAGEMENT

Registration Number:

SECTION A (40 MARKS)

Time allowed - 2 hours

Attempt ALL, questions in this section:

Instructions: answer the following questions by encircling the single best answer,

1. What kind of data structure allows retrieval in the same order as insertion?

A. Array

B. Stack

C. Queue

D. Priority Queue

2. The numbers 9, 8, 4, 3, and 5 are inserted into a data structure in that order. An
item in deleted using only a basic data structure operation. If the deleted item is 5,
the data
structure cannot be a....

A queue

B. stack

C. tree

D. hash table

3. Arrays are best data structures for....

A. relatively permanent collection of data

B. the size of the structure and the data in the structure are constantly changing

C. keeping selected anonymous data

D. tracking varying data.

Consider the unsorted array, using bubble sort method; sort the array 7, 14,
12, 33, 5, 19.

Use it to answer Q4 and 05.

4. After one pass, what is the location of largest element?

A first position

B. last position

C. last but one position

D. second position
5. Which of the following represent the array after the first pass?

A. 7, 14, 12, 35, 5, 19

B. 7, 12, 14, 35, 5, 19

C. 7, 12, 14, 19, 5, 33

D. 7, 12, 14, 5, 19, 33

6 The elements of an array are stored successively in memory cells because...

(i) by this way computer can keep track only the address of the first element and
the addresses of other element can be calculated.

(ii) the architecture of the computer memory does not allow arrays to store other
than serially

(iii) the hard drive of the computer would be full

A. (i) only

B. (ii) only

C. (i) and (ii) only

D. (i) and (iii) only

7. In Fig.1 below, choose the option A-D which satisfies post order traversal.
A. [31, 25, 47, 42, 50]

B. [25, 42, 50, 47, 31]

C. [25, 31, 42, 50, 47]

D. [31, 25, 42, 47, 50]

8. In Fig. I above, choose the option A-D which satisfies pre-order traversal.

A. [31, 25, 42, 47, 50]

B. [25, 42, 50, 47,31]

C. [25, 31, 42, 50, 47]

D. [31, 25, 47, 42, 50]

9. In Fig. 1 above, how many siblings do the node element 25 have?

A. 3

B. 4

C. 2

D. 1
10. What is the disadvantage of selection sort?

A. It requires auxiliary memory

B. It is not scalable

C. It can be used for small keys

D. The performance always increases

11. Given an array of 6 elements: [15, 19, 10, 7, 17, 16] sort it in ascending order
using heap sort.

A. [7, 10, 15, 16, 17, 19]

B. [10, 15, 7, 17, 19, 16]

C. [19, 17, 16, 7, 15, 10]

D. [10, 15,17, 7, 16, 19]

12. In a max-heap, element with the greatest key is always in the .....

A. leaf node

B. first node of left sub tree

C. first node of right sub tree

D. root node

13. Heap can be used as.....

A. linked list

B. stack

C. a decreasing order array


D. priority queue

14. In the given array arr = [3,4,5,2,1]. The number of iterations (passes) in bubble
sort and selection sort respectively are......

A. 2 and 5

B. 4 and 5

C. 2 and 4

D. 5 and 4

15. What is the disadvantage of selection sort?

A. It requires auxiliary memory

B. It is not scalable

C. It can be used for small keys

D. It is scalable

16. Which of the following traversal techniques list the nodes of a binary search
tree in ascending order?

A. Post order only

B. In order only

C. Pre order only

D. Pre order & Post order

17. Binary trees can have how many children?


A. 2

B. any number of children

C. 0 or 1 or 2

D. 0 or 1

18. A disadvantage of using array representation for binary trees is......

A. difficulty in knowing children nodes of a node

B. difficulty in finding the parent of a node

C. have to know the maximum number of nodes possible before creation of trees

D. it is difficult to implement

19. What is special about in-order traversal of a binary search tree?

A. It traverses in a non-increasing order

B. It traverses in an increasing order

C. It traverses in a random fashion

D. It does not traverse in a uniform order

20. What are the advantages of priority queues?

i. Easy to implement

ii. Processes with different priority can be efficiently handled

iii. Applications with differing requirements

A. (1) only
B. (ii) only

C. (i) and (iii) only

D. (i), (ii) and (iii)

21. Space in linked list is....

i) created when only needed

ii) destroyed when not need

iii) use only when available

(iv) always available

A. (i) only

B. (i) and (ii) only

C. (i), (ii), (iii) only

D. (ii) and (iv) only

22. Which of the following property is NOT true about linked list?

A. the last element points to NULL

B. it allocates memory as list grows

C. waste memory space

D. space is destroyed when not needed.

23. What is the minimum number of queues needed to implement the priority
queue?
A. One

B. Two

C. Zero

D. Three

24. There are 8, 15, 13, and 14 nodes in 4 different trees. Which one of them can
form a full binary tree?

A. 8

B. 15

C. 13

D. 14

25. Dynamic data structures are structures that.....

A. expands only as a program runs

B. contract only as a program runs

C. expands and contract as a program runs

D. are permanently fixed

26. In which data structures are pointers applied?

(i) Queues

(ii) Linked list

(iii) Stacks
A. (i) only

B. (i) and (iii) only

C. (ii) only

D. (i), (ii) and (iii) only

Instruction: Use the following statements to answer Q27 and Q28

(i) when we want to insert data into a data structure that is full

(ii) When we want to insert data into a data structure that is empty

(iii) When we want to delete data from a data structure that is full

(iv) When we want to delete data from a data structure that is empty

27. What is meant by overflow?

A. (i) only

B. (ii) only

C. (iii) and (iv) only

D. (iv) only

28. What is meant by underflow?

A. (i) only

B. (ii) only

C. (iii) and (iv) only

D. (iv) only
29. A normal queue, if implemented using an array of size N, gets full when

A. Rear = N-1

B. Front = (rear+1) mod N

C. Front = rear +1

D. Rear = front

30. In a circular queue there is....

A. effective usage of memory

B. easier computations

C. ineffective usage of memory

D. complex computations

31. A linear list of elements in which deletion can be done from one end (front)
and insertion can take place only at the other end (rear) is known as a ...

A. queue

B. stack

C. tree

D. linked list

32. A queue is a .....

A. FIFO (First In First Out) list

B. LIFO (Last In First Out) list

C. Ordered array
D. Linear tree

33. The dequeue process removes data from the front of the single ended queue

A. True

B. False

34. The enqueue operation adds a node at the front of the linked list.

A. True

B. False

35. Elements in an array can NOT be accessed in constant time.

A. True

B. False

36. A Linked list best suited for problems requiring a sequence in which the
maximum number of elements is known up front.

A. True

B. False

37. An array is a better choice when the size of a sequence or list needs to change
after it has been created.

A. True

B. False
38. The height of a tree does NOT play any crucial role in determining the
performance of search algorithms

A. True

B. False

39. Item in priority queue can jump to the front of the line if they have priority.

A. True

B. False

40. Heap exhibits the property of a binary tree.

A. True

B. False

SECTION B

Instruction:

Answer Question 1 and any other one (1) question from this section

QUESTION 1

a. Create Binary Search Tree (BST) for the following data: 50, 25,75, 22, 40, 60,
80, 90, 15, 30

b. Define post-order traversal?

C. Which traversal method would you apply to a binary search tree, to be able to
print numbers in ascending order? Explain.
d. Write down the order in which an In-order traversal processes elements of the
binary search tree in Fig. 2 below.

e. Explain why Fig. 2 is a binary search tree.

f. The five items: A,B,C,D and E are pushed in stack, one after the other starting
from A. The stack is popped four items and each element is inserted in a queue.
Then two elements are deleted from the queue and pushed back on the stack. Now
one item is popped from the stack. What is the popped item?

QUESTION 2

a. Give four (4) differences between Stack and Queue?

b. How many elements are there in a full binary tree with height 4? Explain?

c. What is the maximum number of leaves possible in a binary tree with 10


elements?

d. Construct such a tree.


QUESTION 3

a. Show how the heap below would be implemented in an array.

b. What type of binary tree is Fig 3? Explain why?

C. How many siblings are there in level 2 of Fig 3?

d. Explain why arrays are accessed in constant time.

e. List two (2) disadvantages of arrays and two (2) disadvantages of linked list.

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬

SOLUTION

QUESTION 1

a. In BST the right subtree is greater than the root node which is great than the left
subtree

[R>N>L]

After sorting, the numbers will be [15, 22, 25, 30, 40, 50, 60, 75, 80, 90 ]
b. Post order traversal is visiting each nodes of a binary tree / binary search tree
once by visiting the left node first and then the right node and finally the root node.

c. In order traversal. Since in binary search tree, the left node is smaller than the
root node which is smaller than the right node, visiting the left node first and then
the root node before the right node will give you an arrangement in ascending
order.

d. [25, 21, 42, 45, 50]

e. In every subtree, the right node is greater than the root node which is greater
than the left node

f. Stack = [A, B, C, D, E]

After 4 pops, Stack will be [A]

Queue = [E, DE, C, B]

Poped items from queue = [E, D]


When added to stack, Stack will be [A, E, D]

The item poped will be [D]

This is because stack follows the First in Last Out property and queue follows
the First In First Out property.

QUESTION 2

Stack Queue

1 In stacks we maintain only one pointer to In queues we maintain


access the list, called the top, which always two pointers to access the
points to the last element present in the list. list. The front pointer
always points to the first
element inserted in the list
and is still present, and
the rear pointer always
points to the last inserted
element

2 Delete operation is called pop operation. Delete operation is called


dequeue operation.

3 Insert operation is called push operation Insert operation is called


enqueue operation.

4 Stacks are based on the LIFO principle, i.e., Queues are based on the
the element inserted at the last, is the first FIFO principle, i.e., the
element to come out of the list. element inserted at the
first, is the first element to
come out of the list.
5 Insertion and deletion in stacks takes place Insertion and deletion in
only from one end of the list called the top. queues takes place from
the opposite ends of the
list. The insertion takes
place at the rear of the list
and the deletion takes
place from the front of the
list.

6 Stack is used in solving problems works on Queue is used in solving


recursion. problems having
sequential processing.

b. For a full tree of height 4, the total number of elements will be:

Let height = h = 4

Then elements = (2h+1) - 1

= (2(4+1)) - 1

= 2⁵ - 1

= 32 - 1

= 31.

The root node take one and there would be 15 pairs which will give you 30

c. 5 leaves. This is because 5 nodes will have no children

d.
QUESTION 3

a. [2, 3, 5, 10, 8, 7, 22, 11, 13, 20, 24, 16]

[2, 3, 5, 8, 7, 10, 11, 13, 16, 20, 22, 24]

[2, 3, 5, 7, 8, 10, 11, 13, 16, 20, 22, 24]

This is because using the top - down approach, the elements have to be swapped
until they are ordered.

b. A complete binary tree is a binary tree which have all levels completely filled
except the right side of the last level. All leaves lean to the left.

c. 4

d. Array uses index to find elements. The process uses multiplication and addition.
These two operations have constant time, hence giving array a constant access time.

e. Disadvantages of array

1. It's static

2. Waste memory when allocation is not used

3. Total number of elements should be known beforehand

Disadvantages of linked list

1. Allocates memory for pointers

2. Requires more time to access elements

3. Hard to manipulate

You might also like