46 Pages

SamplePaper

Course: CS 2130, Fall 2009
School: East Los Angeles College
Rating:
 
 
 
 
 

Word Count: 2136

Document Preview

###2S####2o####2o###3a#x##23####3# 7###########################4a######"#######A##################0####0####1####1####1####1#X##23####23####23####2C# ##3####47#*##4a####1########47####4##&##47####47####4a####47####47####47####47### #47####47####Answer 3 questions.Time allowed: 1.5 hoursDisclaimer:This sample paper gives an indication as to the style of the sort of questions that may appear on the...

Register Now

Unformatted Document Excerpt

Coursehero >> California >> East Los Angeles College >> CS 2130

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
###2S####2o####2o###3a#x##23####3# 7###########################4a######"#######A##################0####0####1####1####1####1#X##23####23####23####2C# ##3####47#*##4a####1########47####4##&##47####47####4a####47####47####47####47### #47####47####Answer 3 questions.Time allowed: 1.5 hoursDisclaimer:This sample paper gives an indication as to the style of the sort of questions that may appear on the CS213 examination, i.e. giving a reasonable indication of the mix of bookwork and problems.It should not be interpreted as indicating that certain topics will appear or will not appear on the paper. Potentially questions may be set on any part of the lecture material. Any deductions that you make from this sample paper regarding the topics appearing in the actual examination, you make at your own peril!1. a) Say what is meant by the terms expression and command, bringing out as clearly as possible the distinction between the two terms. Your answer should introduce the concept of state. Discuss the extent to which programming languages in current use maintain a clear separation between expressions and commands. Credit will be given for relevant examples and for comment on the advantages and disadvantages of separation of expressions and commands.(9 marks) b) Outline the similarities and differences between the switch statement in languages such as C and Java and the CASE statement in Ada. In your answer you should concentrate mainly on the semantics of the two constructs rather than their syntactic differences and you should comment on the advantages and disadvantages from a software engineering point of view of the two constructs.. (8 marks) c) Describe what is meant by i) static scoping ii) dynamic scoping in a computer language. Illustrate your answer with a suitable example code fragment.(8 marks) 2. a) Explain what is meant by the following terms relating to subprogram parameters: i) a value parameter (3 marks) ii) a reference parameter. (3 marks) Discuss briefly the parameter-passing methods used in Ada for IN mode parameters distinguishing clearly between the methods used for scalar types, composite types and tagged types.(3 marks) b) An unconstrained type Vector is defined in Ada as follows:TYPE Vector IS ARRAY(Positive RANGE <>) OF Float; Define new overloadings for the Ada operators "+" and "*"; the operator "+" should add two vectors of the same size whilst the operator "*" should allow multiplication of a vector of type Vector by a scalar of type Float.(7 marks) c) State what is meant by aliasing in a computer language. (3 marks) Consider the following code which defines a multiplication procedure for 3-dimensional vectors of the type Vector defined in part (b):SUBTYPE Vec3 IS Vectotr(1 .. 3);PROCEDURE VectorProduct(A, B : IN Vec3; C : OUT Vec3) ISBEGIN C(1) := A(2)*B(3) - A(3)*B(2); C(2) := A(3)*B(1) A(1)*B(3); C(3) := A(1)*B(2) - A(2)*B(1);END VectorProduct; Discuss carefully any potential pitfalls that might arise when using the procedure VectorProduct and outline how the subprogram might be recoded to avoid these pitfalls (full Ada code is not necessary).(6 marks) 3. Consider the following task type Timer, which provides for a time display that counts down in seconds until a time allowance has expired. For simplicity, code for controlling the screen position at which output is produced has been omitted.TASK TYPE Timer IS ENTRY Start(From : in Natural); ENTRY Check(NoTime : out Boolean); ENTRY Stop;END;TASK BODY Timer IS StartTime, Now : Duration; -Used with Split and Clock from Ada.Calendar Year, Month, Day : Integer; -- Needed to use Split TimeGone, TimeRecorded : Integer := 0; TimeLeft : Integer;BEGIN ACCEPT Start(From : in Natural) DO TimeLeft := From; END; Split(Clock, Year, Month, Day, StartTime); Put("Time Left: "); Put(TimeLeft, 2); LOOP SELECT ACCEPT Stop; EXIT; OR ACCEPT Check(NoTime : out Boolean) DO NoTime := TimeLeft <= 0; END; OR DELAY 0.1; IF TimeLeft > 0 THEN Split(Clock, Year, Month, Day, Now); TimeGone := Integer(Now - StartTime); IF TimeGone > TimeRecorded THEN TimeLeft := TimeLeft - (TimeGone TimeRecorded); TimeRecorded := TimeGone; Put(TimeLeft, 2); END IF; END IF; IF TimeLeft <= 0 THEN Put(ASCII.BEL); END IF; END SELECT; END LOOP;END; a) Show how to code a program, making appropriate use of Timer, that asks a question to which the user must respond in a set time. Give suitable declarations and a main program. Cursor positioning code may be omitted.(8 marks) b) Explain the structure of the Timer code, concentrating on those aspects that are specific to concurrent programming, for example the SELECT statement.(9 marks) c) Explain how the code that you gave for part (a) makes use of Timer. Pay particular attention to communication.(8 marks) 4. a) Describe briefly the purpose of protected objects in Ada and outline the r5les of procedures, functions and entries provided in the visible part of a protected object's specification.(10 marks) b) The following protected type Stack encapsulates stack of integer values based on a linked list implementation: PROTECTED TYPE Stack IS ENTRY Push(X : IN Integer); -- push item X onto the top of the stack ENTRY Pop(X : OUT Integer); -- pop an item off the top of the stack FUNCTION IsEmpty RETURN Boolean; -- returns True if the stack is empty and False otherwise PROCEDURE Clear; -- resets the stack to emptyPRIVATE TYPE Node; TYPE Ptr IS ACCESS Node; TheStack : Ptr;END Stack; Write a suitable body for the protected type Stack. Storage deallocation is not required. (13 marks) 5. a) Describe briefly the purpose of controlled types in Ada and outline the r les of the three primitive operations Initialize, Finalize and Adjust of controlled types.(6 marks) b) Outline the steps necessary to define a new controlled type in Ada highlighting the rTles of the package Ada.Finalization, type extension, primitive operations and abstract types in the process.(7 marks) c) The following outline package specification provides a type List for a singly-linked list of integers by extending the type Controlled from Ada.Finalization. The features of controlled types are to be used to provide automatic storage deallocation and deep copy on assignment of list objects and automatic storage deallocation when control finally leaves the scope of a list object.WITH Ada.Finalization; USE Ada.Finalization;PACKAGE SL_List IS TYPE List IS NEW Controlled WITH .... PRIVATE; -- declarations of exported operations for the type List ....PRIVATE TYPE Node; TYPE NodePtr IS ACCESS Node; TYPE Node IS RECORD ..... -- to be completed END RECORD; TYPE List IS ......; -- to be completed PROCEDURE Initialize(L : IN OUT List); PROCEDURE Finalize(L : IN OUT List); PROCEDURE Adjust(L : IN OUT List);END SL_List; Complete the private part of the package specification where indicated and write suitable implementations for the operations Initialize, Finalize and Adjust.(12 marks)END OF EXAMINATION PAPER Extra question for good measure!6 a) Describe briefly the meaning of the following generic formal parameter specificationsi) TYPE T IS PRIVATE;ii) TYPE T(<>) IS PRIVATE;iii) TYPE T IS LIMITED PRIVATE;iv) TYPE T IS (<>);v) TYPE T IS RANGE <>;vi) WITH FUNCTION "+"(X, Y : T) RETURN T;(9 marks) b) The following is an outline declaration of a generic function Max which is to return the largest element of an array of type Collection according to some comparison function "<" which is to be supplied as a generic parameter when the function is instantiated. In an instantiation of the function the actual parameter corresponding to formal parameter Collection can be any (constrained or unconstrained) array of elements of any non-limited definite type indexed by any integer type.GENERIC TYPE ElemType IS .....; -- to be completed TYPE IndexType IS .....; -- to be completed TYPE Collection IS ARRAY .....; -- to be completed WITH FUNCTION "<" .....; -- to be completedFUNCTION Max(C : Collection) RETURN ElemType; Complete the declaration of the function and write a suitable complete function definition.(11 marks) c) Write down suitable code fragments to instantiate the generic function Max in (b) above i) to return the largest element in an unconstrained array of integer values indexed by the enumeration type DayOfWeek whereTYPE DayOfWeek IS (Mon, Tue, Wed, Thu, Fri, Sat, Sun);(2 marks) ii) to return the record with the smallest Key field in a constrained array of record values of type RecType indexed by the integer subrange MonthNumber whereTYPE RecType IS RECORD Key : Integer; -- other fields of the recordEND RECORD;SUBTYPE MonthNumber IS Integer RANGE 1 .. 12;(3 marks)CS213 Programming Language Concepts and Paradigms Page # of 5# 9#hh are each #######,######8###;###<###c###m###r###y#########J###P### ##################5###7###### ## b## e## ## ## ## ## ### ### 0## 8## ## ## ### ### m## ## ## ###3###_#######################q###v###### #########h###r###t###| ### ### #######%################ ####### ###2###F###q###w###G### ###G### ############? ###A###B###U###X###p###t############################## ########################## ########### ########### ############@ #############Y###### ###############2###5###q###{###T###^### ############## ### ## ### .## P## l## ## ## ##!##! ##"&##"/##"n##"o##" ##"##"##"##"##"### ############################################################### ################################################################################### ################################################################################### ######################################################### #@###########@##` ########### ##########-###########,######9#########;###<###=###>######################### ###### ### ############ #########G###Q################################### )## *## ## ### ### [## \## ## ####5 ~ #######(# #####(@#####(#### ###(# ##### #(#@## ###(# ##### #(#@################(####h#####(# ######(# ######(########(# ######(# ######(# ######(# ## ###(# ##########h### ###(# ##########h#######(# ############h### ###(# ##########h#######(# ###1###########A###G###i### ########### ## ## ## ## ## ############ #######_### ################B###k###r###}##############...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Air Force Academy - ME - 492
Air Force Academy - ME - 492
Air Force Academy - ME - 492
Air Force Academy - ME - 229
2009WeekJan. 5 Jan. 9Introduction to Engineering DesignMonday Lab.1B71 2:30-5:20PM Class start Jan 5 Introduction of Faculty and Group Members Introduction to the Design Projects. Prof. Burton Design Process &amp; Designers- Prof. W.Szyszkowski (Co
East Los Angeles College - CS - 2130
CS2130 Programming Language ConceptsUnit 15 addendum Function Pointers in C and C+We can also define function pointers in C or C+. For example to define a pointer type to refer to functions of type double &gt; double we would define#include &lt;math.h&gt;
CSU Fullerton - SRT - 0901
SRT210Week OneWeek OverviewCourse Introduction System Administrators' Role Security Policy Role Types of Security Policies Week One TasksYour ProfessorRaymond Chan Email: raymond.chan@senecac.on.ca Home page: cs.senecac.on.ca/~rchan/ Office
East Los Angeles College - CS - 2130
There is no lab sheet for the labs in the weeks ending Fri 24thFebruary and Friday 3rd March.This is to allow students to work on the PLC coursework assignmentwhich is due in 7th March.There will be a lab sheets for the labs in week 8-11 ( wee
Air Force Academy - ME - 492
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsLab Class 4 An On-screen Time Display Program In this example a task is used to manage a clock which displays the time and date at a certain position on the screen; every second the task updates the
Air Force Academy - ME - 492
Air Force Academy - ME - 492
Air Force Academy - ME - 492
Air Force Academy - ME - 492
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 11 More on Synchronisation in Concurrent Ada Programs The Ada Rendezvous Protected objects and protected types largely solve the problem of synchronising task access to shared data structures. P
Air Force Academy - ME - 492
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 16 - More on Object-Oriented Programming in Ada Object-Oriented Features in Standard Ada Libraries The standard Ada libraries use the object-oriented features of Ada to provide a number of power
Air Force Academy - ME - 492
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 13 Encapsulation and Abstraction Client/Server Model A package typically provides a service that is utilised by a client. The interface of a package should provide exactly the information needed
Air Force Academy - ME - 492
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 8 General Access Types In CS1210 (DSA) access or pointer types were used to provide a means of manipulating objects created by an allocator (i.e. NEW). Such access types are referred to as pool-
Air Force Academy - ME - 492
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 4 - Bindings and Scope Binding Each time execution of a program in a high-level programming language such as Ada reaches a declaration that declaration is elaborated which has the effect of bind
Air Force Academy - ME - 324
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 12 Java Threads A thread in Java is an instance of the Thread class (or a class that extends Thread). The Thread class provides methods to create, control and synchronise a thread. When a thread
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 5 Function and Procedure Abstractions Functions A function definition establishes name for a program entity which, when called, yields a value (of a specific type) which usually depends on one o
Air Force Academy - ME - 492
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 10 Synchronization in Concurrent Ada Programs Protected Variables In Ada 95 a simple mechanism: namely protected variables, was introduced for controlling access to shared data. A protected vari
Air Force Academy - ME - 324
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsLecture 2 - Programming Language Concepts Every programming language has syntax and semantics: The syntax of a programming language is concerned with the form of expressions, commands and declaration
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 16 Object-Oriented Programming in Ada Tagged Types In the previous lecture we saw how a new type could be derived from an existing type and how such a type inherited the primitive operations of
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsLecture 14 Generics In the previous lecture the package IntStack provided an abstract data object namely a stack of integers. It should be clear that the implementation of a stack of floating point n
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 7 - More on Types Semi-Boolean Truth Values In some languages (for example C and C+, but not Java) there is no special Boolean type as such. Instead comparisons and other Boolean expressions pro
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 3 - Values, Types and Variables The term value refers to anything that results when an expression is evaluated, or an entity that may be stored in a memory cell within the computer, or which for
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 9 Concurrent Programming in Ada Tasks So far we have only considered sequential programs in which statements are obeyed in a single thread of control. However a program can also be built from tw
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 6 Renaming in Ada It is possible to give a new name to certain Ada entities using a renaming declaration. The following entities can be renamed: variables constants array elements packages recor
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsPractical Class 2 Solutions Solutions to the first lab class exercises may now be found on the module web-site and in the Unix directory ~barnesa/cs2130/lab1. Recall that you can access the module we
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsPractical Class 1 The Module Web-site Check that you can access the module Web-site by following the CS2130 link from my home page with URLhttp:/www.aston.ac.uk/~barnesaor following the links Prog
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsPractical Class 3 The Ada.Command_Line and POSIX.Files Packages The purpose of this lab is to introduce a few more of the Ada Libraries available with the Gnat Ada system. which enable an Ada program
Air Force Academy - ME - 475
f4_3f4_4
CSU Fullerton - OPS - 234
AS/400 Operations Navigator It is now possible for a user to execute AS/400 commands without having to learn Command Language syntax. Also, for those users who are aware of CL but feel more productive by pointing and clicking with a graphical interfa
East Los Angeles College - CS - 2130
7#&lt;#R#:#}#P#3#P#3#Q3# #Q=##QI#QW#QW#QW#QW##Qc# #Qm# #Qw#Qw#Qw#Qw#Qw# #Q#Qp#Q #Qe#Q#Q#,#Q#Q#Q #Q#Q#Q#Q# #Q#R# # # ##CS2130 Programming Language Concepts and ParadigmsUnit 9 Concurrent Programming in AdaTasksSo far we have only considered sequentia
East Los Angeles College - CS - 2130
7#|#:#v6#%#3# #3#3#.#a#$#I#w# #p## # # # # #,#&quot;##&amp;# (#,#0#2#6# # ## #CS2130 Programming Language Concepts and ParadigmsUnit 4 - Bindings and ScopeBindingEach time execution of a program in a high-level programming language such as Ada reaches a dec
Air Force Academy - ME - 324
Iron and Iron-Fe3C Equilibrium Phase DiagramIron (Fe) * Occurs naturally in meteorites. Only a small quantity is of terrestrial origin. * Is the second most abundant metal (after aluminium) in the Earths crust. It constitutes about 95% of all the me
East Los Angeles College - CS - 2130
7#\t# #Y #$#.# #.# .#&gt;#CN#&lt;\# \# \# \## h# # r# # |#R|# |# |#R|# # U# #d# # #7# # # #R# # #v# # # ## #CS2130 Programming Language Concepts and ParadigmsUnit 10 Synchronization in Concurrent Ada ProgramsProtected VariablesIn Ada 95 a simple mechanis
Air Force Academy - ME - 492
Department of Mechanical Engineering University of Saskatchewan ME464.3 MATERIALS IN ENGINEERING DESIGN Mid-Term Examination Instructor: I. Oguocha Date: 1 March, 2002.Instructions 1. Answer ALL Questions Time: 1 hours 2. Class notes are allowed. C
UMBC - PHYSICS - 151
Find the Angles An 82 kg traffic light is supported by two cables, one pulling up and to the right with 500 N, the other pulling up and to the left with 643 N. Find the angle which each cable makes with the horizontal.
Air Force Academy - ME - 492
ME492.3MaterialsinEngineeringDesign DepartmentofMechanicalEngineering UniversityofSaskatchewan ASSIGNMENT#1SOLUTIONJanuary2009 Question #1 Several professions claim to design one thing or another. Typical examples include: Fashion designer/tailor (de
Air Force Academy - ME - 229
AutoCAD 10% Progress report 5% Log book 10% Design report 25% Presentation 20% Final exam 30% Assignments P/F WHMIS P/F If you receive a F, marks will be withheld until a satisfactory performance has been achieved.Final MarksThe marks represent ra
Air Force Academy - ME - 229
Four Layered Spherical Display Structure:Panoramic Display of Lumieres PhotostereosynthesisGARNET HERTZ: DESIGN PROPOSALGarnet Hertz 1 January 2008 garnethertz@gmail.comAbstract: Proposal for building of a custom four-layered transparent spher
CSU Fullerton - GAM - 666
GAM666 Introduction To Game ProgrammingWindows Programming in C+ You must use special libraries (aka APIs application programming interfaces) to make something other than a text-based program. The C+ choices are: The original Windows SDK (Softwa
Air Force Academy - ME - 229
ME 229 AutoCAD SectionAssignment # 6 Draw the following drafts: Sizes of mechanical parts according to the dimension shown Lines and text are to be properly defined in different layers. Model geometry, dims and text in model space Use Papers
CSU Fullerton - SYA - 710
When One Billion does not equal One Billion, or: Why your computers disk drive capacity doesnt appear to match the stated capacityA White Paperby James Wiebe, CEO WiebeTech LLC www.wiebetech.com 2003 WiebeTech LLC This paper may be reproduced in
East Los Angeles College - CS - 1110
CS1110 Introduction to Systematic Programming Week 3 - Practical Class 1Compiler Error Messages and Compiler Listings So far we have assumed that when you compile an Ada program everything goes smoothly. However suppose that the source file ( divide
East Los Angeles College - CS - 1110
CS111 Introduction to Systematic Programming Second Practical ClassIf you did not attend the first practical or if you did not complete the worksheet, work through the hand-out for that practical BEFORE working on this sheet. Open the file prog1.adb
East Los Angeles College - CS - 1110
7#,#i# #h#.#!#.#(#.# .# .# .#&lt;#P# # #&quot;#4#L# #P#,# #x#(#D# $# # D# #*# # .## ]#I# #w#/#V# ##%#(# #Introduction to Systematic ProgrammingUnit 7 - Writing Larger Programs7.1 IntroductionThe first few units of this course have advocated a four stage ap
CSU Fullerton - INT - 428
1. Describe what the HTTP protocol is used for.HTTP is the protocol used to deliver hyptertext documents, images, and other data between web servers and web clients.2. (a) Which of the following colours are members of the so-called browsersafe pal
Air Force Academy - GE - 449
Presentation Outline1. The GapTechnology and Sustainable DevelopmentGE 449Lisa White Chris Richards2. Global Sustainability 3. The Scala Project in the Philippines 4. The Multifunctional Platform in Ghana 5. Workshop Shea Butter in West Afric
East Los Angeles College - CS - 3250
CS3250 Distributed Systems1. a) Describe how the Transmission Control Protocol (TCP) provides a reliable connection-oriented service on top of the unreliable connectionless service provided by the Internet Protocol (IP). In your answer you should i
East Los Angeles College - CS - 3250
CS3250 Distributed SystemsLecture 6 - More on TCP/IP Delay or Loss of Data Segments In the left-hand diagram below host 1 sends a data segment containing n octets of data with sequence number X1 and when this arrives at host 2, an acknowledgement is
East Los Angeles College - CS - 3250
CS3250 Distributed SystemsLecture 13 A Server Which Reuses Idle tasks The multi-threaded server in lecture 11 created a new task for each client connection. This task becomes idle when the client that it is serving terminates the interaction by ente
Air Force Academy - GE - 111
Cramers RuleCRAMERS RULEGE 111 Engineering Problem Solving 20081Cramers RuleGabriel Cramer was a Swiss mathematician (1704-1752)GE 111 Engineering Problem Solving 20082Coefficient Matrices You can use determinants to solve a system o