FACULTY OF SCIENCE ACADEMY OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING ADVANCED DATA STRUCTURES AND ALGORITHMS EXAM EXAMINATION JUNE 2014

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

CPSC 331 Term Test #2 March 26, 2007

CSE 373: Practice Final

CS134 Spring 2005 Final Exam Mon. June. 20, 2005 Signature: Question # Out Of Marks Marker Total

CSE 373 Winter 2009: Midterm #1 (closed book, closed notes, NO calculators allowed)

Midterm solutions. n f 3 (n) = 3

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

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

Topics for CSCI 151 Final Exam Wednesday, May 10

CLO Assessment CLO1 Q1(10) CLO2 Q2 (10) CLO3 Q4 (10) CLO4 Q3a (4)

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

How many leaves on the decision tree? There are n! leaves, because every permutation appears at least once.

CSE373 Fall 2013, Midterm Examination October 18, 2013

CS 315 Data Structures Spring 2012 Final examination Total Points: 80

namibia UniVERSITY OF SCIEnCE AnD TECHnOLOGY

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

Faster Sorting Methods

Module Contact: Dr Geoff McKeown, CMP Copyright of the University of East Anglia Version 1

CS 445: Data Structures Final Examination: Study Guide

CSE 332 Winter 2015: Midterm Exam (closed book, closed notes, no calculators)

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

About this exam review

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

PROGRAMMING IN C++ (Regulation 2008) Answer ALL questions PART A (10 2 = 20 Marks) PART B (5 16 = 80 Marks) function? (8)

( ) + n. ( ) = n "1) + n. ( ) = T n 2. ( ) = 2T n 2. ( ) = T( n 2 ) +1

End-Term Examination Second Semester [MCA] MAY-JUNE 2006

CS 251, LE 2 Fall MIDTERM 2 Tuesday, November 1, 2016 Version 00 - KEY

Instructions. Definitions. Name: CMSC 341 Fall Question Points I. /12 II. /30 III. /10 IV. /12 V. /12 VI. /12 VII.

Technical University of Denmark

Course Review for Finals. Cpt S 223 Fall 2008

CSE 332, Spring 2010, Midterm Examination 30 April 2010

Algorithms. AVL Tree

INSTITUTE OF AERONAUTICAL ENGINEERING

9. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally likely.)

(2,4) Trees Goodrich, Tamassia (2,4) Trees 1

(2,4) Trees. 2/22/2006 (2,4) Trees 1

Department of Computer Science and Technology

CMSC132, Practice Questions

CS 112 Final May 8, 2008 (Lightly edited for 2012 Practice) Name: BU ID: Instructions

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC)

CS301 - Data Structures Glossary By

) $ f ( n) " %( g( n)

Search Trees - 1 Venkatanatha Sarma Y

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Thursday 1st June 2017 Time: 14:00-16:00

Table of Contents. Chapter 1: Introduction to Data Structures... 1

COMP 250 Midterm #2 March 11 th 2013

Module Contact: Dr Tony Bagnall, CMP Copyright of the University of East Anglia Version 1

Major2 Examination Term: 162 Year: 2016/2017

Computational Optimization ISE 407. Lecture 16. Dr. Ted Ralphs

ECE 250 Algorithms and Data Structures

Algorithms in Systems Engineering ISE 172. Lecture 16. Dr. Ted Ralphs

CS251-SE1. Midterm 2. Tuesday 11/1 8:00pm 9:00pm. There are 16 multiple-choice questions and 6 essay questions.

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer)

AP Computer Science 4325

Computer Science E-22 Practice Final Exam

DIVIDE AND CONQUER ALGORITHMS ANALYSIS WITH RECURRENCE EQUATIONS

Course Review. Cpt S 223 Fall 2009

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. ECE 345 Algorithms and Data Structures Fall 2012

( ) ( ) C. " 1 n. ( ) $ f n. ( ) B. " log( n! ) ( ) and that you already know ( ) ( ) " % g( n) ( ) " #&

UNIVERSITY OF WATERLOO DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING E&CE 250 ALGORITHMS AND DATA STRUCTURES

Cpt S 223 Course Overview. Cpt S 223, Fall 2007 Copyright: Washington State University

Questions Total Points Score

Multiple Choice. Write your answer to the LEFT of each problem. 3 points each

Design and Analysis of Algorithms - - Assessment

CS171 Final Practice Exam

DIT960 Datastrukturer

Bachelor Level/ First Year/ Second Semester/ Science Full Marks: 60 Computer Science and Information Technology (CSc. 154) Pass Marks: 24

ECE250: Algorithms and Data Structures Midterm Review

CSL 201 Data Structures Mid-Semester Exam minutes

SOLUTIONS. COMP103 Introduction to Data Structures and Algorithms

S1) It's another form of peak finder problem that we discussed in class, We exploit the idea used in binary search.

COS 226 Midterm Exam, Spring 2009

MLR Institute of Technology

CS Transform-and-Conquer

CPSC 211, Sections : Data Structures and Implementations, Honors Final Exam May 4, 2001

SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF CSE COURSE PLAN. Sec. Name Office Office hour Mail id

UNIVERSITY OF WATERLOO DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING ECE ALGORITHMS AND DATA STRUCTURES Total:

& ( D. " mnp ' ( ) n 3. n 2. ( ) C. " n

( ). Which of ( ) ( ) " #& ( ) " # g( n) ( ) " # f ( n) Test 1

Advanced Set Representation Methods

University of Toronto Mississauga. Flip to the back cover and write down your name and student number.

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard

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

(a) Write code to do this without using any floating-point arithmetic. Efficiency is not a concern here.

Name: UTLN: CS login: Comp 15 Data Structures Midterm 2018 Summer

COMP Data Structures

c) A perfect ternary tree of height h? (In a ternary tree, each node may have up to three children.)

Questions from the material presented in this lecture

Section 1: True / False (1 point each, 15 pts total)

Comparison Based Sorting Algorithms. Algorithms and Data Structures: Lower Bounds for Sorting. Comparison Based Sorting Algorithms

Computer Science Spring 2005 Final Examination, May 12, 2005

COS 226 Midterm Exam, Spring 2011

Final Examination Semester 1 / Year 2011

Sample Exam 1 Questions

Algorithms and Data Structures: Lower Bounds for Sorting. ADS: lect 7 slide 1

Prepared By: Ms. Nidhi Solanki (Assist. Prof.) Page 1

Total Points: 60. Duration: 1hr

n 2 ( ) ( ) Ο f ( n) ( ) Ω B. n logn Ο

CS 8391 DATA STRUCTURES

Summer Final Exam Review Session August 5, 2009

Transcription:

FACULTY OF SCIENCE ACADEMY OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING MODULE CSC3A10 ADVANCED DATA STRUCTURES AND ALGORITHMS CAMPUS APK EXAM EXAMINATION JUNE 2014 DATE 2014-06-03 SESSION 12:30 15:30 ASSESOR(S) EXTERNAL MODERATOR DR ID ELLEFSEN DR GB O REILLY DURATION 3 HOURS MARKS 150 NUMBER OF PAGES: 11 PAGES INSTRUCTIONS: 1. ALL QUESTIONS MUST BE ANSWERED 2. ANSWER THE QUESTIONS IN NUMERIC ORDER 3. CALCULATORS ARE NOT PERMITTED TO BE USED 4. WRITE CLEARLY AND LEGIBLY REQUIREMENTS: NONE 1

QUESTION 1 (a) Provide a complete discussion on what is meant by the term Abstract Data Type and [5] how Abstract Data Types can be realised in Java. (b) Compare and contrast the implementation of a Singly-linked and Doubly-linked list. Provide [5] two (2) points of comparison with regards to the structural differences between these structures, and discuss three (3) advantages and disadvantages of these structures. (c) The performance of operations on Abstract Data Types is often expressed using Big-Oh [5] notation. Provide a discussion why this is the case and what advantages this approach has over other alternatives. (d) Consider the following function and using primiative counting express the runtime of this [5] function in Big-Oh notation. You should also state your assumptions and which operations should be considered to be primitive. public int f(int a[], int n) { int i = 0; while (i < n) { int b = n-i; float c = 0.0; int j = 0; while (j < b) { c += a[i] + a[j] / c; } for (int k = 0; k < n; k++) { c += a[j]; } i++; } } 2

QUESTION 2 (a) Discuss the following components of a graph and provide a detailed explination of [5] how these components can be used to form a graph. 1. Edges 2. Vertices (b) Provide an algorithm that releases a Breadth First Search of a graph. [5] (c) Compare and contrast Breadth First Search the Depth First Search in terms of application [2] and runtime complexity. (d) One application for a graph is to calculated the Shortest Path. Elaborate on a method [3] for calculating the shortest path between two points in a graph. (e) Graphs and Trees are common data structures used in Computer Science problems. In [5] many cases the choice of a Tree or a Graph is dependent on the problem being solved. Provide a discussion of the differences between Trees and Graphs in terms of applicable algorithms, runtime complexities, and uses. 3

QUESTION 3 Consider the following 2-4 tree provided below. Provide a graphic representation of the 2-4 Tree resulting from the following operations. You must provide a graphic representation of each step in the process, including all intermediate operations. Relevant operations must make use of the Inorder predecessor. Removal operations should follow from the tree that resulted from the insertion operations. 1. Insert nodes that contain the following keys: (inserted one-by-one, in the given order) 28, 98, 50, 22 2. Delete nodes that contain the following keys: (removed one-by-one, in the given order) 93, 90, 49, 22 The 2-4 tree is in the current state (leaf nodes are not shown, however they are assumed to exist): 49 90 93 The sequence of operations that result in the current state of the 2-4 tree can be found in Appendix A on Page 10. [15] 4

QUESTION 4 Consider the following AVL tree provided below. Provide a graphic representation of the AVL Tree resulting from the following operations. You must provide a graphic representation of each step in the process, including all intermediate operations. Relevant operations must make use of the Inorder successor. Removal operations should follow from the tree that resulted from the insertion operations. 1. Insert nodes that contain the following keys: (inserted one-by-one, in the given order) 84, 87, 50, 4 2. Delete nodes that contain the following keys: (removed one-by-one, in the given order) The AVL tree is in the current state: 84, 50, 79, 48, 23, 25 48 25 79 23 The sequence of operations that result in the current state of the AVL tree can be found in Appendix B on Page 10. [15] 5

QUESTION 5 Consider the following Red-Black tree provided below. Provide a graphic representation of the Red-Black Tree resulting from the following operations. You must provide a graphic representation of each step in the process, including all intermediate operations. Relevant operations must make use of the Inorder successor. Removal operations should follow from the tree that resulted from the insertion operations. 1. Insert nodes that contain the following keys: (inserted one-by-one, in the given order) 18, 6, 77, 36, 59, 47 2. Delete nodes that contain the following keys: (removed one-by-one, in the given order) The Red-Black tree is in the current state: 50 83, 50, 36, 6 83 The sequence of operations that result in the current state of the Red-Black tree can be found in Appendix C on Page 11. 6

QUESTION 6 (a) Provide a diagram that demonstrates the relationship between the structure of a Red-Black [5] Tree and a 2-4 Tree. (b) Binary Search Trees have an ordering property that determines how the nodes in the tree [5] are structured. Heaps also have an ordering property that determines how the nodes in the tree are structured. Explain the difference between the Binary Search Tree Ordering Property and the Heap Ordering Property and the result that these properties have on the resulting trees. (c) Provide a proof to show that the height of an AVL tree storing n keys is bound by O(log n). [10] 7

QUESTION 7 (a) Explain the phases of a Divide and Conquer algorithm. [2] (b) Provide brief pseudocode that explains how a Merge Sort operates. [3] (c) Using your knowledge of algorithmic analysis explain why QuickSort is described as having a worst-case runtime of O(n 2 ), but an expected runtime of O(n log n). Under what [5] conditions will QuickSort exhibit a O(n 2 ) runtime? (d) Explain what is meant by Stable Sorting Algorithm. [2] (e) Under what conditions would a Stable Sorting Algorithm be important? Justify your [2] answer. (f) A Lexicographic Sort is a type of Stable Sorting Algorithm. Provide and example of a [3] Lexicographic Sort and explain how it would work. (g) You have been approached by a company to write a function that can be used to return the number of bit that are set in a binary number. For instance, the binary number 0011001 2 has 3 bits set, therefore the function should return 3. You should write a function that operates as quickly as possible, and memory usage is not a concern. Explain how you would approach such a problem, what data structures you would use and what the expected runtime of your approach would be. [3] 8

QUESTION 8 (a) Bob loves programming languages and wants to plan his university course schedule for the [10] next few years (assuming that the is allowed to choose). He is interested in the following nine programming language courses: ASM, C, C++, Java, C#, Erlang, Scala, SML and Smalltalk. The prerequisites for the courses are: ASM - none C - ASM C++ - ASM, C Java - C, C++ C# - Java, ASM, C++ Erlang - SML, Smalltalk Scala - Java, SML, Smalltalk SML - ASM Smalltalk - none Draw a graph that demonstrates the dependencies between the above courses, and then outline the order of courses Bob should take to cover all the languages he wants to learn. (b) A Bitset is a common structure that allows set operations to be defined in terms of a number of bits that are set or not set in an array of integer values. In most cases, the implementation of a bitset makes use of integer arrays (meaning that you can have at most 32-bits per integer in the array - assuming that you are using 32-bit integer values). Provide an implementation for a class that realises the ISet interface described below. Your implementation should be as efficient as possible and you only need to provide the implementation for the functions below. You can assume that the constructors have been implemented for you and that the bitset array has been initialised where every bit is unset. [10] 1. set(...) will set the indicated bit in the bitset. 2. unset(...) will unset the indicated bit in the bitset. 3. union(...) will create a new bitset where bits set in the current bitset are combined with the bits set in the passed bitset (union operation). 4. difference(...) will create a new bitset where the bits are set if they are set in the current bitset but not in the passed bit set (difference operation). p u b l i c i n t e r f a c e I S e t { p r i v a t e i n t [ ] b i t s e t ; } p u b l i c void s e t ( i n t bitnumber ) ; p u b l i c void u n s e t ( i n t bitnumber ) ; p u b l i c I S e t union ( I S e t o t h e r S e t ) ; p u b l i c I S e t d i f f e r e n c e ( I S e t o t h e r S e t ) ; 9

A 2-4 Tree Operations Insert 49: Insert 93: Insert 90: 49 49 93 49 90 93 B AVL Tree Operations Insert 25: 25 Insert 48: 25 48 Insert 79: 25 48 79 Rebalancing: 48 25 79 Insert 23: 10

48 25 79 23 C Red-Black Tree Operations Insert 83: 83 Set Root Black: 83 Insert 50: 83 50 End of exam 11