Possible exam questions with Scenarios

Slides:



Advertisements
Similar presentations
ALGORITHMS THIRD YEAR BANHA UNIVERSITY FACULTY OF COMPUTERS AND INFORMATIC Lecture two Dr. Hamdy M. Mousa.
Advertisements

1 CSE1301 Computer Programming: Lecture 23 Algorithm Design (Part 1)
Program Design and Development
CSE1301 Computer Programming: Lecture 27 Game Programming: Bingo.
Algorithms. Introduction Before writing a program: –Have a thorough understanding of the problem –Carefully plan an approach for solving it While writing.
Main task -write me a program
1 CSE1301 Computer Programming: Lecture 25 Software Engineering 2.
Python quick start guide
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Fruitful functions. Return values The built-in functions we have used, such as abs, pow, int, max, and range, have produced results. Calling each of these.
Algorithms In general algorithms is a name given to a defined set of steps used to complete a task. For example to make a cup of tea you would fill the.
Modular Programming. Modular Programming (1/6) Modular programming  Goes hand-in-hand with stepwise refinement and incremental development  Makes the.
Question 10 What do I write?. Spreadsheet Make sure that you have got a printout of your spreadsheet - no spreadsheet, no marks!
Procedures and Functions Computing Module 1. What is modular programming? Most programs written for companies will have thousands of lines of code. Most.
Review for Exam2 Key Ideas 1. Key Ideas: Boolean Operators (2 > 3) || (3 < 29.3) A.True B.False C.Impossible to determine (22 > 3) && (3 > 29.3) A.True.
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
L061 Algorithms, Part 3 of 3 Topics Top down-design Structure charts Reading Sections , 3.3.
Top-down approach / Stepwise Refinement & Procedures & Functions.
Loops and Simple Functions CS303E: Elements of Computers and Programming.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Low-Level Programming Languages, Pseudocode and Testing Chapter 6.
Design f. describe a design specification including input design, diagrammatic depiction of the overall system, processing, data structure design and output.
Chapter 7: Designing solutions to problems OCR Computing for A Level © Hodder Education 2009.
G043: Lecture 12 Basics of Software Development Mr C Johnston ICT Teacher
7 - Programming 7J, K, L, M, N, O – Handling Data.
CIS199 Test Review 2 REACH.
Chapter 11 - JavaScript: Arrays
CST 1101 Problem Solving Using Computers
Topics Introduction to Functions Defining and Calling a Void Function
IGCSE 4 Cambridge Data types and arrays Computer Science Section 2
Data Types Variables are used in programs to store items of data e.g a name, a high score, an exam mark. The data stored in a variable is entered from.
Searching Given a collection and an element (key) to find… Output
Different Types of Testing
CMPT 120 Topic:  Case Study.
CS1001 Programming Fundamentals 3(3-0) Lecture 2
Lesson 5 Functions I A function is a small program which accomplishes a specific task. For example, we invoke (call) the function, sqrt(x), in the library.
CS1371 Introduction to Computing for Engineers
Lecture 2 Introduction to Programming
ALGORITHMS & FLOWCHARTING II
Functions, variables, operators, loops Modularity
Algorithm and Ambiguity
Designing and Debugging Batch and Interactive COBOL Programs
Control Structure Senior Lecturer
Arrays An Array is an ordered collection of variables
Unit# 9: Computer Program Development
Problem Solving Techniques
Learning to Program in Python
Starter 15//2 = 7 (Quotient or Floor) (Modulus) 22%3 =1
Databases Lesson 2.
Lesson 15: Processing Arrays
Programming Fundamentals (750113) Ch1. Problem Solving
Algorithm Discovery and Design
If selection construct
The while Looping Structure
Design and Implementation
If selection construct
Topics Introduction to Functions Defining and Calling a Void Function
Basics of Recursion Programming with Recursion
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Topics Introduction to Functions Defining and Calling a Function
Computing Spans Given an an array X, the span S[i] of X[i] is
Loops and Simple Functions
Algorithms, Part 3 of 3 Topics Top down-design Structure charts
Algorithms For use in Unit 2 Exam.
The while Looping Structure
Pseudocode For Program Design.
Algorithms, Part 3 of 3 Topics Top down-design Reading
CMSC201 Computer Science I for Majors Lecture 12 – Program Design
Presentation transcript:

