DEPARTMENT OF MATHS/STATS. AND COMPUTER SCIENCE
2NDSEMESTER EXAMINATION 2011/2012 CSC1102: INTRO. TO COMPUTER SC. II
INSTRUCTION: ANSWER ANY FOUR QUESTIONS AT LEAST ONE FROM EACH SECTION
1a. In a class of M students, each student offers N courses. If M=20 and N=5 write a flowchart and a computer program in Basic programming language that will accept the following input data: (i) name of a student. (ii) Matric number of a student. (ii) scores for the N courses. Compute each student average score, and each student is given a pass status if his/her average score is greater than or equal to 50 otherwise the student is given a fail status. Output your result to the screen of the monitor.
1b. Comment briefly on any two control structures you have employed in your computer program in question 1a above.
1c. With the aid of a simple illustration differentiate between a counted loop and conditional loop.
2a. Decline the term branching and comment briefly on any two types of branching known to you.
2b. Comment briefly on the various stages of program development known to you.
2ci. Define an array and comment briefly on its major properties.
2cii. Write an interactive basic program that will allow you to generate the elements of a two-dimensional array of any data type known to you.
3a. Explain what you understand by the efficiency of algorithm
3b. What makes it necessary to study algorithm as a computer scientist?
3c. What makes an algorithm Z more efficient than another algorithm Y
4a. Consider two computers A and B. Computer A is faster and runs in insertion sort against a slower computer B running merge sort. They each must sort an array of two million JAMB candidates using their registration numbers. Suppose that computer A execute one and a half billion instruction per a second and computer B executes only fifteen million instruction per second. Suppose also that the insertion sort was coded by the best programmer ever, and the merge sort by an amateur programmer. If the code for insertion sort takes 2n2 instructions to sort n numbers and that of takes 65 n log n.
(a). Compute the time it will take computer A to sort the array.
(b). Compute the time it will take for computer B to sort the same array.
(c). Describe the speed of one over the other.
(d). Using the answers in (a) and (b), describe which of the two computers is more efficient, based on the algorithm they run.
5. (a) Give the steps involved in the insertion sort algorithm. Given the elements of the array j: using insertion sort, arrange the following items of the array with the iterator positioned at index 1. 61 48 34 82 48 57 89 45 70
(b). Describe the Bubble sort and Mergesort algorithms giving their worst-case computational complexity. Give the general strategy for moving n disks from origin to destination in the Towers of Hanoi game.
Also Read: BASIC Program For Sum of Numbers Using IF Then Statement
Pascal Arithmetic Program Using IF THEN statement
Pascal Program to Create and Save Records in a Textfile
Pascal program To Calculate Area of a Triangle
Pascal Program of Matrix Multiplication
Pascal Program to Read in Even Numbers Into An Array
Pascal Program to Find The Average Of Only Positive Numbers Using While Do loop