Download Cosc 241 Programming and Problem Solving Exam Guidance Exam

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Linked list wikipedia , lookup

Quadtree wikipedia , lookup

Binary search tree wikipedia , lookup

Transcript
Exam format
I
Nine questions, ten points per question
Theorem (Albert, 1985-now)
Cosc 241
Programming and Problem Solving
Exam Guidance
I
Each question has a title, indicating its theme
Not all points are created equal.
I
Write all answers in booklet, not on exam itself even if
there seems to be space available/provided
I
Questions are typically divided into three or four parts, and
points are specified for each part
That is, some questions are easier than others (sometimes just
for you, sometimes for everyone). Think about time and effort
management.
Michael Albert
I
Previous exams are a good study guide, but content and
delivery have changed somewhat so emphasis will be a
little different
[email protected]
I
What do you need to know?
I
In principle, anything covered in lectures, the associated
sections of the textbook, or in labs is fair game
I
In practice, most of the exam is devoted to material
covered in the lectures, and the associated sections of the
textbook
I
A happy grader is a generous grader so:
In particular if you find a question on an exam (particularly
pre 2011) that doesn’t seem to make sense it probably
means we didn’t cover that – check your notes, look in the
textbook, and then if still unsure, ask
1
I
Words to the wise
I
Start each question on a new page
I
If you don’t finish a question and plan to come back to it,
leave an extra page or two
I
Be as neat and organized as possible
I
Avoid the ‘brain dump’ technique (almost all parts of
questions can be answered fully in a short paragraph at
most)
2
Algorithms, recursion and algorithmic analysis
3
Arrays, sorting and searching
I
What is an algorithm?
I
How do we describe them?
I
We covered Chapters 11 through 19 of the text, omitting
only quick sort and merge sort (in 13.2), 14.5, 14.6, 14.14,
15.2, 15.3, 16.5
I
What (and why) is recursion? [Links forward to recursive
data structures]
Using subarrays (particularly in recursive methods for array
processing)
I
Finding maximum values, doing swaps
I
Who is the big-O? And what does he mean?
I
Searching in unsorted and sorted data (binary search)
We also covered random number generation and use (not
in text)
I
Scales of efficiency (is n log n better than n2 ?)
I
Sorting methods (selection, insertion, heap sort)
I
Common efficiency analyses (nested loops, divide and
conquer)
I
Look at the ‘outline’ slide in each lecture to see what I
considered the main points
I
CS in general and programming in particular are
cumulative subjects, so a certain amount of background is
presupposed (e.g. arrays, references, methods, . . . )
5
4
ADT principles, data structures
I
What is an ADT?
I
What are the advantages of using ADTs?
I
What is the relationship between ADT and data structure?
I
Common ADTs: stack, list, queue. Similarities and
differences.
Stack and queue ADTs, linked data structures
I
7
6
Graphs and trees
What is a stack? What is a queue? How are they similar?
How are they different?
I
Basic definitions and terminology
I
How are linked data structures implemented in Java?
I
I
One link good, two links bad? (issues with multiple linking)
Traversals (we considered trees mostly, but implicitly in
graphs in e.g. distance algorithms, see 19.4)
I
Room for some “hands on” material here (e.g. ‘What does
this code do?’)
I
Weighted graphs, distances, and minimum spanning trees
8
9
Binary trees, and binary search trees
Heaps, heap sort, and priority queues
The heap data structure
I
How are random numbers generated in a computer?
I
Addition and removal algorithms
I
I
Using heaps for sorting (in place, O(n log n) – best
possible for a comparison based sort)
What is the difference between true randomness and
pseudo-random numbers?
I
How can we use randomness to e.g. shuffle an array?
I
Priority queue ADT and why heap is an ideal data structure
for it
I
To choose k items from a list of n? (several methods)
I
To choose k items from a list of unknown length?
I
I
Definitions
I
Properties of a search tree, and searching algorithm
I
Addition and deletion algorithms in search trees
I
Balance – and its importance for efficiency
10
Question: Recursion
I
I
I
I
I
I
recursive function definitions (e.g. factorial)
Towers of Hanoi
array algorithms (using subarrays)
sorting
almost anything to do with trees
I
I
I
Generic types allow us to describe many types in a single
interface e.g. “Stack of T” where T is any class
I
Without them, we’d need a separate interface for each type
of stack, or be limited to “Stack of Object”
I
If you are asked to provide code
I
Question: ADT vs. Data Structure
The distinction between data structures and ADTs - eg why is a
list an ADT but a linked list a data structure
Some clarification on generic types and their importance in
ADTs for collections?
We saw recursion in several different contexts including:
the algorithm will be described clearly in the text,
the code skeleton will be in place,
it will be a few lines illustrating that you know where and
how to use recursion
ADT An abstract specification or description of various
methods (and implicitly of the contracts they are
intended to fulfill)
DS A realisation or implementation of an ADT
In Java:
Basically, a generic type is a “formal type parameter” while
an implementing class provides the “actual type parameter”
(this parallels the situation with methods, see p. 216 of text)
13
Question: O
14
Question: Binary trees
What is the depth of a binary tree, and what are its maximum
and minimum possible values?
Some clarification on the formal definition of the big Oh notation
The depth or height (I can never keep them straight and so
don’t expect you to either) of a binary tree is the length of its
longest branch.
(copy and paste from lecture 5)
We write
If the tree has n nodes, and each has only one child then the
depth will be n 1, i.e. O(n).
f (n) = O(g(n))
if, for some constant A, f (n)  Ag(n) for all sufficiently large n
If the tree is fully balanced (like the structure of a heap) then
there are 2k nodes at depth k and the depth is blog2 nc,
i.e. O(log n).
16
12
11
Question: Generics
I’m interested in asking about the scope of the recursion
question we will be given and what material it will be from.
I
Random
17
I
An ADT is described by an interface
I
A data structure which implements that ADT is described
by a class
I
E.g. a List ADT might be implemented using either a
linked list or an array as a data structure.
15