This exam is worth 24 points, or 24% of your total course grade. The exam contains six

Similar documents
This exam is worth 40 points, or 30% of your total course grade. The exam contains eight

This exam is worth 30 points, or about 28% of your total course grade. The exam contains

This exam is worth 60 points, or 30% of your total course grade. The exam contains eight

CS61c MIDTERM EXAM: 3/17/99

! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive)

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive)

CS 223: Data Structures and Programming Techniques. Exam 2

cs61amt2_4 CS 61A Midterm #2 ver March 2, 1998 Exam version: A Your name login: cs61a- Discussion section number TA's name

University of California, Berkeley College of Engineering

! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive)

Practice problems Set 2

Fall 2010 CS61C Midterm 1 Solutions

CS 61A Midterm #2 ver March 2, 1998 Exam version: A. Your name. login: cs61a- Discussion section number. TA's name

Sample Examination. Family Name:... Other Names:... Signature:... Student Number:...

University of California, Berkeley College of Engineering

Computer Science Foundation Exam

However, in C we can group related variables together into something called a struct.

Question 1 (2 points): In project 1 we told you that you didn'thave to turn o interrupts in your implementation of semaphores, but in project 2 we tol

UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING

University of California, Berkeley College of Engineering

COS 126 General Computer Science Spring Written Exam 1

Wawrzynek & Weaver CS 61C. Sp 2018 Great Ideas in Computer Architecture MT 1. Print your name:,

CS 61C, Fall, 2005, Midterm 1, Garcia Question 1: For those about to test, we salute you (11 pts, 20 min.)

Wawrzynek & Weaver CS 61C. Sp 2018 Great Ideas in Computer Architecture MT 1. Print your name:,

Computer Science Foundation Exam

More on Arrays CS 16: Solving Problems with Computers I Lecture #13

CS16 Midterm Exam 2 E02, 09F, Phill Conrad, UC Santa Barbara Wednesday, 11/18/2009

EECE.2160: ECE Application Programming Fall 2017 Exam 3 December 16, 2017

Computer Architecture I Mid-Term I

University of California, Berkeley College of Engineering

Provided by - Microsoft Placement Paper Technical 2012

Department of Electrical Engineering and Computer Sciences Spring 2013 Instructor: Dr. Dan Garcia CS61C Midterm

! Determine if a number is odd or even. ! Determine if a number/character is in a range. ! Assign a category based on ranges (wind speed)

This is CS50. Harvard University Fall Quiz 0 Answer Key

General Instructions. You can use QtSpim simulator to work on these assignments.

Discussion section number. a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z

Why arrays? To group distinct variables of the same type under a single name.

This exam is worth 30 points, or 18.75% of your total course grade. The exam contains

200 points total. Start early! Update March 27: Problem 2 updated, Problem 8 is now a study problem.

CS 61C, Midterm #2, Spring 1997 CS 61C. Spring 1997 Midterm #2. Professor Brian Harvey

Department of Electrical Engineering and Computer Science Spring 2004 Instructor: Dan Garcia CS61C Midterm

CSE351 Winter 2016, Final Examination March 16, 2016

8*4 + 4 = 36 each int is 4 bytes

CS16 Midterm Exam 2 E02, 10W, Phill Conrad, UC Santa Barbara Tuesday, 03/02/2010

Spring 2017 CS 1110/1111 Exam 1

Name: Login: cs61c- Decimal Ternary 5 12 three three

Review of Important Topics in CS1600. Functions Arrays C-strings

ECE 30 Introduction to Computer Engineering

Midterm Exam #2 April 20, 2016 CS162 Operating Systems

CSCI 135 Exam #0 Fundamentals of Computer Science I Fall 2012

Computer Science Foundation Exam

CPSC 213, Summer 2017, Term 2 Midterm Exam Solution Date: July 27, 2017; Instructor: Anthony Estey

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

CS Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2015

Introduction to Computer Science Midterm 3 Fall, Points

CS 61B Summer 2005 (Porter) Midterm 2 July 21, SOLUTIONS. Do not open until told to begin

CSE 333 Midterm Exam 2/14/14

Computer Science Foundation Exam

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

CSE 333 Midterm Exam 7/25/16. Name UW ID#

Exercise 1.1 Hello world

Final Exam. 11 May 2018, 120 minutes, 26 questions, 100 points

Engineering 100 Midterm Exam Technical Part Fall 2010

ECE/CS 552: Introduction to Computer Architecture ASSIGNMENT #1 Due Date: At the beginning of lecture, September 22 nd, 2010

EECE.2160: ECE Application Programming Fall 2017

Department of Electrical Engineering and Computer Sciences Spring 2007 Instructor: Dr. Dan Garcia

a) Write the signed (two s complement) binary number in decimal: b) Write the unsigned binary number in hexadecimal:

CS 61B, Midterm #3 and solutions, Spring 1996

CS16 Final Exam E03, 10S, Phill Conrad, UC Santa Barbara Wednesday, 06/09/2010

COS 126 General Computer Science Spring Midterm 1

CIS 2107 Computer Systems and Low-Level Programming Fall 2010 Midterm

Prelim 1 Solutions. CS 2110, March 10, 2015, 5:30 PM Total Question True False. Loop Invariants Max Score Grader

CSE 250 Final Exam. Fall 2013 Time: 3 hours. Dec 11, No electronic devices of any kind. You can open your textbook and notes

