Exam Document: Applied Data Structures - COMP 6012, Science and Computing, BSc Programs, Exams of Data Structures and Algorithms

An exam paper from the cork institute of technology for the module applied data structures (comp 6012) in the science and computing school. The exam covers various data structures such as linked lists, circular queues, binary trees, and sorting algorithms. Students are required to answer questions on setting up nodes, updating records, adding records to lists, implementing functions, and understanding data structures concepts.

Typology: Exams

2012/2013

Uploaded on 03/24/2013

bakula
bakula 🇮🇳

4.4

(5)

35 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
CORK INSTITUTE OF TECHNOLOGY
INSTITIÚID TEICNEOLAÍOCHTA CHORCAÍ
Semester 2 Examinations 2010
Module Title: Applied Data Structures
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_Y2
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: Summer 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.
pf3
pf4
pf5

Partial preview of the text

Download Exam Document: Applied Data Structures - COMP 6012, Science and Computing, BSc Programs and more Exams Data Structures and Algorithms in PDF only on Docsity!

CORK INSTITUTE OF TECHNOLOGY

INSTITIÚID TEICNEOLAÍOCHTA CHORCAÍ

Semester 2 Examinations 2010

Module Title: Applied Data Structures

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: Summer 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.

Question 1 Linked Lists (Compulsory)

(i) Set up a node to hold a fix length flight record of information and a link pointer. The flight information should include a flight id, departure airport, destination airport and the number of seats sold. Define the total number of seats as a constant. 5 marks

(ii) Write the details in the main program to update the last flight record. The last node in the flight list is referenced by the pointer last.

  • Check the number of seats sold to date against the last record
  • Find the number of required seats by the customer
  • If there are spaces available (assuming a total of 350 seats) - read in the details to update the number of seats sold for the last flight record in the list.

6 marks

(iii) Write code for in the main program to set up a new record. Automate the flight Id for each record. Note no seats are sold as yet. 4 marks

(iv) Write a function addFlight to add a new flight record to the end of a linked list. 6 marks

(v) Referring to (iv)

a. Explain what happens when a new node is created.

b. Explain how a record is added to the flight node. c. What value does the link of the node have and why?

d. If a node is added to an empty list, i. What would the starting head be?

ii. What happens to head after a call to the function addFlight? e. Write the code required to add a node after the first node.

9 marks

(vi) Write the code to empty a list of flights into a file called flights.dat 10 marks

Question 1 Î 40 marks

Question 3 Binary Trees

(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 bank customers: customerId, current balance, overdraft limit, 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:

ƒ Post-order traversal ƒ Pre-order traversal 4 marks

(viii) Write a recursive function which returns the factorial of an integer. The factorial of an integer is defined as n! = n(n -1)(n-2) …1. For example 4! = 4 x 3 x 2 x 1. 6 marks

Question 3 Î 30 marks

Question 4 Sorting

(i) Describe, in your own words, how the selection 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 selection 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

Total marks for Question 4 Î 30 marks