Docsity

Empty Linked - Applied Data Structure - Past Exam, Exams of Data Structures and Algorithms

Toggle sidebar
bg1
CORK INSTITUTE OF TECHNOLOGY
INSTITIÚID TEICNEOLAÍOCHTA CHORCAÍ
Semester 2 Examinations 2010/11
Module Title: Applied Data Structures
Module Code: COMP6012
School: School of Computing & Mathematics
Programme Title: Higher Certificate in Science in Computing
Bachelor of Science (Honours) in Software Development
Bachelor of Science in Computing
Programme Code: KCOME_6_Y2
KSDEV_8_Y1 / 2
KCOMP_7_Y1 / 2
External Examiner(s): Mr. Peter Given
Internal Examiner(s): Mr. Eoin O’Regan
Mr. Karl O’Connell
Instructions: Answer Question 1 and any TWO other Questions.
Show all work.
Duration: 2 hours
Sitting: Summer 2011
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 paper.
If in doubt please contact an Invigilator.
pf3
pf4
pf5

Partial preview of the text

Download Empty Linked - Applied Data Structure - Past Exam 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

School: School of Computing & Mathematics

Programme Title: Higher Certificate in Science in Computing Bachelor of Science (Honours) in Software Development Bachelor of Science in Computing

Programme Code: KCOME_6_Y KSDEV_8_Y1 / 2 KCOMP_7_Y1 / 2

External Examiner(s): Mr. Peter Given Internal Examiner(s): M r. Eoin O’Regan Mr. Karl O’Connell

Instructions: Answer Question 1 and any TWO other Questions. Show all work.

Duration: 2 hours

Sitting: Summer 2011

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 paper. If in doubt please contact an Invigilator.

Question 1. – Compulsory Question

a. Describe what a Linked List is under the following headings i. Definition ii. What a Linked List is made up of iii. Memory Allocation [5 marks]

b. What are the advantages of using a Linked List? [5 marks]

c. Describe how i. An empty linked list is represented in memory ii. An existing node is deleted from a linked list

Use both a memory diagram & a diagram showing the node & the pointer to help in illustrating the answer. [8 marks]

d. Data to be stored in a node of a linked list should include the following data on route information for flights  Route id  Departure  Destination  Aeroplane Seating  Price per Adult

Write the code to i. Create the struct that will contain the record info & be used in the linked list as a node. [4 Marks] ii. Create a pointer called head in the main program that is initialised to indicate that there is an empty list. [1 Mark]

e. Write a function addFlight to add a new flight record to the end of a linked list. [8 Marks]

f. Referring to (e.) i. Explain what happens when a new node is created. ii. Explain how a record is added to the flight node. iii. What value does the link of the node have and why? iv. If a node is added to an empty list,

  1. What would the starting head be?
  2. What happens to head after a call to the function addFlight?

v. Write the code in the main program required to add a node after the first node [9 Marks]

Question 3.

a. Explain the difference between PreOrder, In-Order & Postorder processing in terms of BTrees. [6 Marks]

b. Explain the difference between the Root Node and the Leaf Node in terms of trees. [4 Marks]

c. Explain the difference between a full binary tree and a complete binary tree [2 Marks]

d. Perform a DEQUEUE operation on the following heap and draw the resultant heap.

[8 Marks]

e. Given an empty BTree structure insert the following key values and draw the resulting BTree Structure. root: NULL

Key Values = 37, 2, 45, 48, 41, 29, 20, 30, 49, 7 [10 Marks]

Question 4.

a. Explain what is meant by the term Recursive Function. [2 Marks]

b. A factorial function is often written as a recursive function Write a C++ function that returns the factorial of a given number passed to the function. Ensure your function can handle negative numbers.

The factorial of an integer is defined as n! = n(n -1)(n-2) …1. For example 5! = 5 x 4 x 3 x 2 x 1. e.g Factorial(5) will return 120. [10 Marks]

c. What does infinite recursion mean? [2 Marks]

d. Explain the meaning of the following stack operations: i. PUSH ii. POP iii. PEEK [3 Marks]

e. Outline what the data structures Stack and Queue are and the reasons for using one over the other. [3 Marks]

f. The main operations that are performed on a Circular Queue are: Initialise the Queue Insert an element into the Queue Remove an element from the Queue.

Explain the steps involved in: i. Initialise the Queue [2 Marks]

ii. Inserting an element into the Queue [4 Marks]

iii. Removing an element from the Queue [4 Marks]