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

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

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY THIRD SEMESTER B.TECH DEGREE EXAMINATION, JULY 2017 CS205: DATA STRUCTURES (CS, IT)

CS301 - Data Structures Glossary By

Data Structures and Algorithms

Module Contact: Dr Gavin Cawley, CMP Copyright of the University of East Anglia Version 1

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

Introduction to Algorithms October 12, 2005 Massachusetts Institute of Technology Professors Erik D. Demaine and Charles E. Leiserson Quiz 1.

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

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

Course Review for Finals. Cpt S 223 Fall 2008

Student number: Datenstrukturen & Algorithmen page 1

Quick Sort. CSE Data Structures May 15, 2002

INSTITUTE OF AERONAUTICAL ENGINEERING

(b) If a heap has n elements, what s the height of the tree?

21# 33# 90# 91# 34# # 39# # # 31# 98# 0# 1# 2# 3# 4# 5# 6# 7# 8# 9# 10# #

CS301 All Current Final Term Paper Subjective 2013 Solved with refernces

Module 2: Classical Algorithm Design Techniques

CS2223: Algorithms Sorting Algorithms, Heap Sort, Linear-time sort, Median and Order Statistics

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

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

COS 226 Algorithms and Data Structures Fall Midterm

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

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

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

List of Transparencies

Programming II (CS300)

Course Review. Cpt S 223 Fall 2009

CPSC 331 Term Test #2 March 26, 2007

Sorting and Selection

Selection, Bubble, Insertion, Merge, Heap, Quick Bucket, Radix

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

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

CS210 (161) with Dr. Basit Qureshi Final Exam Weight 40%

CSE 373 Sample Midterm #2 (closed book, closed notes, calculators o.k.)

Table ADT and Sorting. Algorithm topics continuing (or reviewing?) CS 24 curriculum

CS8391-DATA STRUCTURES QUESTION BANK UNIT I

CSE Data Structures and Introduction to Algorithms... In Java! Instructor: Fei Wang. Mid-Term Exam. CSE2100 DS & Algorithms 1

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

Final Examination CSE 100 UCSD (Practice)

Chapter 1 Divide and Conquer Algorithm Theory WS 2014/15 Fabian Kuhn

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Data Structures and Algorithms. Final Examination

Data Structures and Algorithms

Department of Computer Science and Technology

Data Structures Question Bank Multiple Choice

1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers?

COS 226 Midterm Exam, Spring 2009

University of Waterloo Department of Electrical and Computer Engineering ECE250 Algorithms and Data Structures Fall 2014

Programming II (CS300)

CSE 373 Autumn 2012: Midterm #2 (closed book, closed notes, NO calculators allowed)

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

Second Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms...

CS 8391 DATA STRUCTURES

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

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

COMP2012H Spring 2014 Dekai Wu. Sorting. (more on sorting algorithms: mergesort, quicksort, heapsort)

1. Attempt any three of the following: 15

Cpt S 223 Fall Cpt S 223. School of EECS, WSU

CS 3343 (Spring 2013) Exam 2

Cpt S 122 Data Structures. Sorting

Data Structures and Algorithms 2018

Lecture 19 Sorting Goodrich, Tamassia

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

Closed Book Examination. One and a half hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Wednesday 20 th January 2010

Question Bank Subject: Advanced Data Structures Class: SE Computer

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

Discuss the following operations on One-Dimensional array with algorithms.

COS 226 Midterm Exam, Spring 2011

School of Computer Science

Queues. ADT description Implementations. October 03, 2017 Cinda Heeren / Geoffrey Tien 1

CS61BL. Lecture 5: Graphs Sorting

Module Contact: Dr Gavin Cawley, CMP Copyright of the University of East Anglia Version 1

CS-301 Data Structure. Tariq Hanif

CS8391-DATA STRUCTURES

CSCE 2014 Final Exam Spring Version A

Total Points: 60. Duration: 1hr

Sample Exam 1 Questions

Heaps. 2/13/2006 Heaps 1

COMP Data Structures

School of Computer Science

ECE 250 Algorithms and Data Structures

University of Waterloo CS240 Spring 2018 Help Session Problems

GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER ENGINEERING (07) / INFORMATION TECHNOLOGY (16) / INFORMATION & COMMUNICATION TECHNOLOGY (32) DATA STRUCTURES

Unit 6 Chapter 15 EXAMPLES OF COMPLEXITY CALCULATION

Basic Data Structures (Version 7) Name:

IS 709/809: Computational Methods in IS Research. Algorithm Analysis (Sorting)

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)

QUESTION BANK. Prepared by,mrs.d.maladhy AP/IT,RGCET. Page 1

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

MLR Institute of Technology

Course Review. Cpt S 223 Fall 2010

COS 226 Algorithms and Data Structures Fall Midterm

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

D. Θ nlogn ( ) D. Ο. ). Which of the following is not necessarily true? . Which of the following cannot be shown as an improvement? D.

1. AVL Trees (10 Points)

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

Sorting. Two types of sort internal - all done in memory external - secondary storage may be used

Divide-and-Conquer. Dr. Yingwu Zhu

( ) 1 B. 1. Suppose f x

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

Transcription:

