Birkbeck (University of London) MSc Examination. Department of Computer Science and Information Systems. Fundamentals of Computing (COIY058H7)

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

CE161-4-AU UNIVERSITY OF ESSEX. Undergraduate Examinations 2014 DIGITAL SYSTEMS ARCHITECTURE. Time allowed: TWO hours

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

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

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

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

15110 PRINCIPLES OF COMPUTING SAMPLE EXAM 2

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Friday 20th May 2016 Time: 14:00-16:00

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

Computer science Higher level Paper 1

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

Theory Bridge Exam Example Questions Version of June 6, 2008

Last lecture CMSC330. This lecture. Finite Automata: States. Finite Automata. Implementing Regular Expressions. Languages. Regular expressions

Abstract Data Structures IB Computer Science. Content developed by Dartford Grammar School Computer Science Department

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

1. (10 points) Draw the state diagram of the DFA that recognizes the language over Σ = {0, 1}

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1

8. Write an example for expression tree. [A/M 10] (A+B)*((C-D)/(E^F))

CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

Birkbeck (University of London)

Computer Science /21/2000

UNCA CSCI 255 Exam 1 Spring February, This is a closed book and closed notes exam. It is to be turned in by 1:45 PM.

CS1800 Discrete Structures Final Version A

Total No. of Questions : 18] [Total No. of Pages : 02. M.Sc. DEGREE EXAMINATION, DEC First Year COMPUTER SCIENCE.

I have read and understand all of the instructions below, and I will obey the Academic Honor Code.

(a) What is the denary equivalent of the hexadecimal number A7?

WARNING for Autumn 2004:

Department of Electrical and Computer Engineering University of Wisconsin Madison. Fall Midterm Examination CLOSED BOOK

Birkbeck (University of London)

6-TREE. Tree: Directed Tree: A directed tree is an acyclic digraph which has one node called the root node

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

Draw a diagram of an empty circular queue and describe it to the reader.

Birkbeck (University of London)

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

SISTEMI EMBEDDED. Basic Concepts about Computers. Federico Baronti Last version:

R10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA?

COMS 1003 Fall Introduction to Computer Programming in C. Bits, Boolean Logic & Discrete Math. September 13 th

ALGORITHMS EXAMINATION Department of Computer Science New York University December 17, 2007

The LC3's micro-coded controller ("useq") is nothing more than a finite-state machine (FSM). It has these inputs:

CS 44 Exam #2 February 14, 2001

Data Structures. Algorithms

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

Chapter 5 Hashing. Introduction. Hashing. Hashing Functions. hashing performs basic operations, such as insertion,


CDS130 Mid-term exam: Sample

Operations on Heap Tree The major operations required to be performed on a heap tree are Insertion, Deletion, and Merging.

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. M.Sc. in Computational Science & Engineering

COMPUTER SCIENCE Paper 1

Non-deterministic Finite Automata (NFA)

Java Software Solutions for AP Computer Science 3rd Edition, Lewis et al. 2011

Grammar Rules in Prolog!!

Midterm I - Solution CS164, Spring 2014

Read this before starting!

Problem Set 6 Due: 11:59 Sunday, April 29

Course Project 2 Regular Expressions

Algorithms and Data Structures

UNIVERSITY OF MALTA THE MATRICULATION EXAMINATION ADVANCED LEVEL. COMPUTING May 2016 EXAMINERS REPORT

4.1 COMPUTATIONAL THINKING AND PROBLEM-SOLVING

Lexical Analysis (ASU Ch 3, Fig 3.1)

Exam Principles of Imperative Computation, Summer 2011 William Lovas. June 24, 2011

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

CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

Introduction. hashing performs basic operations, such as insertion, better than other ADTs we ve seen so far

Formal Languages and Compilers Lecture VI: Lexical Analysis

We can create PDAs with multiple stacks. At each step we look at the current state, the current input symbol, and the top of each stack.

We have the pointers reference the next node in an inorder traversal; called threads

Grammar Rules in Prolog

AAL 217: DATA STRUCTURES

CSE-1520R Test #1. The exam is closed book, closed notes, and no aids such as calculators, cellphones, etc.

Automating Construction of Lexers

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE

for (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; }

CSE-1520R Test #1. The exam is closed book, closed notes, and no aids such as calculators, cellphones, etc.

WYSE Academic Challenge 2002 Computer Science Test (Sectional) SOLUTION

COMP3 (JUN13COMP301) General Certificate of Education Advanced Level Examination June 2013

A Secondary storage Algorithms and Data Structures Supplementary Questions and Exercises

Recursive definition of sets and structural induction

Irish Collegiate Programming Competition Problem Set

Slides for Faculty Oxford University Press All rights reserved.

QUESTION BANK. Formal Languages and Automata Theory(10CS56)

Lecture 9 March 4, 2010

CS402 - Theory of Automata Glossary By

Binary Trees. Height 1

9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS

Midterm Exam 2B Answer key

M.Sc. (Computer Science) I Year Assignments for May Paper I DATA STRUCTURES Assignment I

COMP171. Hashing.

Final Exam Solution Sunday, December 15, 10:05-12:05 PM

Unit 4 Processing and Programming Techniques

Binary Search Trees. What is a Binary Search Tree?

Recursively Enumerable Languages, Turing Machines, and Decidability

GOZO COLLEGE. Boys Secondary Victoria - Gozo, Malta Ninu Cremona. Half Yearly Examination

Problem with Scanning an Infix Expression

LOGIC SYNTHESIS AND VERIFICATION ALGORITHMS. Gary D. Hachtel University of Colorado. Fabio Somenzi University of Colorado.

Finite Automata. Dr. Nadeem Akhtar. Assistant Professor Department of Computer Science & IT The Islamia University of Bahawalpur

Exam Principles of Imperative Computation, Summer 2011 William Lovas. June 24, 2011

«Computer Science» Requirements for applicants by Innopolis University

Department of Computer Science Admission Test for PhD Program. Part I Time : 30 min Max Marks: 15

Transcription:

Birkbeck (University of London) MSc Examination Department of Computer Science and Information Systems Fundamentals of Computing (COIY058H7) CREDIT VALUE: 15 credits Date of Examination: Monday, 22 May 2017 Time of Examination: 14:30 17:30 Duration of Paper: Three hours This paper is split into two sections. There are 50 marks for each section. There are 5 questions in Section A and 5 questions in Section B. Use a separate answer book for each section. Answer all questions. Start each answer on a new page. The use of electronic calculators is not permitted. The breakdown of marks per question is as follows: Question 1 2 3 4 5 6 7 8 9 10 Marks 10 9 10 11 10 11 10 10 10 9 COIY058H7 Page 1 of 5 c Birkbeck College 2017

Section A 1. (a) Construct the truth-table for the Boolean function given by the formula ( (A B) (C A) ). (b) Find a Boolean circuit with AND, OR and NOT gates only that computes the Boolean function in (a) above and contains as few gates as possible. (4 marks) (c) Determine whether the formula in (a) is equivalent to the formula Show your working. (B A) (C A). 2. (a) Represent 101 10 as a 32-bit two s complement binary number. Show your working. (b) Represent 17.125 10 as an IEEE 754 32-bit floating-point number. Show your working. (c) Find the decimal number represented by the 32-bit word 1100 0001 0101 0000 0000 0000 0000 0000 assuming it is a single precision IEEE 754 floating-point number. 3. (a) What is the language recognised by the following deterministic finite automaton? 0 > s 1 0 p 1 0 q 1 Describe the language in English. Describe the language by means of a regular expression. (b) Design a deterministic finite automaton A such that L(A) consists of all strings over the alphabet {0, 1} in which every occurrence of 0 is immediately followed by a 1. Give a regular expression for L(A). 4. (a) Give a context-free grammar for the language over the alphabet {0, 1} containing all words of even length all words of odd length (b) What is the language defined by the following context-free grammar? S S 1, S S 2, S 1 0S 1, S 1 0A, S 2 S 2 1, S 2 A1, A ε, A 0A1. (5 marks) 5. (a) Give an implementation level description in English of a Turing machine computing the function f : N N given by f(n) = 8 n + 2. (b) Give a transition table of your Turing machine and the computation of this machine for n = 0. (7 marks) COIY058H7 Page 2 of 5 c Birkbeck College 2017

Section B 6. In addition to the usual stack operations, concatenable stacks also support the operation of concatenating two stacks. So, if S1 and S2 are concatenable stacks, we have the usual operations: Stack(S1, y), U nstack(s1), Stack(S2, y), U nstack(s2), and also Concat(S1, S2) and Concat(S2, S1). The effect of Concat(S1, S2) is to put the elements of S2 at the bottom of S1 and make S2 empty. For example, if S1 and S2 are initially empty, then after the sequence of operations: Stack(S1, 1), Stack(S1, 2), Stack(S1, 3), Stack(S2, 4), Stack(S2, 5), Stack(S2, 6), Concat(S1, S2), the contents of S1 will be [3, 2, 1, 6, 5, 4], where the top element is 3, and S2 will be empty. (a) Suggest a suitable representation for a concatenable stack. (b) Give algorithms for the operations Stack(S1, y), Unstack(S1) and Concat(S1, S2) for the representation you have suggested. (9 marks) 7. (a) Draw the binary search tree B obtained by inserting the following strings into an empty tree in the order: f ly, sow, ape, dog, hen, cod, cow, ant, pig, ram, bat, owl. Add in the threads to turn B into a threaded binary tree with a head node. (b) What are the pre-order, in-order and post-order predecessors and successors in B of ape and cow? (c) Draw the forest F corresponding to B using the natural correspondence between forests and binary trees. (d) What implications does the fact that B is a binary search tree have for the relationship between the string values at the nodes of F? COIY058H7 Page 3 of 5 c Birkbeck College 2017

8. (a) A programmer tries to modify the standard non-recursive algorithm for pre-order traversal of a binary tree using a stack so that the traversal is in in-order. He produces the following algorithm: PointerStack S //S is initially empty while (true) //initially P points to the root if (P nil) { Stack(S,P) P P Llink Visit(P) } else { if Empty(S) return P Unstack(S) P P Rlink } Show that this does not work as intended by tracing the execution of the algorithm on the (unthreaded) binary tree B that you constructed in Question 7 (a), and write down the order in which the nodes are visited. What modification should the programmer have made so that the nodes are visited in in-order? (5 marks) (b) In a threaded binary tree, node B is the in-order successor of node A, that is, B = insucc(a). Draw diagrams to illustrate the two possible relationships between A and B. By mistake, the tag fields of B may not have not been set correctly, although all the threads and the tags of all the nodes other than B are set correctly. Modify the code of the function insucc(.) so that it correctly finds the in-order successor of node A (although it may not work correctly for node B). (5 marks) COIY058H7 Page 4 of 5 c Birkbeck College 2017

9. (a) At 1 January 2010 (time t1) a new file of 40 million records was constructed and held on disk. It would not be completely reconstructed until 31 December 2010. By 30 November 2010 (time t2), there had been many insertions and deletions, but more insertions, so that the file then contained nearly 80 million records. Copy the following table and write A, B or C in each of the cells to indicate whether for the specified method of file organisation and pattern of access: A Access is good at t1 and still pretty good at t2 B Access is good at t1 but markedly worse at t2 C Access is poor even at t1 Key-ordered sequential Indexed-sequential Hashed/random B-tree Key-ordered sequential access Random access (4 marks) (b) A B-tree of order 6 with a maximum of 5 records per data page currently has 3 levels. The keys of the records are three-digit positive integers, e.g. 037. What are the minimum and maximum number of records that there could currently be in the B-tree? Draw a possible B-tree B1 with the minimum number of records. Select some record in B1 and draw the resulting B-tree B2 after this record has been deleted from B1. For B2, you should include the keys on all pointer pages, but only need include the keys on those data pages that are changed after the deletion. (6 marks) 10. (a) You are given an unordered array of n, not necessarily distinct, positive integers a[1], a[2],... a[n]. Give an algorithm that returns some duplicate element, i.e. some integer that occurs in the array more than once, or returns 0 if all n elements are distinct. Your algorithm must not change the array and may only use a constant amount of additional space, i.e. not dependent on n. State the order of magnitude of the time complexity of your algorithm using O(.) notation. (5 marks) (b) Now suppose that your algorithm may change the array and may use any amount of additional space. Describe, without writing any code, how you could construct an algorithm to solve this problem that would run significantly faster than your original algorithm. What would the time complexity of this new algorithm be? (4 marks) COIY058H7 Page 5 of 5 c Birkbeck College 2017