CSE 131 Introduction to Computer Science Fall Exam I

Similar documents
CSE 131 Introduction to Computer Science Fall Exam I

CSE 131 Introduction to Computer Science Fall Exam I

CSE 131S Introduction to Computer Science Summer SON Exam I

CSE 131 Introduction to Computer Science Fall 2016 Exam I. Print clearly the following information:

CSE 131 Introduction to Computer Science Fall Exam II

CSE 131 Introduction to Computer Science Fall Exam II

CSE 131 Introduction to Computer Science Fall Exam II

CSE 131 Introduction to Computer Science Fall Final Exam

CSE 131 Introduction to Computer Science Fall Exam III

CSE 247 Data Structures and Algorithms Fall Exam I

CS 111X - Fall Test 1

CS 111X - Fall Test 1 - KEY KEY KEY KEY KEY KEY KEY

CSE 131S Introduction to Computer Science Summer SON Exam III

Final Exam. COMP Summer I June 26, points

(the bubble footer is automatically inserted into this space)

Part 1 (80 points) Multiple Choice Questions (20 questions * 4 points per question = 80 points)

CIS 110 Fall 2014 Introduction to Computer Programming 8 Oct 2014 Midterm Exam Name:

COMP 401 Midterm. Tuesday, Oct 18, pm-3:15pm. Instructions

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Spring 2017 CS 1110/1111 Exam 1

Without fully opening the exam, check that you have pages 1 through 11.

University of Maryland College Park Dept of Computer Science CMSC106 Fall 2016 Midterm I

CS 2604 Minor Project 1 DRAFT Fall 2000

CS 1301 Exam 1 Fall 2010

Spring 2017 CS 1110/1111 Exam 3

Read this before starting!

Discrete Mathematics and Probability Theory Fall 2015 Rao Midterm 1

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science

Note that there are questions printed on both sides of each page!

ENGR 100 Midterm (CSE Part) Winter 2014

CIS 110 Fall 2016 Introduction to Computer Programming 13 Oct 2016 Midterm Exam

CS 1301 Exam 1 Fall 2014

CS 2316 Exam 4 Fall 2011

CS 1301 Exam 1 Fall 2014

The American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011

CS 1301 Exam 1 Fall 2010

CSE 143 Final Exam Part 1 - August 18, 2011, 9:40 am

Read this before starting!

CS 1803 Fall 2010 Exam 1

gcc o driver std=c99 -Wall driver.c bigmesa.c

Ryerson University Vers HAL6891A-05 School of Computer Science CPS109 Midterm Test Fall 05 page 1 of 6

Final Exam COMP Fall 2004 Dec 16, 2004

Exam 2. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 40 Obtained Marks:

16.216: ECE Application Programming Fall 2011

The Program Specification:

Fall 2002 Page 1 of 9 READ THIS NOW!

CS 1301 Exam 3 Fall 2014

On my honor I affirm that I have neither given nor received inappropriate aid in the completion of this exercise.

Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Midterm 1

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring Instructions:

COS 126 General Computer Science Spring Written Exam 1

CS 1803 Fall 2010 Exam 1

CIS 110 Introduction to Computer Programming 8 October 2013 Midterm

Read this before starting!

Practice Midterm 1. Problem Points Score TOTAL 50

CS 2604 Minor Project 1 Summer 2000

Computer Programming : C++

York University AS/AK/ITEC INTRODUCTION TO DATA STRUCTURES. Midterm Sample I. Examiner: S. Chen Duration: One Hour and 30 Minutes

ECE 2035 Programming HW/SW Systems Fall problems, 4 pages Exam Three 14 November Your Name (please PRINT clearly) Signed.

CSc Introduction to Computing

Exam Percentage: / 55 = %

3. When you process a largest recent earthquake query, you should print out:

5. PLEASE TAKE HOME the question bundle, but turn in 2 paper sheets: The scantron AND the paper where you wrote your programming question solution!

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

CS 1301 Exam 1 Spring 2011

