mid1-f18-written-sol-master

Tài liệu tương tự
COS 126 Written Exam 1 Fall 2018 There are seven questions on this exam, each worth ten points. There is one question per lecture, numbered correspond

Screen Test (Placement)

UBND TỈNH ĐỒNG THÁP SỞ GIÁO DỤC VÀ ĐÀO TẠO Số: 1284/SGDĐT-GDTrH-TX&CN V/v hướng dẫn tổ chức dạy học bộ môn tiếng Anh cấp trung học năm học C

MD Paper-Based Test ELA Vietnamese Script for Administrating PARCC TAM

Hệ điều hành Bài tập tuần 6 1 Quản lý bộ nhớ Bài tập 1 : Xem thông tin bộ nhớ 1. Sử dụng top, ps đọc thông tin về kích thước vùng nhớ của 1 tiến trình

说明书 86x191mm

2018 Vietnamese FL Written examination

Lập trình và ngôn ngữ lập trình

! LỊCH HỌC CỦA TRẺ 3-4 TUỔI/ DAILY SCHEDULE FOR PRESCHOOL 1 September Tuần 1 / Week 1 Bài học: Trường em Ngày: 5/9 9/9 Unit: My school Date: Sep 5-9 T

NMPED 2019 Spring ADMINISTRATOR Manual

FAQs Những câu hỏi thường gặp 1. What is the Spend Based Rewards program for Visa Vietnam? The Spend Based Rewards program for Visa Vietnam is a servi

BIỂU ĐẠT HÌNH THÁI DĨ THÀNH TIẾNG ANH TRONG TIẾNG VIỆT 1. Mục đích và phương pháp 1.1. Mục đích 19 ThS. Trương Thị Anh Đào Dựa trên nền tảng lý thuyết

Microsoft Word - Persevere-2 Stories.docx

