Computer Science Exam Questions for Electronic Engineering Bachelor, Exams of Computer Science

Exam questions from a computer science module for students pursuing a bachelor of engineering in electronic engineering at cork institute of technology. The questions cover topics such as linked lists, stack data types, memory allocation, gaussian elimination, and binary search trees. Students are required to define data structures, write functions, and answer theoretical questions.

Typology: Exams

2012/2013

Uploaded on 03/30/2013

lallit
lallit 🇮🇳

4

(27)

150 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Cork Institute of Technology
Page 1 of 4
Bachelor of Engineering (Honours) in Electronic Engineering – Stage 2
(Bachelor of Engineering in Electronic Engineering – Stage 2)
(NFQ – Level 8)
Autumn 2005
Computer Science
(Time: 3 Hours)
Answer Question 1 and THREE other questions.
All questions carry equal %.
Examiners: Prof. C. Burkley
Mr. D. O’Donovan
Mr. J. G. Ryan
Q1 (a) Define a structure capable of implementing a linked list based stack data type. Assume the
information consists of one piece of data of type integer [3 %]
(b) Write functions to implement the following for a linked-list based stack:
i. Initialise the stack [2 %]
ii. Push information onto the stack [10 %]
iii. Pop information off the stack [5 %]
(c) Why is it so important to deallocate the pointer when popping information from the stack in
(b)? [3 %]
(d) The C language makes great use of the system stack. Briefly describe the purpose and use
of the stack in the context of the execution of a C program. [2 %]
Q2. (a) Describe the operation of the mechanism referred to as passing by reference. [3 %]
(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);
}
pf3
pf4

Partial preview of the text

Download Computer Science Exam Questions for Electronic Engineering Bachelor and more Exams Computer Science in PDF only on Docsity!

Cork Institute of Technology

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

(Bachelor of Engineering in Electronic Engineering – Stage 2)

(NFQ – Level 8)

Autumn 2005

Computer Science

(Time: 3 Hours)

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

Examiners: Prof. C. Burkley Mr. D. O’Donovan Mr. J. G. Ryan

Q1 (a) Define a structure capable of implementing a linked list based stack data type. Assume the information consists of one piece of data of type integer [3 %] (b) Write functions to implement the following for a linked-list based stack: i. Initialise the stack [2 %] ii. Push information onto the stack [10 %] iii. Pop information off the stack [5 %] (c) Why is it so important to deallocate the pointer when popping information from the stack in (b)? [3 %] (d) The C language makes great use of the system stack. Briefly describe the purpose and use of the stack in the context of the execution of a C program. [2 %]

Q2. (a) Describe the operation of the mechanism referred to as passing by reference. [3 %] (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 1 (i) Using diagrams, in conjunction with the addresses supplied in Table 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 %]

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

(b) The prototype for the malloc()function in C is:- void *malloc(size_t numBytes); (i) Explain the purpose and operation of this function. (ii) What are the implications of the void * and size_t numBytes for the function’s typical use in a program? Illustrate your answer by example. [6 %]

(c) Write a C program which performs the following operations.

8, 12, 19, 16, 3, 21, 11, 7, 5, 10 [5 %]

(b) Describe the following methods of binary tree traversal, showing the output from each in relation to the tree you constructed in (a) above: Pre-Order In-Order Post-Order [9 %]

(c) Draw the binary tree resulting from the deletion of nodes 19 and 8 from the tree constructed in (a). Explain what adjustments have taken place and why. [6 %]

(d) Write a boolean function which will search for an item in a binary search tree in which the nodes contain integers. [5 %]