



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Main points of this exam paper are: Structure, Linked List, Memory Diagram, Empty Link List, Nodes, Accounting Record., Record Holds, Address, Balance., Account Number
Typology: Exams
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Autumn Examinations 2010
Module Code: COMP 6012
School: Science and Computing
Programme Title: Bachelor of Science in Computing Bachelor of Science in Computing ACCS Bachelor of Science (Honours) in Software Development
Programme Code: KCOMP_7_Y2, KCOME_6_Y2 and KSDEV_8_Y
External Examiner(s): Mr. Peter Given Internal Examiner(s): Mr. Gerard MacSweeney and Ms. Gemma MacSweeney
Instructions: Answer Question 1 and TWO questions from Questions 2, 3 and 4.
Duration: 2 Hours
Sitting: Autumn 2010
Requirements for this examination:
Note to Candidates: Please check the Programme Title and the Module Title to ensure that you have received the correct examination. If in doubt please contact an Invigilator.
(i) Describe the structure of a linked list. 2 marks
(ii) Describe a memory diagram to show:
(a) An empty link list (b) A list with two nodes 3 marks
(iii)
(a) Set up a node which contains an accounting record. Each record holds the following information account number, name, address and balance. 4 marks
(b) Write a function called addToList which adds each record to end of a list by first creating the node and then adding to the list 15 marks
(c) Write the main to store each record from the list to a file called Accounts .txt. 16 marks
Question 1 40 marks
(i) With reference to binary trees, explain the terms node, child and leaf. 3 marks
(ii) Set up a node struct to hold the following data about members of a leisure centre: customerId, telephone number, address1, address2, town, left pointer and right pointer. 3 marks
(iii) Create an empty binary tree including allocation of memory. 2 marks
(iv) Write a function for attaching the node given in (ii) to the binary tree in (iii). 5 marks
(v) Write a function to create a binary tree using the function in (iv) to attach a number of nodes. The data can be read from the keyboard or from a file. 4 marks
(vi) Write a function to display the tree in any order. 3 marks
(vii) Define what is meant by:
In-order traversal Pre-order traversal 4 marks
(viii) Write a recursive function which returns the power of an integer. The power of an integer is defined as xy. For example 5^3 = 5 x 5 x 5. 6 marks
Question 3 30 marks
(i) Describe, in your own words, how the insertion sort algorithm works. 4 marks
(ii) An array of integers contains five elements as follows: {63, 75, 90, 12, 27}. Trace the changing positions of the elements as the insertion sort is implemented. 6 marks
(iii) Consider the sorting function code in Appendix 1. What is the name of this type of function? 2 marks
(iv) Trace how this function (in Appendix 1) might sort the following array {5, 28, 6, 9, 18, 21, 37, 17} 10 marks
(v) Write a function which implements a bubble sort to sort an array of integer elements. 8 marks
Question 4 30 marks