Algorithm Design and Analysis. What is an Algorithm? Do Algorithms Matter?

Computer Science Foundation Exam

Computer Science Foundation Exam

Computer Architecture I Midterm I

CSE 303 Midterm Exam

CSE 378 Final Exam 3/14/11 Sample Solution

ECE264 Spring 2013 Exam 1, February 14, 2013

UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING

Personal SE. Arrays Pointers Strings

CS61B (Clancy) Spring 1996 Exam 3, solutions, and grading standards. April 12, 1996 Exam 3

#101 Page: 1 Name: CS32 Midterm Exam. E01, W15, Phill Conrad, UC Santa Barbara

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

ECE264 Fall 2013 Exam 1, September 24, 2013

Midterm Exam #2 Solutions April 20, 2016 CS162 Operating Systems

MIPS Functions and the Runtime Stack

3/7/2018. Sometimes, Knowing Which Thing is Enough. ECE 220: Computer Systems & Programming. Often Want to Group Data Together Conceptually

Computer Science Foundation Exam

CS 2150 Final Exam, Spring 2018 Page 1 of 10 UVa userid:

United States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring AY2017

UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING

CS16 Midterm Exam 1 E01, 10S, Phill Conrad, UC Santa Barbara Wednesday, 04/21/2010, 1pm-1:50pm

Programming for Engineers Arrays

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2009

United States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring 2015

CSE 333 Midterm Exam 5/10/13

Assembler. Lecture 8 CS301

CSE 333 Autumn 2013 Midterm

Transcription:

CS 60B Final December 14, 1992 Your name login c60b{ Discussion section number TA's name This exam is worth 24 points, or 24% of your total course grade. The exam contains six questions. This booklet contains eight numbered pages including the cover page. Put all answers on these pages, please don't hand in stray pieces of paper. This is an open book exam. When writing procedures, don't put in error checks. Assume that you will be given arguments of the correct type. Our expectation is that many of you will not complete one or two of these questions. If you nd one question especially dicult, leave it for later start with the ones you nd easier. 1 =3 2 =3 3 =4 4 =4 5 =4 6 =6 1 total =24

Question 1 (3 points): (a) Convert 0xffffff99 to a signed decimal integer. (b) Suppose we want to represent positive integers using a binary coded decimal representation, with each decimal digit represented in four bits, so that 123 would be represented as 0001 0010 0011. With this representation, what is the largest number that ts in a MIPS word? (c) Of the MIPS assember instructions below, circle the ones that can be carried out by a single MIPS hardware instruction: la $8, 0x80000080 move $10, $4 loop: loop: beq $8, $9, loop blt $8, $9, loop la $8, 0x2000 2

Your name login c60b{ Question 2 (3 points): You have been hired to design a 64-bit version of the MIPS architecture. You're deciding between two possibilities for instruction formats: Option A: Double the width of every eld in the existing instruction formats (12 bits for opcode, 10 bits for registers, etc.). Option B: Keep all elds the same as in the 32-bit version except for the immediate/oset eld, which will be 48 bits wide. Give an argument (one or two sentences should be enough) for why each of these choices might make programs run faster. (Don't just say, for example, \it can address more registers" explain why that will make programs faster.) Which argument seems more reasonable to you, and why? (We haven't chosen a right answer to this it's your reason we want to see.) 3

Question 3 (4 points): Translate the following fragmentofccodeinto MIPS assembler: int baz(int i, int a[7], char b[10]) { a[i] = b[i] return a[0] 4

Your name login c60b{ Question 4 (4 points): Write a C function satisfying this declaration: char *doubles(char *str) that returns a string containing all characters that appear twice (or more) in a row in the argument string. For example, printf("%s\n", doubles("mississippi")) should print \ssp". The result should be returned in a newly allocated string that's no bigger than necessary. You may assume that the argument string has fewer than 100 characters. 5

Question 5 (4 points): You are working with lists of integers constructed out of nodes like this: struct node { int value struct node *next Write the C procedure swap that takes a pointer to a list as its argument. It should return a list with the same elements, but reversing the order of each pair of elements. For example, if the list that you get as the argumentcontains the elements (22 18 9 5 47 100 6) then the returned list should contain (18 22 5 9 100 47 6). (Note that if the list has an odd number of elements you leave the last one alone.) Do the reordering without allocating any new nodes rearrange the pointers in the next elds. There is not adummynodeat the head of the list the rst node contains the rst actual element. 6

Your name login c60b{ Question 6 (6 points): Find, explain, and x the bugs in the following programs. Each program has exactly one bug. (You may need to change more than one line to x the bug, however.) (a) In the graph programming project, you want to mark all the vertices as unvisited, so you say for (i = 1 i <= max vertex i++) unvisit(vertices[i]) Here is the procedure unvisit: void unvisit(struct vertex v) { v.visited = 0 (b) This procedure takes a positive integer and a list as arguments. It adds the integer to the end of the list. Assume that the list is not empty initially. struct node { int value struct node *next void append(int n, struct node *list) { struct node newnode while (list->next!= NIL) list = list->next newnode.value = n newnode.next = NIL list->next = &newnode Question 7 continues on the next page. 7

Question 7 continued. (c) This procedure reads a line from the keyboard, converts all letters to lower case, and puts the result into a preallocated buer whose address is given as argument. void user input(char *buffer) { char response[100] char *cp fgets(response, 100, stdin) for (cp = response *cp cp++) { *buffer++ = tolower(*cp) 8