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 131 Introduction to Computer Science Fall Exam II

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 Final Exam

CSE 131 Introduction to Computer Science Fall Exam III

CSE 247 Data Structures and Algorithms Fall Exam I

CSE 131S Introduction to Computer Science Summer SON Exam III

CS 111X - Fall Test 1

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

Final Exam. COMP Summer I June 26, points

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

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science

CS 2604 Minor Project 1 DRAFT Fall 2000

CS 1301 Exam 1 Fall 2010

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

(the bubble footer is automatically inserted into this space)

Computer Security Fall 2006 Joseph/Tygar Midterm 3

Spring 2017 CS 1110/1111 Exam 1

(the bubble footer is automatically inserted into this space)

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

Discrete Mathematics and Probability Theory Fall 2015 Rao Midterm 1

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

Computer Science CS221 Test 2 Name. 1. Give a definition of the following terms, and include a brief example. a) Big Oh

COS 126 General Computer Science Spring Written Exam 1

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

University of Virginia Department of Computer Science. CS 4501: Information Retrieval Fall 2015

CS 1301 Exam 1 Fall 2010

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

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

Features. What makes us different? Call for 24/7 support assistance. Page 2 of 8

CS112 Spring 2012 Dr. Kinga Dobolyi. Exam 2. Do not open this exam until you are told. Read these instructions:

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

CS 1803 Fall 2010 Exam 1

Read this before starting!

Final Exam. Name: Student ID Number: Signature:

CS 1110, LAB 1: PYTHON EXPRESSIONS.

Do not start the test until instructed to do so!

Spring 2017 CS 1110/1111 Exam 2

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

1 Fall 2017 CS 1110/1111 Exam 3

CS 1803 Fall 2010 Exam 1

Database Programming - Section 16. Instructor Guide

Spring 2017 CS 1110/1111 Exam 3

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

CS 3030 Scripting Languages Syllabus

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

CS 1301 Exam 1 Spring 2014

CDA 3103 Computer Organization Exam 1 (Sep. 22th, 2014)

Math 52 - Fall Final Exam PART 1

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

CS 1301 Exam 2 Fall 2010

Using C++, design an Abstract Data Type class named MyGrades. The class must have the following private members :

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

CIS 110 Introduction to Computer Programming Summer 2018 Midterm. Recitation ROOM :

ENGR 100 Midterm (CSE Part) Winter 2014

CS 1044 Programming in C++ Test 1 READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties.

EXAMINATION INSTRUCTIONS

CIS 110 Introduction to Computer Programming Summer 2014 Final. Name:

Introduction to SPSS on the Macintosh. Scott Patterson,Ph.D. Broadcast and Electronic Communication Arts San Francisco State University.

CS 1301 Exam 1 Fall 2014

York University AK/ITEC OBJECT-BASED PROGRAMMING. Midterm Test Sample. Examiner: S.Y. Chen Duration: One Hour and Fifteen Minutes

CS 1301 Exam 1 Spring 2011

CS 1301 Exam 3 Fall 2014

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!

CS 3114 Data Structures and Algorithms READ THIS NOW!

CS 1301 Exam 1 Fall 2014

1. Read each problem carefully and follow the instructions.

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

Introduction to Wimba

Final Exam COMP Fall 2004 Dec 16, 2004

CpSc 1111 Lab 9 2-D Arrays

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

Control Flow: Loop Statements

CSE 241 Algorithms and Data Structures Fall Semester, Midterm Exam

MATH 2100 / 2105 / 2350 EXAM 1

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

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

COS 126 Midterm 1 Written Exam Fall 2011

CSE 1223: Exam II Autumn 2016

The Program Specification:

CS 2604 Minor Project 1 Summer 2000

Dental College of Georgia

UNIVERSITY REGULATIONS

Problem Possible Points Points Earned Problem Possible Points Points Earned Test Total 100

(the bubble footer is automatically inserted into this space)

INF 315E Introduction to Databases School of Information Fall 2015

2. You are required to enter a password of up to 100 characters. The characters must be lower ASCII, printing characters.

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

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

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

CS 374 Fall 2014 Homework 2 Due Tuesday, September 16, 2014 at noon

