151 views

Uploaded by examkiller

- CS255 Data Structure Lab Manual
- DS_IMP_Q_A
- Problems of Data Structure
- 1071
- phani
- qb_2018_EEM303 Soln (updated 2.10.18).pdf
- EC6312 SET1.pdf
- Sd Summary
- Data-Strc
- [2011] Data Structures
- test2fall96
- Assignment of Concept of Linked List
- 03 Queues
- CSCA48_TT2_2012W
- Ece-ds & Oops- Manual
- Lab Manual DS and OOPS
- ms
- Linked List
- 03 Stack and Queue Data Structures
- it2205-datastructurelm

You are on page 1of 20

Aids Allowed: None

Student Number:

Last (Family) Name(s):

First (Given) Name(s):

Do not turn this page until you have received the signal to start.

In the meantime, please read the instructions below carefully.

This exam consists of 9 questions on 20 pages (including this

one), printed on both sides of the paper. When you receive the signal

to start, please make sure that your copy of the test is complete.

Answer each question directly on the test paper, in the space

provided, and use one of the blank pages for rough work. If you

need more space for one of your solutions, use a blank page and

indicate clearly the part of your work that should be marked.

Marking Guide

# 1: / 15

# 2: / 10

# 3: / 25

# 4: / 10

# 5: / 10

# 6: / 10

# 7: / 5

# 8: / 5

# 9: / 10

TOTAL: /100

Good Luck!

Page 1 of 20

CSCA48 Final

For the duration of this exam, you can assume that you have access to the following Python classes:

class LLNode(object):

A Node in a singly-linked list

def __init__(self, data):

(LLNode, object) -> NoneType

Create a new node to hold data

self.data = data

self.link = None

class DLLNode(object):

A Node in a doubly-linked list

def __init__(self, data):

(DLLNode, object) -> NoneType

Create a new node to hold data

self.data = data

self.next = None

self.prev = None

class BTNode(object):

A Node in a binary tree

def __init__(self, data):

(BTNode, object) -> NoneType

Create a new node to hold data

self.data = data

self.left = None

self.right = None

Page 2 of 20

Exam 24 April 2013

Question 1. [15 marks]

Implement the following ADT:

LetterQueue: A container for holding alphabetical letters, with the following public methods:

__init__(): initialize a new empty queue

enqueue(L): insert the letter L onto the end of the queue

dequeue_vowel(): remove and return the next vowel in the queue

dequeue_consonant(): remove and return the next consonant in the queue

size(): returns the number of elements in the queue

num_caps(): returns the number of capital letters in the queue

num_lower(): returns the number of lower-case letters in the queue

is_empty(): returns True i the queue is empty

Page 3 of 20

CSCA48 Final

Use the space on this blank page for scratch work, or for any solution that did not t elsewhere.

Clearly label each such solution with the appropriate question and part number.

Page 4 of 20

Exam 24 April 2013

Question 2. [10 marks]

For the LetterQueue ADT dened in the previous question, design a series of test cases to optimally

cover all testing of the ADT.Your code does not have to be in standard UnitTest style, but your as-

sertions should use the standard assertion calls, such as: AssertEqual, AssertTrue, AssertRaises,

AssertIsInstance, etc. You do not have to complete an exhaustive set of tests, but you should choose

a small number of representative tests for optimal coverage.

Purpose Assertion Test Type

Test that a newly created LetterQueue is empty my_lq = LetterQueue() Black Box

assertTrue(my_lq.isEmpty)

Page 5 of 20

CSCA48 Final

Use the space on this blank page for scratch work, or for any solution that did not t elsewhere.

Clearly label each such solution with the appropriate question and part number.

Page 6 of 20

Exam 24 April 2013

Question 3. [25 marks]

You have been hired to write a program to manage the data of a small community college. The dean has

sent you the following list of requirements:

We have a number of courses, with course codes like ABC123, each course has exactly one instruc-

tor, and may have zero or more students

Lecture courses meet on a particular day of the week in room (all rooms have numbers 0-500)

Reading courses dont have a specic time/place to meet, but they still have students and a teacher

We have three types of people in the school, students (we need to know their date of birth, student

number and name), faculty (we need to know their name, date of birth, oce number and a salary),

and sta (we need to know their name, date of birth and salary).

I should be able to create/modify courses/people and any of their elds. If someone puts in bad info,

it should give me an error explaining what I did wrong.

When I print a course, Id like to see its info, plus all students taking it, and when I print a student,

Id like to see their info and a list of all the courses theyre taking, when I print a faculty or sta

member, I just want to see their info.

Weve hired a programmer from our own course to do the actual implementation of the code, they are

familiar with Python, but have no idea how to structure a program. So you must provide them with

the class/inheritance structure, and method details, including DocStrings, as well as a few internal

