Binary Search algorithm - Computer Applications and Programming - Exam, Exams of Computer Programming

Main points of this past exam are: Binary Search Algorithm, Operation, Implement, User-Defined Data Type, Capable of Storing, Integer Co-Ordinates, Visual Basic

Typology: Exams

2012/2013

Uploaded on 03/30/2013

lalitchndra
lalitchndra 🇮🇳

4.5

(12)

146 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Cork Institute of Technology
Page 1 of 3
Bachelor of Engineering in Electronic Engineering – Stage 2
(EELXE_7_Y2)
Autumn 2008
Computer Applications & Programming
(Time: 3 Hours)
Answer ANY five questions.
All questions carry equal marks.
Examiners: Mr. D. O’Donovan
Mr. D. Denieffe
Dr. P. O’Sullivan
1. (a) Describe the operation of the Binary Search algorithm. Use the list:
1 5 7 8 10 15 20 23 25 40
Demonstrate the operation of the Binary Sort algorithm by searching for 7. [8 %]
(b) Write code to implement the Binary Search algorithm in BASIC. [12 %]
2. (a) Define a user-defined data type, called ‘sample’, capable of storing two integer co-ordinates –
called amplitude and time. [5 %]
(b) Declare an array of 300 samples as defined in (a) called ‘sampleData’. [3 %]
(c) Write Visual BASIC code such that when the command Button ‘Read’ on the program form
is clicked i.e. ‘Read_click()’ event occurs, the sample data from a file called ‘c:\input.dat’ is
loaded into the array defined in (b). The data should be read until the end of file is reached.
The data is stored in the format: amplitude1, time1, amplitude2, time2, amplitude3, time3,
etc. [6 %]
(d) Write Visual BASIC code for the button ‘Average_click()’ event to calculate the average of
the amplitude values extracted from the file in (c). [6 %]
pf3

Partial preview of the text

Download Binary Search algorithm - Computer Applications and Programming - Exam and more Exams Computer Programming in PDF only on Docsity!

Cork Institute of Technology

Bachelor of Engineering in Electronic Engineering – Stage 2

(EELXE_7_Y2)

Autumn 2008

Computer Applications & Programming

(Time: 3 Hours)

Answer ANY five questions. All questions carry equal marks.

Examiners: Mr. D. O’Donovan Mr. D. Denieffe Dr. P. O’Sullivan

  1. (a) Describe the operation of the Binary Search algorithm. Use the list:

1 5 7 8 10 15 20 23 25 40 Demonstrate the operation of the Binary Sort algorithm by searching for 7. [8 %]

(b) Write code to implement the Binary Search algorithm in BASIC. [12 %]

  1. (a) Define a user-defined data type, called ‘sample’, capable of storing two integer co-ordinates – called amplitude and time. [5 %]

(b) Declare an array of 300 samples as defined in (a) called ‘sampleData’. [3 %]

(c) Write Visual BASIC code such that when the command Button ‘Read’ on the program form is clicked i.e. ‘Read_click()’ event occurs, the sample data from a file called ‘c:\input.dat’ is loaded into the array defined in (b). The data should be read until the end of file is reached. The data is stored in the format: amplitude1, time1, amplitude2, time2, amplitude3, time3, etc. [6 %]

(d) Write Visual BASIC code for the button ‘Average_click()’ event to calculate the average of the amplitude values extracted from the file in (c). [6 %]

  1. (a) Explain each of the following terms as they apply to Visual BASIC giving a typical example where appropriate: o Event procedures o Methods o Properties o Form o Module [10 %]

(b) What is meant by the ‘scope’ of a variable in Visual BASIC? How would you make a variable visible to all modules and forms of a program? [5 %]

(c) Which methods are used to determine the following information about a listbox. i. Number of elements ii. The currently selected item iii. The array containing the data iv. Add an element to the list v. Remove an element [5 %]

  1. (a) State and describe the important properties of the:
    • command button
    • scrollbar
    • option box
    • timer [8 %]

(b) Write a program to implement a simple calculator as illustrated in Figure 4.1. (continued on next page)