



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
The instructions and questions for the applied data structures exam held at cork institute of technology during the 2011/12 academic year. The exam covers topics such as linked lists, queues, binary trees, and sorting, and includes both theoretical and practical questions. Students are required to answer questions related to memory diagrams, setting up data structures, and writing code for functions and programs.
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!




Semester 2 Examinations 2011/
Module Code: COMP
School: Science & Informatics
Programme Title: Higher Certificate in Computing – Year 2 BSc in Computing – Year 2 BSc (Hons) in Software Development – Year 2
Programme Code: KCOME_6_Y KCOMP_7_Y KSDEV_8_Y
External Examiner(s): Mr Peter Given Internal Examiner(s): Mr Gerard McSweeney Mrs Gemma McSweeney
Instructions: Answer Question 1 and 2 other questions.
Duration: 2 hours
Sitting: Summer 2012
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 (mandatory question)
Section A (i) Draw a diagram to represent a link list with 2 nodes of information. 2 marks
(ii) Describe a memory diagram to show:
(a) An empty link list (b) A list with two nodes 5 marks
(iii) (a) Set up a flight record which holds the following information flightId, route and costPerflight.
(b) Set up a node struct of a linked list which contains a flight record as in (iii)(a) and a link. 4 marks
(iv) Compare and contrast the types of memory allocation used for Linked Lists as distinct from either static or dynamic arrays. 2 marks
(v) Explain the term non-contigious memory 3 marks
(vi) Explain 2 steps that happen when the following operation is carried out: ptr1 = new node 2 marks Section A 18 marks Section B Write a program with a menu which includes the following options:
create list : which adds one record at a time display list : displays all record details
Use a selection statement to choose one of the above choices.
(i) Write a createList function which stores information of flights – one record at a time
which should be added to the end of the list.
(ii) Write the code to display all nodes of a linked list.
(iii) Write the main code for the program
Section B ==> 22 marks
Total Marks Question 1 ==> 40 marks
Question 3 Binary Trees & Binary Searching
Section A: Binary Trees
(i) Set up a node struct to hold the following information: flight id, the number of seats, the number of adults, the total cost and 2 pointers left and right. 4 marks
(ii) Set up the memory for the node in (i) and set the left and right pointer to NULL 3 marks
(iii) Write a function to display the node given in (i) for a binary tree 5 marks
(iv) Write a function to produce a binary tree of ten random integers (range from 1 to 100). 4 marks
Section A ==> 16 marks
Section B: Binary Searching
(i) What is the main criteria for a binary search? 2 marks
(ii) Given the code in Appendix 1 , show line by line what happens to find
(a) A flight record present in an array of flights, where the flightID is the key – assume there is at least 8 flights present. note: the flight Ids are not automated 4 marks
(b) A flight record that is not present in an array of flights 4 marks
(iii) Show what happens in the main program when the binary search function is called for (ii)(a) and (ii)(b) 4 marks
Section B ==> 14 marks
Total Marks Q3 ==> 30 marks
Section A
(i) Explain what is recursion 1 mark (ii) Write a recursive function to find the factorial of a number 3 marks (iii) What is the anchor statement in the factorial function 2 marks (iv) Show the steps involved when using the factorial function to calculate 5!. Show how a stack is involved in the process. 6 marks
Section A 12 marks
Section B
You are required to do the first 3 Passes on the following data using the insertion sort
in Appendix 2 Please show all the working steps involved.
Show the arrangement of the numbers at each Pass
45, 12, 56, 78, 23 18 marks
Section B 18 marks
Question 4 30 marks
Appendix 2
void insertion_sort( int * array)
{
int i, j, key, array_length=array.length( ); for(j = 1; j < array_length; j++) //Notice starting with 1 (not 0) { key = array[j]; for(i = j - 1; (i >= 0) && (array[i] < key); i--) { array[i+1] = array[i]; } array[i+1] = key; } return;
}