


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 a bachelor of engineering (honours) in electronic engineering exam in the computer science subject. The exam covers topics such as linked lists, passing by reference, recursion, binary trees, and matrix operations. Students are required to answer questions related to defining data structures, writing functions, and implementing algorithms.
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!



(NFQ Level 8)
Answer Question 1 and THREE other questions. All questions carry equal marks.
Examiners: Mr. D. O’Donovan Prof. G. Hurley Dr. S. Foley
(b) Given the following lines of C code: #include<stdio.h> #include<stdlib.h> #include<malloc.h> void FunctionCall(int **q); void main(void) { int *y; FunctionCall(&y); free(y); } void FunctionCall(int **q) { *q = (int *)malloc(sizeof(int)); }
C Name Address in Memory y (^1234) q 2468 Value returned from malloc 3579 Table 2- (i) Using diagrams, in conjunction with the addresses supplied in Table 2-1 illustrate the variable assignments that occur in the above program. [6 %]
(ii) Why is the double star i.e. ‘**’ notation required? [4 %]
(c) Write a function(s) using the C language to add a new node to a linked list with zero nodes. The structure of the node is as follows: typedef struct List, *ListPtr;struct List { (^) int Element; ListPtr NextElement; }; [12 %]
(b) In the following sequence 50 is chosen as the pivot. Illustrate how the QuickSort algorithm would insert the pivot into its correct position:
50, 30, 20, 80, 90, 70, 95, 85, 10, 15, 75, 25 [5 %]
(c) Write C code to implement the QuickSort algorithm. [15 %]