CSEN202: Introduction to Computer Science Spring Semester 2017 Midterm Exam

Read this before starting!

Repetition Structures

CSE 142, Autumn 2008 Midterm Exam, Friday, October 31, 2008

UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING

Spring 2017 CS 1110/1111 Exam 2

CS 2505 Computer Organization I

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

CIS 110 Introduction to Computer Programming Spring 2016 Midterm

COMP-202: Foundations of Programming. Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015

Decision Logic: if, if else, switch, Boolean conditions and variables

Computer Science Foundation Exam. May 3, Section I A. No Calculators! Name: SSN: In this section of the exam, there are three (3) problems.

CIS 110 Introduction To Computer Programming. November 21st, 2011 Exam 2

CSCI 131, Midterm Exam 1 Review Questions This sheet is intended to help you prepare for the first exam in this course. The following topics have

CS Name : Grading TA:

Good Evening! Welcome!

Database Programming - Section 16. Instructor Guide

PREPARING FOR PRELIM 1

CS 3114 Data Structures and Algorithms Test 1 READ THIS NOW!

Read this before starting!

You have 45 minutes to work on this exam. It is a "closed-book/closed-notes" test.

CS 455 Midterm Exam 1 Fall 2015 [Bono] Thursday, Oct. 1, 2015

Eng. Mohammed S. Abdualal

AP Computer Science Principles Programming Question Tips. 1: Which algorithm/code segment achieves some result?

CPSC 121 Some Sample Questions for the Final Exam Tuesday, April 15, 2014, 8:30AM

ECE 2035 Programming HW/SW Systems Spring problems, 5 pages Exam Three 8 April Your Name (please print clearly)

CS 1301 Exam 1 Spring 2014

CS 2316 Exam 4 Fall 2011

Computer Science Foundation Exam. March 3, Section I A. No Calculators! Name: SSN: In this section of the exam, there are three (3) problems.

CIS 110 Introduction to Computer Programming Summer 2016 Midterm. Recitation # (e.g., 201):

Control Structure: Loop

LAB 12: ARRAYS (ONE DIMINSION)

CIS 110 Introduction To Computer Programming. February 29, 2012 Midterm

CS 101 Spring 2007 Midterm 2 Name: ID:

Transcription:

CSE 131 Introduction to Computer Science Fall 2017 Exam I Given: 28 September 2017 Due: End of session This exam is closed-book, closed-notes, no electronic devices allowed. The exception is the sage page on which you may have notes to consult during the exam. Answer questions on the pages of the exam. Do not unstaple the pages of this exam, nor should you attach any other pages to the exam. You are welcome to use the blank space of the exam for any scratch work. Your workmustbelegible. Work that isdifficulttoread willreceive nocredit. Donot dwell over punctuation or exact syntax in code; however, be sure to indent your code to show its structure. You must sign the pledge below for your exam to count. Any cheating will cause the students involved to receive an F for this course. Other action may be taken. If you need to leave the room for any reason prior to turning in your exam, you must give your exam and any electronic devices with a proctor. You must fill in your identifying information correctly. Failure to do so is grounds for a zero on this exam. When you reach this point in the instructions, please give the instructor or one of the proctors a meaningful glance. Name (print clearly): Print clearly the following information: Student 6-digit ID (one digit per box): Your answers below tell us where to return your graded exam. What time do you arrive in studio/lab? (circle one) 11:30 1:00 2:30 4:00 Which Urbauer lab? (your best guess, circle one) 214 216 218 222 Pledge: On my honor, I have neither given nor received any unauthorized aid on this exam. Signed: (Be sure you filled in your information in the box above!)

CSE 131 (Exam I) 2 Due by End of session Problem Possible Received Grader Number Points Points Initials 1 20 2 30 3 20 4 30 Total 100

