Docsity

Gauss Siedel method - Computer Science - Exam, Exams of Computer Science

Toggle sidebar
bg1
Cork Institute of Technology
Bachelor of Engineering (Honours) in Electronic Engineering – Stage 2
(NFQ – Level 8)
Summer 2007
Computer Science
(Time: 3 Hours)
Answer Question 1 and THREE other questions.
All questions carry equal %.
Examiners: Prof. G. Hurley
Dr. S. Foley
Mr. D.O’Donovan
1. The outcome of a set of experiments are stored in a file called “results.dat”. The results
are organised in the file using the following format:
Experiment number (int)
hour:min:sec (int:int:int)
outcome (float)
Each line stores one set of results. Write appropriate C code to implement the following:
i. Define a structure capable of storing the experimental information in linked-
list fashion. [5 %]
ii. Add a set of results to the linked-list in (i). [12 %]
iii. Determine the average, max. and min. values of the experimental outcomes in
the linked-list. [8 %]
2. (a) Draw the binary search tree that would result from the following integers arriving in
sequence from left to right.
29,20,27,17,9,45,67,52,78
[4 %]
(b) For each of the following methods of tree traversal,
In-Order
Pre-Order
Post-Order
Show the output for each traversal method using the tree constructed in (a) above. [6 %]
pf3

Partial preview of the text

Download Gauss Siedel method - Computer Science - Exam and more Exams Computer Science in PDF only on Docsity!

Cork Institute of Technology

Bachelor of Engineering (Honours) in Electronic Engineering – Stage 2

(NFQ – Level 8)

Summer 2007

Computer Science

(Time: 3 Hours)

Answer Question 1 and THREE other questions. All questions carry equal %.

Examiners: Prof. G. Hurley Dr. S. Foley Mr. D.O’Donovan

  1. The outcome of a set of experiments are stored in a file called “results.dat”. The results are organised in the file using the following format: Experiment number (int) hour:min:sec (int:int:int) outcome (float) Each line stores one set of results. Write appropriate C code to implement the following: i. Define a structure capable of storing the experimental information in linked- list fashion. [5 %] ii. Add a set of results to the linked-list in (i). [12 %] iii. Determine the average, max. and min. values of the experimental outcomes in the linked-list. [8 %]
  2. (a) Draw the binary search tree that would result from the following integers arriving in sequence from left to right. 29,20,27,17,9,45,67,52, [4 %] (b) For each of the following methods of tree traversal, ƒ In-Order ƒ Pre-Order ƒ Post-Order Show the output for each traversal method using the tree constructed in (a) above. [6 %]

(c) If node 67 is deleted from the binary search tree followed by the subsequent deletion of node 29, draw the tree which would result in each case. Describe the changes required in the creation of each new tree. [5 %] (d) Write a function in C to search the tree for a particular value supplied as a parameter. The function’s result should indicate the success of the search. Define variables and data structures as appropriate. [10 %]

  1. (a) A formula for implementing the Gauss Siedel method for solving linear equations is given as follows:

( )

1

N jj i

b i a i j approx x j x i (^) a i i

=≠

=^ 

Describe, in detail, the workings of this method. [5 %] (b) Define the data types and declare variable for the above formula ( i.e. declare a , b, x and (^) N ) [2 %] (c) Write a C function, which when passed the system of equations, (i.e. a and b) will re- arrange them such that they are diagonally dominant. [7 %] (d) Write a function to implement the Gauss-Siedel method for n linear equations with n unknowns. This function should first re-arrange the equations into a diagonally dominant form. [11 %]

  1. (a) What is recursion and discuss the attributes required by such a function. [3 %]

(b) Write a function to implement the Factorial function i.e. n! = ( n )( n − 1 )( n − 2 ),......., ( )( )( ) 3 21

and use it to illustrate these attributes. [4 %] (c) The merge sort algorithm is an example of a recursive sort algorithm. Write a C program to implement the merge sort algorithm. [18 %]

  1. (a) What is meant by the terms static and dynamic memory allocation? [4 %]