MCS-378 Intraterm Exam 1 Serial #:

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Midterm 1

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

Exam Datastrukturer. DIT960 / DIT961, VT-18 Göteborgs Universitet, CSE

CS164: Midterm I. Fall 2003

Transcription:

CSE 131 Introduction to Computer Science Fall 2015 Given: 24 September 2015 Exam I 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. Print clearly the following information: Name (print clearly): Student 6-digit ID (print really clearly): Your answers below tell us where to return your graded exam. What time do you actually attend studio/lab? What room (222, 218, 216, or 214)? your best guess Problem Possible Received Number Points Points 1 20 2 30 3 25 4 25 Total 100 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 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 247 > 241 double int boolean String 3.0 + "0" double int boolean String "100" + (30+1) double int boolean String (7/8) + "nly" double int boolean String 5 / 2 double int boolean String 5 / 2.0 double int boolean String true && false double int boolean String! ((1 > 2) false) 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) 3 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 prints true if exactly two of the variables have the same value. Otherwise it should print false. int a = ap.nextint("value for a?"); int b = ap.nextint("value for b?"); int c = ap.nextint("value for c?"); Continued on next page...

CSE 131 (Exam I) 4 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?"); 3. (25 points) (a) (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. Also give a brief explanation of why you made that choice and one simple example. Note that a given scenario may have more than one correct answer. Continued on next page...

CSE 131 (Exam I) 5 Due by End of session Scenario Circle one type Explanation & example 1 point 2 & 2 points The number of courses you are taking this semester How much you are enjoying CSE131 Whether you plan to continue your studies in computer science The title of your first novel, assuming you write one double int boolean String double int boolean String double int boolean String double int boolean String (b) (5 points) Recall that in the Nutrition lab, you were asked to ensure that the results you printed had only two digits after the decimal point. For this problem, suppose d is a double with an unknown number of digits after its decimal point. For each of the following, provide a description or single line of code to explain how to achieve the result: i. (1 points) Assign double r1 so that it is like d, but with the decimal moved two digits to the right. ii. (1 points) Assign double r2 so that it is like d, but with the decimal moved two digits to the left. iii. (1 points) Assign int k so that it is like d, but with no digits after the decimal point. iv. (2 points) Below assign String s so that it has the value of d but with just two digits of precision after the decimal point.

CSE 131 (Exam I) 6 Due by End of session 4. (25 points) An array poll has been created that contains polling data for an election. You may assume for all of this problem that the array contains only positive 2 numbers. An example of such an array follows: poll array [0] [1] [2] [3] [4] [5] [6] [7] contents 3 1 3 7 6 1 3 2 In this particular example, we can tell the following from the above array: poll[0] = 3, meaning that the first person who responded to this poll chose candidate 3. 8 people were polled, because the array has 8 elements. 7 candidates were running, because the largest value found in the array is 7. Candidate 2 received 1 vote. Candidates 4 and 5 received 0 votes. Candidate 3 received 3 votes. The above is only an example of a poll array. Suppose you are given another poll array containing only positive integers. Answer the questions below by filling in the required code. (a) (5 points) Complete the code below so that it sets N to the size of the poll array: int N = // How many people were polled? (b) (10 points) Complete the code below so that the printed line says how many candidates are running for this poll: int M = 0; // initialize M, but its value will change below // Complete the loop so that when the loop is over, // M is set to the number of candidates that are running // for this poll for (int i=0; i < N; ++i) { // N is computed above } System.out.println("There are " + M + " people running"); Continued on next page... 2 An integer is positive if it is strictly greater than 0.

CSE 131 (Exam I) 7 Due by End of session (c) (10 points) With N and M already computed above for some poll array with positive entries, you next determine how many votes each candidate received. As an example, your output would resemble the following if you were given the poll array shown at the beginning of this question. Candidate 1 received 2 votes Candidate 2 received 1 vote Candidate 3 received 3 votes Candidate 4 received 0 votes Candidate 5 received 0 votes Candidate 6 received 1 vote Candidate 7 received 1 vote Complete the code below so that it prints the number of votes each candidate has received in the poll. for (int c=0; c < M; ++c) { // for each candidate c } // // your code above here computes and prints the number of // vote candidate c has in the poll array //

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