comments per method to explain to an experienced programmer how to complete the methods, but

you do not need to provide the actual method bodies (hope you read all the way through before you started coding).

Page 7 of 20

CSCA48 Final

Use the space on this blank page for scratch work, or for any solution that did not t elsewhere.

Clearly label each such solution with the appropriate question and part number.

Page 8 of 20

Exam 24 April 2013

Question 4. [10 marks]

Complete the following function according to its DocString. For full marks, your code must be recursive:

def add_nested(L):

"""(nested list of numbers) -> number

Return the sum of all the numbers in the nested list L.

REQ: L and all of the components of L are either numbers, or nested lists of numbers

>>>add_nested([[],[[],[]]])

0

>>>add_nested([[], 1, [1, 1]])

3

>>>add_nested([2, 3, [4, [[[5]], 6]], 7])

27

"""

Page 9 of 20

CSCA48 Final

Use the space on this blank page for scratch work, or for any solution that did not t elsewhere.

Clearly label each such solution with the appropriate question and part number.

Page 10 of 20

Exam 24 April 2013

Question 5. [10 marks]

Complete the following function according to its DocString.

def reverse_list(L):

"""(LLNode) -> LLNode

Given the head of a linked list L, return the head of a linked list with the same

elements as L, but in reverse order

"""

Page 11 of 20

CSCA48 Final

Use the space on this blank page for scratch work, or for any solution that did not t elsewhere.

Clearly label each such solution with the appropriate question and part number.

Page 12 of 20

Exam 24 April 2013

Question 6. [10 marks]

Complete the following function according to its DocString.

def second_largest(root):

"""(BTNode) -> object

Return the vale of the second largest node in the binary search tree rooted at root

REQ: root is the root of a properly formed binary search tree, with >= 2 nodes

"""

Page 13 of 20

CSCA48 Final

Use the space on this blank page for scratch work, or for any solution that did not t elsewhere.

Clearly label each such solution with the appropriate question and part number.

Page 14 of 20

Exam 24 April 2013

Question 7. [5 marks]

Draw the Heap (the abstract node based representation, not the list implementation) resulting from the

following series of operations (assume you are using a max-heap (largest value at the root), and starting

with an empty Heap):

Insert 10

Insert 20

Insert 30

Insert 15

Insert 5

Insert 50

Remove-Head

Page 15 of 20

CSCA48 Final

Use the space on this blank page for scratch work, or for any solution that did not t elsewhere.

Clearly label each such solution with the appropriate question and part number.

Page 16 of 20

Exam 24 April 2013

Question 8. [5 marks]

Consider running the MergeSort algorithm on the following list:

[9,5,7,3,2,1,6,8]

What sub-lists will merge be called on over the course of the sort?

For example, if merge will be called twice, once to merge the lists [a,b,c] and [d,e,f], and once to

merge the lists [x,y,z] and [w], your answer would be:

merge([a,b,c],[d,e,f])

merge([x,y,z],[w])

Page 17 of 20

CSCA48 Final

Use the space on this blank page for scratch work, or for any solution that did not t elsewhere.

Clearly label each such solution with the appropriate question and part number.

Page 18 of 20

Exam 24 April 2013

Question 9. [10 marks]

Consider the following Splay Tree:

a) [5 marks] Draw the tree resulting from the operation insert(15)

b) [5 marks] Draw the tree resulting from the operation delete(3) performed on the original tree,

not the modied tree from part a)

Page 19 of 20

CSCA48 Final Exam 24 April 2013

End of Exam: Total Marks = 100

Page 20 of 20

- CS255 Data Structure Lab ManualUploaded byJagadeesh Kumar
- DS_IMP_Q_AUploaded byKumar Puspesh
- Problems of Data StructureUploaded byiiitsunny
- 1071Uploaded byPrashanth Raghavan
- phaniUploaded byVamshi Krishna Singirikonda
- qb_2018_EEM303 Soln (updated 2.10.18).pdfUploaded byMi
- EC6312 SET1.pdfUploaded byManju Nathan
- Sd SummaryUploaded byGabriel M Bero
- Data-StrcUploaded byKlevi Mehmeti
- [2011] Data StructuresUploaded byMd Isfaque
- test2fall96Uploaded byGobara Dhan
- Assignment of Concept of Linked ListUploaded byMosabbir Ahmed
- 03 QueuesUploaded byamitfegade121
- CSCA48_TT2_2012WUploaded byexamkiller
- Ece-ds & Oops- ManualUploaded byKishore Raveendiran
- Lab Manual DS and OOPSUploaded byChella Pandian
- msUploaded byHappy Anand
- Linked ListUploaded byJonreyLendioLumayag
- 03 Stack and Queue Data StructuresUploaded byThobius Joseph
- it2205-datastructurelmUploaded byAculfeloith Awesomstyle
- CS112mid1-1999(RUTGERS)Uploaded byManan Shah
- Dsa Mk Lect1Uploaded byAnkit Priyarup
- Data Structures and Algorithm LabUploaded byRandeep Singh
- program assignment 1Uploaded byapi-341819929
- QueueUploaded byanand
- Abstract Data Type.PptxUploaded byPhilmon Roberts
- DA06Uploaded byasim_albakali
- Cis110 12sp FinalUploaded bydodoman666
- C intrroductionUploaded byanusanrd
- Data Structures and ProgrammingUploaded bygullisatha