Possible exam questions with Scenarios

Advantages for using modular design to produce software Focus on small parts Easy to solve and test and debug Easy to maintain and update Development can be shred between teams Program develop faster Easy to monitor resources Modules can allocated according to expertise Reduce amount of code and codes can be reused Reduce time

Dosadvantages of Top –down modular design Modules must be linked Programmers must ensure that cross-referencing is done Interface between modules must be planned Testing of links must be carried out

Module design and Stepwise refinement A technique design to solve complex tasks by splitting the tasks into a smaller task

A computer program is designed to store the results of matches in a football competition and calculate the ranking of the teams. When the results are entered, the number of points of each team are updated as follows. If both teams have the same number of goals (draw) then each team gets 1 point if one team has more goals than the other (there is a winner) then the winning team gets 3 points, and the losing team gets 0 points IF goals_of_first_team = goals_of_second_team THEN points_of_(first_team) = points_of_(first_team) + 1 Points_of(second_team) = points_of(second_team) + 1 END IF

Answers IF goals_of_first_team > goals_of_second_team THEN points_of(first_team) = points_of(first_team) + 3 ELSEIF goals_of_second_team > goals_of(first_team) THEN points_of(second_team) = points_of(second_team) + 3 END IF

Write an algorithm which takes the number of tickets wanted as an input, and outputs the best seats available.

Input NumberOFTickets, n If n< 0 or n> 15 produce an error message And stop Else Loop through the rows from Row A Unitl seats are found or you reach row J provided this is within a loop Test that there are n seats available in row (together) by finding empty seats and checking n -1 seats after it If seats found then output the seat numbers

A printing company uses a computer program to randomly generate and print bingo tickets. Each bingo ticket has a grid with three rows and nine columns. Each row contains 5 numbers and 4 blank spaces. The computer program stores the numbers in a 2-dimesioal array called Ticket. In the array Ticket, the first index represents the row and the second represents the column e.g (1,4) = 32 means the number on row 1, column 4 is 32. To generate the tickets, the computer program first fills in the columns with random in tegers. After filling the array, the computer ensures that no numbers have been repeated, and replaces four positions on each row with the number 0.

A bingo ticket is printed using the following method: For every row in the array For every column in that row if the value is 0 then the output a space otherwise output the value Write an algorithm in pseudo-code to print the numbers in the array onto a ticket. You should indent your pseudo-code correctly to make it easier to understand.

FOR Row = 1 To 3 For Column = 1 TO 9 IF Ticket(Row, Column) = 0 THEN Print ‘ ‘ ELSE Print ticket(Row, Column) END IF NEXT Column GO to new line NEXT ROW

The following algorithm for a function CheckTotalLength() contains a FOR loop in lines 03 to 05. Rewrite this FOR loop as a WHILE loop FUNCTION CheckTotalLength() : BOOLEAN TotalLength = 0 FOR I = 1 TO NumberOfSongs TotalLength = TotalLength + SongLength(i) NEXT I RETURN (TotalLength > 80) END FUNCTION

i= 1 WHILE I <= NumberOfSongs TotalLength = TotalLength + SongLength(i) i=i+1 END WHILE

The design for a game contains the following pseudo-code IF Character has reached end of platform Display ‘’YOU WIN’’ REPEAT Play Music END IF UNTIL any key is pressed IF nested incorrectly in the loop Repeat should be within the IF statement Last two lines other way round Repeat has no UNTIL

Function Mystery (n : Integer) : Integer IF n < 20 THEN RETURN n ELSE RETURN Mystery ( n – 9 ) END IF END FUNCTION N = 15 State the value which will be returned by n and justify your answer

Function Mystery (n : Integer) : Integer IF n < 10 THEN RETURN n ELSE RETURN Mystery ( n – 9 ) END IF END FUNCTION Er