Tóm tắt ngữ pháp tiếng Anh Tổng hợp và biên soạn: Thầy Tâm - Anh Văn ( TÓM TẮT NGỮ PHÁP TIẾNG ANH Mục lục Tóm tắt

Lesson 4: Over the phone (continued) Bài 4: Nói chuyện qua điện thoại (tiếp theo) Trần Hạnh và toàn Ban Tiếng Việt, Đài Úc Châu, xin thân chào quí bạn

Microsoft Word - Listen to Your Elders-2 Stories.docx

Copyright vietjack.com Chuỗi (String) trong C# Trong C#, bạn có thể sử dụng các chuỗi (string) như là mảng các ký

Microsoft Word - Huong dan dang ky Techsoup_v1

Microsoft Word - co_ban_ve_jquery.docx

29T-STAT.pmd

H_中英-01.indd

Microsoft Word - bai 16 pdf

Microsoft Word - menh-de-quan-he-trong-tieng-anh.docx

9-KiemThu

Các cấu trúc logic trong lập trình 1 Cấu trúc tuần tự (Sequence) 1.1 Những câu lệnh phải được sắp xếp theo thứ tự Một số hướng dẫn cho việc tổ chức câ

NGÔN NGƯ LÂ P TRIǸH Biên tập bởi: nguyenvanlinh

Hướng dẫn cụ thể từng bước để đăng ký sử dụng Đơn đăng ký không tín chỉ sau đó ghi danh vào các lớp không tín chỉ. 1 tháng Sáu, 2018 Các sinh viên dự

Hướng dẫn làm bài thi xếp lớp tiếng Anh GIỚI THIỆU VỀ BÀI THI XẾP LỚP Bài thi kiểm tra xếp lớp tiếng Anh của Cambridge English là dạng bài thi trực tu

Microsoft Word - status_code_trong_servlet.docx

Nhúng mã-cách khai báo biến Nhúng mã-cách khai báo biến Bởi: Khoa CNTT ĐHSP KT Hưng Yên Nhúng mã javascript trong trang HTML Bạn có thể nhúng JavaScri

copy Vietnamese by Khoa Dang Nguyen

Winmeen Tnpsc Gr 1 & 2 Self Preparation Course

Kiến trúc tập lệnh1

Copyright vietjack.com Nạp chồng toán tử trong C# Operator Overloading là Nạp chồng toán tử. Bạn có thể tái định

Java cơ bản

HOÀNG VĂN VÂN (Tổng chủ biên) NGUYỄN THỊ CHI (Chủ biên) LÊ KIM DUNG PHAN CHÍ NGHĨA VŨ MAI TRANG LƯƠNG QUỲNH TRANG - NGUYỄN QUỐC TUẤN TẬP HAI

Những cơ sở của ngôn ngữ C# Những cơ sở của ngôn ngữ C# Bởi: phamvanviet truonglapvy Trong chương này sẽ trình bày về hệ thống kiểu trong C#; phân biệ

Web: truonghocmo.edu.vn Thầy Tuấn: BÀI TẬP LUYỆN TẬP LƯỢNG TỪ Khóa học Chinh phục kỳ thi THPT QG - Cấu tạo câu Th

H_中英-01.indd

Chapter 1

Các biến và các kiểu dữ liệu trong JavaScript Các biến và các kiểu dữ liệu trong JavaScript Bởi: Hà Nội Aptech Các biến (Variables) Biến là một tham c

Kế thừa và đa hình

Website review luanvancaohoc.com

Stored Procedures Stored Procedures Bởi: Khoa CNTT ĐHSP KT Hưng Yên Trong những bài học trước đây khi dùng Query Analyzer chúng ta có thể đặt tên và s

tcvn tiªu chuèn quèc gia national STANDARD tcvn : 2009 ISO : 1994 XuÊt b n lçn 1 First edition CẦN TRỤC TỪ VỰNG PHẦN 2: CẦN TRỤC TỰ HÀNH

Exam 1 Information 332: 345 Fall 2003 Exam 1 results are posted on WebCT. The average is 17.5/35. Exam 1 solutions are on reserve reading in SERC Libr

Microsoft Word - 16_LTXC_LocThanh.doc

TiengAnhB1.Com CẨM NANG LUYỆN THI CHỨNG CHỈ TIẾNG ANH B1 1 P a g e

Manicurist SPF-ICOC-VIET

Photographing, Filming and Recording students at Abbotsford Primary School Annual Consent Form and Collection Notice During the school year there are

Microsoft Word - bia.doc

Sonata IV Sei Sonate per il Cembalo Solo Johan Agrell Published by Johan Tufvesson for Project Runeberg. Non-commercial copying welcome Revi

Microsoft Word - Business Visitor Checklist - Feb 2013.doc

§”π”

Blood pool and Hemangioma - Khoang chứa máu và U máu gan Hoàng Văn Trung Normally when we look at lesions filling with contrast, the density of these

Về khả năng của sẽ trong vai trò đánh dấu thời tương lai tiếng Việt Về khả năng của sẽ trong vai trò đánh dấu thời tương lai tiếng Việt Bởi: Trần Kim

Microsoft Word - session_tracking_trong_servlet.docx

Kế thừa

Xử lý ngoại lệ

NGÔN NGỮ THỐNG KÊ R

Boston-new

Using a Walker - Vietnamese

To Chinese

MAS001 SCHOOL OF MATHEMATICS AND STATISTICS Foundation Year Mathematics I Autumn Semester hour 30 minutes ØØ ÑÔØ ÐÐ ÕÙ Ø ÓÒ º Ì ÐÐÓ Ø ÓÒ Ó Ñ

Lập trình cấu trúc trong Visual Basic Lập trình cấu trúc trong Visual Basic Bởi: Nguyễn Sơn Học xong chương này, sinh viên phải nắm bắt được các vấn đ

2017 Vietnamese Background Speakers Examination Paper BK1.indd

uid32355

HỌC VIỆN NGHIÊN CỨU VÀ ĐÀO TẠO ĐÁNH VẦN TIẾNG ANH Page 1 PHƯƠNG PHÁP TĂNG CƯỜNG PHẢN XẠ VÀ TƯ DUY TIẾNG ANH ĐỂ NÓI BẤT KỲ ĐIỀU GÌ BẠN MUỐN Tài liệu nà

Trường ĐHBK Hà Nội Khoa Điện Bộ môn Điều khiển Tự động Tài liệu hướng dẫn thực hành: KĨ THUẬT LẬP TRÌNH C/C++ Bài 1: Lập trình cơ sở 1 Mục đích bài th

PowerPoint Presentation

Lesson 10: Talking business (continued) Bài 10: Bàn chuyện kinh doanh (tiếp tục) Trần Hạnh và toàn Ban Tiếng Việt Đài Úc Châu xin thân chào bạn. Mời b

Mass Appeal

Tập huấn Kinh doanh lưu trú DU LỊCH tại nhà dân Bài 4: Phục vụ khách lưu trú esrt programme

Animation, Modules 6 - Hoạt hình, tách file

Bản ghi:

COS 126 Written Exam 1 all 2018 There are seven questions on this exam, each worth ten points. There is one question per lecture, numbered corresponding to the lectures, not in order of difficulty. If a question seems difficult to you, skip it and come back to it. You will have 50 minutes to complete the exam. This exam is preprocessed by computer. If you use pencil (and eraser), write darkly. Resources. You may reference your optional two-sided 8.5-by-11 handwritten "cheat sheet" during this exam. You may not use the textbook, your notes, or any electronic devices. You may not communicate with anyone except the course staff during this exam. Discussing this exam. Due to travel for extracurriculars and sports, some of your peers will take this exam later. Do not discuss its contents with anyone who has not taken it. This page. Do not remove this exam from the exam room. ill in this page now, but do not start the exam until you are told. Name NetID Precept Exam Room I pledge my honor that I have not violated the onor Code during this examination. [copy the pledge here] [signature]

Q1a. Types and Casts.=mìí=íÜÉ=äÉííÉê=íç=äÉÑí=çÑ=É~ÅÜ=äáåÉ=íÜ~í=ÖáîÉë=íÜÉ=î~äìÉ=éêáåíÉÇ=Eçê=êÉéêÉëÉåíë= íüé=áåçáå~íéç=éêêçêk=^=äéííéê=ã~ó=äé=ìëéç=ãçêé=íü~å=çååé=e~åç=ëçãé=åçí=~í=~ääk= G D StdOut.println( 4" * 4); StdOut.println(1 + 63.0); A 1234 64 C 4444 StdOut.println((int) 32.0 + 32); D 64.0 E 334 D StdOut.println(1 + 2 + 3 + "4"); StdOut.println(64 + "." + 0); 163.0 G compile-time error run-time error Q1b. Terminology.=mìí=íÜÉ=äÉííÉê=íç=äÉÑí=çÑ=É~ÅÜ=ÇÉÑáåáíáçå=íÜ~í=áÇÉåíáÑáÉë=íÜÉ=íÉêã=ÇÉÑáåÉÇK=kç= äéííéê=ã~ó=äé=ìëéç=ãçêé=íü~å=çååék= D ^=ëéí=çñ=î~äìéë=~åç=~=ëéí=çñ=çééê~íáçåë=çå=íüçëé=î~äìéëk A literal declaration A ^=éêçöê~ããáåöjä~åöì~öé=êééêéëéåí~íáçå=çñ=~=î~äìék C D î~êá~ääé data type ^=éêçöê~ããáåöjä~åöì~öé=êééêéëéåí~íáçå=çñ=~=íóéék E ~ëëáöåãéåí algorithm ^=ëí~íéãéåí=íü~í=~ëëçåá~íéë=~=î~êá~ääé=ïáíü=~=íóéé G identifier E ^=ëí~íéãéåí=íü~í=~ëëçåá~íéë=~=î~äìé=ïáíü=~=î~êá~ääé none of the above

Q2. Loops and conditionals. Consider the following Java code fragment: int count = 0 for (int i = 0; i < N; i++) if (((i/10) % 2) == 1) count++; StdOut.println(count); A. (1 point). What value is printed when N is 5? 0. (1 point). What value is printed when N is 10? 0 C. (2 points). What value is printed when N is 20? 10 D. (2 points). What value is printed when N is 1000? 500 E. (2 points). What value is printed when N is 1024? 510. (2 points). What value is printed when N is 975? 485

Q3. Arrays. A. (3 points) In the box below, write one line of Java code that creates a 3-by-3-by-3 (threedimensional) array named a of int values and initializes them each to the value 0. int[][][] a = new int[3][3][3]; int[][][] a = { { {0, 0, 0}, {0, 0, 0}, {0, 0, 0} }, { {0, 0, 0}, {0, 0, 0}, {0, 0, 0} }, { {0, 0, 0}, {0, 0, 0}, {0, 0, 0} } };. (7 points) Indicate whether each of the following statements about Java arrays are true or false by writing T or respectively in the box to its left. T Creating a Java array takes time proportional to its length. If a, b, and c are arrays of length N, the statement c = a + b is equivalent to the statement for (i = 0; i < N; i++) c[i] = a[i] + b[i]. X Once a one-dimensional array has been created and initialized, you can refer to the first element in the array with the code a[0]. Java arrays enable programmers to mix different types of data in the same data structure. T It is reasonable for a programmer to expect that the time taken to access an element using its index is independent of the array length. If a and b are arrays of the same length, then the code a = b copies each element of b to the corresponding position in a. The number of items in an array a is a.length -1.

Q4. I/O. Consider the following Java program, which has no purpose other than to test your understanding of standard input and standard output: public class Q4 } public static void main(string[] args) } while (!StdIn.isEmpty()) } int N = StdIn.readInt(); int sum = 0; for (int i = 0; i < N; i++) if (!StdIn.isEmpty()) sum += StdIn.readInt(); StdOut.print(sum + " "); StdOut.println(); Suppose that the file dataq4 contains "1 2 3 4 5 6 7 8 9"K In the box to the left of each command, write the output that it produces. or brevity, we say "java" which you may read as "java-introcs". If the command results in an error or produces no output, write NONE. NONE % java Q4 dataq4 NONE % java Q4 dataq4 2 15 17 % java Q4 < dataq4 32 % java Q4 < dataq4 java Q4 0 % java Q4 < dataq4 java Q4 java Q4