UNIVERSITY OF EAST ANGLIA School of Computing Sciences Main Series UG Examination 2015-16 DATA STRUCTURES AND ALGORITHMS CMP-5014Y Time allowed: 3 hours Section A (Attempt any 4 questions: 60 marks) Section B (Attempt any 2 questions: 60 marks) Notes are not permitted in this examination. Do not turn over until you are told to do so by the Invigilator. CMP-5014Y Module Contact: Dr Geoff McKeown, CMP Copyright of the University of East Anglia Version 1

Page 2 SECTION A 1. (a) Outline a general strategy for determining the complexity of an algorithm. (b) Use the strategy you have described to determine the worst-case run-time complexity of the following sorting algorithm. for i from 1 to n-1 do //Find the item next, that should be in //position i in the sorted array: next := a[i]; indexofnext := i; for j from i+1 to n do if ( a[j] < next ) then next := a[j]; indexofnext := j; endif endfor swap the positions of item a[i] and next in the array; // items in positions 1,..., i are now in sorted order. endfor; Show your working. [11 marks] 2. (a) Describe how a FIFO queue may be represented using a circular array. (b) Give algorithms for the enqueue and dequeue methods for a queue represented in this way. You may assume that a method, doublecirculararray, is available for doubling the length of the underlying array when necessary. [8 marks]

Page 3 (c) State the run-time complexity of each of your algorithms. [3 marks] 3. (a) Describe a linear-time heap construction algorithm, illustrating your answer by constructing a max heap for the following numbers. 37,25,31,39,36,38,42,26,44,38,42,45,53,60,46. [7 marks] (b) Determine the maximum number of swap operations your algorithm could require to construct a heap from thirty one numbers (in a swap operation, a parent value is swapped with one of its child values). (c) Describe an algorithm for inserting an additional element into a heap, assuming that the underlying data structure used to represent the heap is a one-dimensional array, a. 4. (a) Define what is meant by a B-tree of order m. [5 marks] (b) Draw diagrams to illustrate the insertion of the following keys, in the order given, into a 2-3 tree. 39,62,43,27,14,60,35,24,82,51,33. [10 marks] TURN OVER

Page 4 5. (a) In the context of hashing, briefly describe what is meant by each of the following terms: (i) open addressing; (ii) probe increment; (iii) quadratic probing; (iv) double hashing. [8 marks] (b) Let h(k) = k%11, where % is the remainder operator (e.g. 25%11 = 3). Insert the following set of keys into a hash table of size 11, using double hashing to resolve collisions, with the probe increment defined as follows: p(k) = 5 (k%5). Give the sequence of locations probed during the insertion of each key. 17,9,26,34,25,31,37,48. [7 marks]

Page 5 SECTION B 6. (a) Explain what is meant by a divide-and-conquer" algorithm. (b) Describe both informally and formally in pseudo-code the divide-and-conquer algorithms merge sort and Quicksort for sorting an array of comparable items into ascending order. [12 marks] (c) Illustrate the use of the merge sort algorithm and the Quicksort algorithm (using the median of three pivot) to sort the following array into ascending order: A = [12,28,14,12,30,11,8,35,11,12]. In each case, show all working and count the number of comparisons performed. (d) Describe informally and formally in pseudo-code a partitioning algorithm for Quicksort that allows an in-place implementation. Demonstrate how the algorithm works by partitioning the following array A = [12,28,14,12,30,11,8,35,11,12] using the pivots you obtained in part (c). (e) State the worst-case and average case time complexity of the Quicksort algorithm and the merge sort algorithm. TURN OVER

Page 6 7. (a) In the context of binary trees, explain what is meant by: (i) the height of the tree; (ii) a height-balanced binary tree. (b) Draw diagrams to illustrate the effect in a binary tree of (i) a right rotation; (ii) a left rotation. (c) (i) Insert the following integers in the order given into a binary search tree 33,40,38,24,45,19,34,57,35,25,49,39,42. [5 marks] (ii) Write the balance of each node next to it in your tree. State which node(s) is (are) unbalanced. [3 marks] (iii) Explain how the tree may be re-balanced, drawing diagram(s) to illustrate the process. (iv) Explain what happens when 33 is deleted from your balanced tree. What is the complexity of deletion in a height-balanced binary search tree. Justify your answer. 8. (a) Describe what is meant by a trie. (b) Given the following set of keys: S = {346,354,355,3553,3558,357,380,510,513,5134,546,549}. (i) Draw the trie corresponding to S. (ii) Explain how a trie may be represented as a binary tree; represent the trie from (i) as a binary tree. [10 marks] (iii) Explain how a trie may be represented as a two-dimensional array; represent the trie from (i) using this method. [10 marks]

Page 7 9. Consider the following set of disjoint sets: S = {{2,5,7},{3,11,6},{1,8,10,12},{4}}. (a) Represent S by an appropriate forest of trees. (b) Explain how your forest may in turn be represented by a one-dimensional array and give the array. [5 marks] (c) Suppose that it is required to merge the set containing 11 with the set containing 10. Assuming no ranking rule is used in deciding how to do this merge, draw the two possible forests of trees that could result and give the corresponding one-dimensional arrays. Which of the two forests is to be preferred and why? [8 marks] (d) Give an algorithm that uses the array representation of a set of disjoint sets to find the set containing item i, where i is specified. Illustrate the application of this algorithm to find element 10 in each of the arrays given in part (c). [7 marks] (e) Describe how a ranking rule based on the count of the number of nodes in a tree can be used when implementing the merge operation so as to reduce the average number of levels traversed during applications of the find operation. END OF PAPER