CSE 131 (Exam I) 3 Due by End of session 1. (20 points) (a) (10 points) Circle the correct type for each expression in the table below, and state the result of evaluating the expression: Expression Type Result 7 / 2 double int boolean String 7 / 2.0 double int boolean String 131 > 132 double int boolean String 1.8 + "0" double int boolean String "Sept " + (20+3/2) double int boolean String (17/8) +"" +(3 < 4) double int boolean String true && false double int boolean String! ((1 > 2) && true) double int boolean String 3/2 <= 1 double int boolean String true false double int boolean String (b) (5 points) Below draw the expression tree 1 for the expression 1+2 3+4 5 1 Or, explain exactly the order in which the operations occur.

CSE 131 (Exam I) 4 Due by End of session (c) (5 points) c d b + a / * Complete the blanks below regarding the tree shown above, which uses the aritmethic operators +,, and /: The The operator is the first operation to execute. operator is the last operation to execute. 2. (30 points) (a) (10 points) Complete the code below so that it computes and prints the integer division of a/(a-b), if a-b is not zero. If a-b is zero, the code should print Error. int a = ap.nextint("value for a?"); int b = ap.nextint("value for b?"); Continued on next page...

CSE 131 (Exam I) 5 Due by End of session (b) (20 points) Complete the code below so that it determines how many of N random numbers are less than 0.5, with each random number chosen by a call to Math.random(). Recall that each call to Math.random() returns a double r such that 0 r < 1. Do not use any arrays! Your code should produce output such as the following (in the example below, I typed 100 in response to the prompt): You asked for 100 random numbers. Of those, 63 were less than 0.5. Your output will depend on the value of N supplied when the program is run, as well as the results of the calls to Math.random(). int N = ap.nextint("how many random numbers?");

CSE 131 (Exam I) 6 Due by End of session 3. (20 points) We have studied 4 basic data types in the first part of our course: int, double, boolean, and String. Fill in the table below to supply the data type most appropriate for the specified scenario and provide one simple example. Note that a given scenario may have more than one correct answer. Scenario Circle one type Example 2 points 3 points The name of the TA most helpful to you in this course The number of studios you have completed so far The fraction of students who haveturnedinlab1ontime Whether or not you have have pulled from git double int boolean String double int boolean String double int boolean String double int boolean String

CSE 131 (Exam I) 7 Due by End of session 4. (30 points) An integer array nums has been created for your use in this problem. Each integer in the array could be positive, negative, or zero. An example of such an array follows: nums array [0] [1] [2] [3] [4] [5] [6] [7] contents 50 81 5-2 -2-1 0 2 While thearray inthe example above has 8entries, it isonly anexample forillustrative purposes. The array nums could be of any size. (a) (5 points) Complete the code below so that it sets N to the size of the nums array: int N = nums.length; // Our free gift to you // Please, no need to thank us! (b) (10 points) Complete the code below so that it computes the sum of all of the entries in the nums array. Given the example above, your code would produce The sum is 133. // // you can use N, as computed above, // or not, as you wish // for ( ) { } System.out.println("The sum is " + sum); Continued on next page...

CSE 131 (Exam I) 8 Due by End of session (c) (10 points) Your tasknow isto createasumsarraythat contains ateach element i the sum of all entries in nums up to and including entry i. For example, given the nums array reprised from above: nums array [0] [1] [2] [3] [4] [5] [6] [7] contents 50 81 5-2 -2-1 0 2 the code you are about to write would produce the sums array: sums array [0] [1] [2] [3] [4] [5] [6] [7] contents 50 131 136 134 132 131 131 133 Below, write the code to compute the sums array as described above, assuming you are given a nums array of some size (not necessarily the size of our running example). Do not print out anything, just compute the sums array properly. Be sure to declare and allocate the sums array. Continued on next page...

CSE 131 (Exam I) 9 Due by End of session (d) (5 points) Finally, given the sums array as described above, write code below that prints each index i of sums at which the entry 131 appears. 2 In our running example, the output would be: At 1 At 5 At 6 2 If you had trouble with the previous part of this problem, just assume that sums is somehow computed correctly and you can still answer this part.

CSE 131 (Exam I) 10 Due by End of session