Q5. unctions. Our task is to develop a function for computing the absolute value of each of the elements in a 1-dimensional array of int values. or example, for the array {1, -6, 2, -1} the desired result is {1, 6, 2, 1}. The code below is a solution to this problem, with five snippets of code missing. Your task is to identify the code needed to complete this program. We explore two different design patterns. public static =lkb= abs(int[] x) } int N = x.length; qtl for (int i = 0; i < N; i++) if (x[i] < 0) clro cfsb =qeobb== A. (5 points) Suppose that the design is to modify the argument array to reflect the result. Using the table at right, fill in each box with the letter corresponding to the code that is needed to accomplish this. A return x; return z; C x[i] = -x[i]; D int[] z; E z[i] = -x[i]; int[] z = new int[]; J lkb P clro G new int[n] int[] z = new int[n]; P C qtl qeobb P cfsb * some other answers are also possible I J K else z[i] = x[i]; void int. (5 points) Suppose that the design is to return a new array that reflects the result. Again using the table at right, fill in each box with the letter corresponding to the code that is needed to accomplish this. L M N int[] x[i] = x[i]; new int[] L lkb I clro O else z[i] = -x[i]; qtl cfsb P åç=åççé=ñçê=íüáë=äçñ E qeobb

Q6. Recursion. Consider the following recursive static method: static int f(int n) if (n == 0) return 0; if (n == 1) return 0; if (n == 2) return 1; return f(n-1) + f(n-2) - f(n-3); } A. (1 point). What is the value of f(3)? 1. (1 point). What is the value of f(4)? 2 C. (1 point). What is the value of f(7)? 3 D. (3 points). Including the first one, how many calls on f()=are made to compute f(7)? E. (2 points). What is the value of f(101)? 46 50. (2 points). Write T in the box at right if you could compute the value of f(101) using this code in less than 10 seconds on your computer, otherwise write. f(7) f(6) f(5) f(4) f(5) f(4) f(3) f(4) f(3) f(2) f(3) f(2) f(1) f(2) f(1) f(0) f(0) - 1 call f(1) - 1 call f(2) - 1 call f(3) - 4 calls f(5) - 13 calls f(6) - 25 calls f(7) - 46 calls

Q7. TOY. Consider the following TOY program: 10: 7100 R[1] <- 0000 11: 8 read R[] 12: 915 M[15] <- R[] 13: 82 read R[2] 14: 1112 R[1] = R[1] + R[2] 15: C016 goto 16 16: 91 write R[1] 17: 0000 halt ill in the following table to give the value(s) printed on standard output for each given sequence of values on standard input. If no output, write NONE. 0000 1112 NONE 1112 0000 0000 1112 1112 2224 C011 1112 1112 1112 3336 C011 C011 1112 1112 E235