- Eco100y1 Wolfson Tt4 2014wUploaded byexamkiller
- MAT137_TT1_2013FUploaded byexamkiller
- Eco100y1 Wolfson Tt1 2012fUploaded byexamkiller
- Mgeb02 FinalUploaded byexamkiller
- Eco100y1 Wolfson Tt1 2013fUploaded byexamkiller
- Eco100 Furlong Tt2 2014sUploaded byexamkiller
- Eco100y1 Wolfson Tt2 2012fUploaded byexamkiller
- Eco100y1 Wolfson Tt4 2013wUploaded byexamkiller
- Eco100 Furlong Tt3 2014sUploaded byexamkiller
- Eco100y1 Wolfson Tt3 2014wUploaded byexamkiller
- MATH115 Exam1 2013W PracticeUploaded byexamkiller
- ECON 101 Final Practice1Uploaded byexamkiller
- Eco100y1 Wolfson Tt3 2013wUploaded byexamkiller
- MTH240_TT1Uploaded byexamkiller
- Eco100y1 Wolfson Tt2 2013fUploaded byexamkiller
- MATH150_Midterm1_2009SpringUploaded byexamkiller
- STAT110 Exam1 2009F Version BUploaded byexamkiller
- STAT112 Midterm1 PracticeUploaded byexamkiller
- STA220 Midterm 2009SpringUploaded byexamkiller
- STAT111 Final PracticeUploaded byexamkiller
- STAT110 Exam3 2009F Version AUploaded byexamkiller
- SSC302 Midterm 2010FUploaded byexamkiller
- STAT110 Exam1 Hendrix PracticeUploaded byexamkiller
- STAT111 Exam1 PracticeUploaded byexamkiller
- STAT110 Exam3 2009F PracticeUploaded byexamkiller
- STAT110 Final 2009Spring PracticeUploaded byexamkiller
- STAT220 Midterm PracticeUploaded byexamkiller
- MATH263_Mid_2009FUploaded byexamkiller
- STA220 Midterm 2009WUploaded byexamkiller
- STAT111 Exam2 PracticeUploaded byexamkiller

- Synopsis of the Transient Solvers in ESATANUploaded byP_lee
- Document 08dfea7f2df93916e14683c9b9676bccUploaded by郭冠軒
- Lempel ZivUploaded byHoós László
- median finding algorithmUploaded byvivek upadhyay
- Swift Algorithms 1.4Uploaded byerikoterice
- DNEPSAUploaded bySaeid Zamani
- Ch12 Cryptographic Hash FunctionsUploaded byPhạm Ngọc Hải
- A Framework to Discover Association Rules Using Frequent Pattern MiningUploaded byIntegrated Intelligent Research
- Micro Mouse Using At Mega 2560Uploaded byNitin Nandeshwar
- Ecc Lesson Plan 2013Uploaded byManjunath Ji
- Day16-InterpolationPolyUploaded byRuth Limbo
- 22trans3Uploaded byPotnuru Vinay
- AiUploaded bysaisampath katru
- SBES Final ReportUploaded bybehoya
- AIMA Ch3 L2-ComplementUploaded byAchmad Agung Setiawan
- Numerical MethodsUploaded byAndreas Neophytou
- AdaptiveUploaded bymshchetk
- Algorithm and Computation ComplexityUploaded bykrupanick24
- ImpUploaded byPatriniaRupestris
- optimisationUploaded byShubhamAgarwal
- Multilevel QueuesUploaded byNavdeep Walia
- tttttttttttttttUploaded byPranav Sodhani
- A Tabu Search Algorithm for Two Dimensional Non-Guillotine Cutting ProblemsUploaded byJulham Efendi Nasution
- DSS SyllabusUploaded bytheresa.painter
- Constructing a Fuzzy Network Intrusion Classifier Based on Differential Evolution and Harmonic SearchUploaded byAIRCC - IJCNC
- Updateless Decision TheoryUploaded byTyrrell McAllister
- Linkedlist CormenUploaded byadithya604
- Vort RagUploaded bysatya_chaganti
- 1_DBNUploaded byanoopingle9
- Microsof Certification ManualUploaded bymanelofm