COS 126 Written Exam 2 Spring 18

Similar documents
COS 126 Written Exam 2 (Spring 2015)

COS 126 Midterm 1 Written Exam Spring 2015

COS 126 General Computer Science Spring Written Exam 1

COS 126 General Computer Science Fall Exam 1

COS 126 General Computer Science Fall Exam 1

11/22/1999 7pm - 9pm. Name: Login Name: Preceptor Name: Precept Number:

COS 126 General Computer Science Fall Midterm 1

Instructions. This exam has 7 questions, worth 10 points each. You have 50 minutes.

COS 126 General Computer Science Spring Written Exam 2

CIS 110 Introduction to Computer Programming. 17 December 2012 Final Exam

11. A Computing Machine

COS 126 Written Exam 2, Fall 2009

What is TOY? An imaginary machine similar to: ! Ancient computers. ! Today's microprocessors.

COS 126 General Computer Science Spring Written Exam 1

Computer Architecture /

CS.17.A.MachineI.Overview

COS 126 MIDTERM 1, FALL

Computer Science /21/2000

CIS 110 Introduction to Computer Programming. 7 May 2012 Final Exam

6.1 Combinational Circuits. George Boole ( ) Claude Shannon ( )

COS 226 Midterm Exam, Spring 2011

COS 226 Algorithms and Data Structures Fall Midterm

Lecture A2: X-TOY Programming

! Ancient computers. ! Today's microprocessors. Memory. ! Stores data and programs. ! 256 "words." (16 bits each) ! Special word for stdin / stdout.

COS 226 Algorithms and Data Structures Spring Midterm Exam

COS 126 General Computer Science Spring Exam 2

COS 126 General Computer Science Fall Written Exam 1

COS 126 Midterm 1 Written Exam, Fall 2009

COS 226 Midterm Exam, Spring 2009

18. Machine Language. Computer Systems. COMP1917: Computing 1. Machine Language Programming. History of Computer Technology

CS1800 Discrete Structures Final Version A

Name: University of Michigan uniqname: (NOT your student ID number!)

ECE 30 Introduction to Computer Engineering

Virtual machines. Virtual machines. Abstractions for computers. Abstractions for computers. Virtual machines

CIS 110 Spring 2014 Introduction to Computer Programming 12 May 2014 Final Exam Answer Key

COS 126 General Computer Science Fall Programming Exam 2

12/11/ The TOY Machine II. Data Representation. What We've Learned About TOY. What We Do Today. Adding and Subtracting Binary Numbers

COSC 6385 Computer Architecture. Instruction Set Architectures

5. The TOY Machine II

Engineering 100 Midterm Exam Technical Part Fall 2010

CS 2504 Intro Computer Organization Test 1

The Processor (1) Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CSE 30 Fall 2013 Final Exam

I-Format Instructions (3/4) Define fields of the following number of bits each: = 32 bits

CS61c MIDTERM EXAM: 3/17/99

CSE 30 Winter 2014 Final Exam

COS 226 Algorithms and Data Structures Spring Second Written Exam

TOY II LINC LINC. !1 Introduction to Computer Science Sedgewick and Wayne Copyright 2007

Review. Steps to writing (stateless) circuits: Create a logic function (one per output)

ECE331: Hardware Organization and Design

1. [5 points each] True or False. If the question is currently open, write O or Open.

COS 126 General Computer Science Fall Exam 1

COS 126 Exam 2 Review Part 1

COS 226 Algorithms and Data Structures Spring Midterm

(the bubble footer is automatically inserted in this space)

CS1800 Discrete Structures Spring 2017 Profs. Gold & Schnyder April 28, CS1800 Discrete Structures Final

RECITATION SECTION: YOUR CDA 3101 NUMBER:

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

CSE 247 Data Structures and Algorithms Fall Exam I

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final

Operations On Data CHAPTER 4. (Solutions to Odd-Numbered Problems) Review Questions

CS402 Theory of Automata Solved Subjective From Midterm Papers. MIDTERM SPRING 2012 CS402 Theory of Automata

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

CS61C : Machine Structures

Birkbeck (University of London) Department of Computer Science and Information Systems. Introduction to Computer Systems (BUCI008H4)

Real Digital Problem Set #6

Chapter 4. The Processor

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture

Organisation. Assessment

Read this before starting!

Automata Theory TEST 1 Answers Max points: 156 Grade basis: 150 Median grade: 81%

Theory of Computations Spring 2016 Practice Final Exam Solutions

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

CS1800 Discrete Structures Summer 2017 Prof. Schnyder May 26, CS1800 Discrete Structures Midterm Practice Exam

C++ to assembly to machine code

! Binary and hex. ! Box with switches and lights. ! 4,328 bits = (255 " 16) + (15 " 16) + (8) = 541 bytes! ! von Neumann architecture.

Review. Lecture #9 MIPS Logical & Shift Ops, and Instruction Representation I Logical Operators (1/3) Bitwise Operations

Instructions: Language of the Computer

CSE 30 Fall 2012 Final Exam

CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Formats

Unsigned Binary Integers

Master Theorem, Introduction to Graphs

Unsigned Binary Integers

Midterm Exam 2B Answer key

Introduction to Computer Science Midterm 3 Fall, Points

The Assembly Language of the Boz 5

CSCI 2121 Computer Organization and Assembly Language PRACTICE QUESTION BANK

Advanced Computer Architecture-CS501. Vincent P. Heuring&Harry F. Jordan Chapter 2 Computer Systems Design and Architecture

Final Exam May 8, 2018

CS 112 Midterm Exam Fall 2016

COS 226 Algorithms and Data Structures Spring Midterm

COS 226 Algorithms and Data Structures Fall Midterm

CS 61c: Great Ideas in Computer Architecture

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final

Read this before starting!

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

UC Berkeley CS61C : Machine Structures

Compiler Construction

Transcription:

COS 126 Written Exam 2 Spring 18 Instructions. This exam has 7 questions, worth 10 points each. You have 50 minutes. 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. After this exam. Due to travel for extracurriculars and sports, some of your peers will take this exam next week. Do not discuss its contents with anyone who has not taken it yet. This paper. Do not remove this copy of the exam from the exam room. You may fill in this page now. NAME: NETID: PRECEPT: EXAM ROOM: I pledge my honor that I will not violate the Honor Code during this examination. SIGNATURE:

Question 1 Number Systems 10 points Fill in the blanks in the table below by converting the given values between number systems. decimal 8-bit two's complement hexadecimal 126 0111 1110 7E -126 1111 1111 1A F8-2

Question 2 Regular Expressions 10 points Let L = { bbaaa, abbaa, bbbaa, abaaa }. The alphabet for L is {a, b}. For each of the following regular expressions, choose one of the following: NONE -- Matches no strings in L. SOME -- Matches some, but not all, strings in L. EXACT -- Matches all strings in L and no other strings. MORE -- Matches all strings in L and some other strings. NONE SOME EXACT MORE 1.... 2..(ab)* 3. (a* b*)(aa)* 4. ab*a*b*a*a*bab* 5. (ab bb)(baa aaa) 6. (a ab bbb)(bba abb a) 7. (a b)(ba bb)(a b)a 8. (bbb bba abb aba).. 9. (b* ((ab) (ba)))* 10. ((a b)* (aba*..a))*

Question 3 TOY 10 points Fill in the blanks in the following TOY program that reads two inputs from StdIn, multiplies them using repeated addition, and prints the result to StdOut. 10: 8 A F F 11: 8 B F F 12: 7 C 0 0 13: 7 1 0 1 14: C A 15: 1 C 16: 2 A 17: 18: 9 C F F 19: 0 0 0 0 reads from StdIn to R[A] reads from StdIn to R[B] R[C] < 0000 R[1] < 0001 HINT: if R[A] == 0, we have our answer! HINT: add something to R[C] HINT: subtract something from R[A] HINT: we're not done yet! prints R[C] to StdOut halt

Question 4 Theory 10 points For each cell in the table below, select the response that best represents our current understanding. Assume that, as we suspect, the Church-Turing thesis holds. solvable in polynomial time reduces to SAT in polynomial time SAT reduces to it in polynomial time SORT FACTOR PRIME TSP SAT HALTING PROBLEM OUTSIDE THE SCOPE OF THIS COURSE OUTSIDE THE SCOPE OF THIS COURSE

Question 5 Linked Lists 10 points Choose the correct sequence of Java instructions to insert a node into a circularly linked list. You have access to two node variables, first and n, as diagrammed below. n.next is initialized to null. Your answers must produce a circularly linked list. Treat each of the four parts below as independent. Choose one letter per box below, in the correct order, to perform the following operations. You may use each letter once, more than once, or not at all. A. first = n; B. first.next = n; C. first.next.next = n; D. first.next.next.next = n; E. first.next.next.next.next = n; F. n.next = first; G. n.next = first.next; H. n.next = first.next.next; I. n.next = first.next.next.next; J. n.next = first.next.next.next.next; 1. Insert n between the first node and the second node. 2. Insert n after the last node. 3. Insert n between the second node and the third node. 4. Insert n before the first node.

Question 6 Runtime Analysis 10 points Choose the order of growth of each of the following operations. 1 logn N NlogN N 2 N 3 1. Best-case scenario for insertion sort. 2. Best-case scenario for mergesort. 3. Worst-case scenario for insertion sort. 4. Worst-case scenario for mergesort. 5. A program whose running time doubles (exactly) when the input size doubles. 6. A program that performs an operation on all possible pairings of N elements. 7. Finding the largest element in a linked list. 8. Finding the median element in a sorted array. 9. Finding the average of all the elements in a binary search tree. 10. Finding the largest element in a balanced binary search tree.

Question 7 Circuits 10 points For each circuit below, complete the corresponding truth table and choose the best descriptor. x 0 1 out not maj xor odd and even none of the above x y out 0 0 0 1 1 0 not maj xor odd and even none of the above 1 1 x y z out 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 not maj xor odd and even none of the above 1 0 1 1 1 0 1 1 1

TOY REFERENCE CARD INSTRUCTION FORMATS................ Format RR: opcode d s t (0 6, A B) Format A: opcode d addr (7 9, C F) ARITHMETIC and LOGICAL operations 1: add R[d] < R[s] + R[t] 2: subtract R[d] < R[s] R[t] 3: and R[d] < R[s] & R[t] 4: xor R[d] < R[s] ^ R[t] 5: shift left R[d] < R[s] << R[t] 6: shift right R[d] < R[s] >> R[t] TRANSFER between registers and memory 7: load address R[d] < addr 8: load R[d] < M[addr] 9: store M[addr] < R[d] A: load indirect R[d] < M[R[t]] B: store indirect M[R[t]] < R[d] CONTROL 0: halt halt C: branch zero if (R[d] == 0) PC < addr D: branch positive if (R[d] > 0) PC < addr E: jump register PC < R[d] F: jump and link R[d] < PC; PC < addr Register 0 always reads 0. Loads from M[FF] come from stdin. Stores to M[FF] go to stdout. 16 bit registers (two's complement) 16 bit memory locations 8 bit program counter

You may tear this page out and use it as scratch paper. If you do, fill in the blanks below and return it inside your exam. NAME: NETID: PRECEPT: EXAM ROOM: