Docsity

Review Sheet for Final Exam - Data Structures | CS 261, Exams of Data Structures and Algorithms

Toggle sidebar
bg1
Review: Final Exam — CS 261: Data Structures
Midterm date: Monday, June 10, 6:00 PM (in class).
Covering: Chapters 1 through 17 (except Chap. 5) and Chap. 20 in the book and the corresponding lecture material
with a major focus on the material covered since Midterm # 2.
It will be closed book and closed notes—except three pages (both sides) of handwritten notes.
Sit with at least one empty seats between you and the next person.
You may bring a calculator, though you probably won’t need it.
Possible topics to expect:
Chapter 1: Management of Complexity
• Abstraction, Information Hiding, and Layering — Definitions and how they are related.
• Creating structure through Layering — Definitions, distinctions, examples
Specialization
Division into Parts
Multiple Views
• Division into Parts
Encapsulation and Interchangeability — Definitions and how they are related.
Interface and Implementation — Definitions, distinctions, relationship to software design.
Service view — Examples, Patterns, relationship to software engineering (ADTs).
Repetition
- Components
- Behavior — Mathematical induction, Recursion, Iteration
Composition
- Similarities and differences with Division into Parts.
- Difference (in terms of relationship between layers) with Specialization.
• Into which subtopic of Layering does the concept of the Java “interface” fit best?
Chapter 2: Abstract Data Types
• What is a Type
Values, Operations, and Properties
Primitive types and classes
Interfaces and Polymorphism
• Abstract Data Type (ADT) — Definition, Primary concern, Language construct (in Java)
• Point example.
• Interfaces and Classes (in Java) — Distinctions and relationship.
• Fundamental ADTs — Methods defined, relationship to each other, possible uses.
Collection — What does Serializable provide?
Bag — What does it add to Collection?
Set — Difference with a Bag.
Sorted — Describes a property of the type rather than (additional) behavior.
Comparator, Comparable — Distinctions and relationship
- DefaultComparator
Stack, Queue, Deque
FindMin, FindNth
Indexed
SortAlgorithm
Map
pf3
pf4
pf5
pf8

Partial preview of the text

Download Review Sheet for Final Exam - Data Structures | CS 261 and more Exams Data Structures and Algorithms in PDF only on Docsity!

Review: Final Exam — CS 261: Data Structures

Midterm date: Monday, June 10, 6:00 PM (in class).

Covering: Chapters 1 through 17 (except Chap. 5) and Chap. 20 in the book and the corresponding lecture material with a major focus on the material covered since Midterm # 2.

It will be closed book and closed notes—except three pages (both sides) of handwritten notes.

Sit with at least one empty seats between you and the next person.

You may bring a calculator, though you probably won’t need it.

Possible topics to expect:

Chapter 1: Management of Complexity

  • Abstraction, Information Hiding, and Layering — Definitions and how they are related.
  • Creating structure through Layering — Definitions, distinctions, examples Specialization Division into Parts Multiple Views
  • Division into Parts Encapsulation and Interchangeability — Definitions and how they are related. Interface and Implementation — Definitions, distinctions, relationship to software design. Service view — Examples, Patterns, relationship to software engineering (ADTs). Repetition - Components - Behavior — Mathematical induction, Recursion, Iteration Composition - Similarities and differences with Division into Parts. - Difference (in terms of relationship between layers) with Specialization.
  • Into which subtopic of Layering does the concept of the Java “interface” fit best?

Chapter 2: Abstract Data Types

  • What is a Type Values, Operations, and Properties Primitive types and classes Interfaces and Polymorphism
  • Abstract Data Type (ADT) — Definition, Primary concern, Language construct (in Java)
  • Point example.
  • Interfaces and Classes (in Java) — Distinctions and relationship.
  • Fundamental ADTs — Methods defined, relationship to each other, possible uses. Collection — What does Serializable provide? Bag — What does it add to Collection? Set — Difference with a Bag. Sorted — Describes a property of the type rather than (additional) behavior. Comparator, Comparable — Distinctions and relationship - DefaultComparator Stack, Queue, Deque FindMin, FindNth Indexed SortAlgorithm Map

Chapter 3: Algorithms

  • What is an algorithm?
  • Language independent
  • Implementation in Java — methods
  • Characteristics/Analyzing Accurate specification of input - Input parameter data types - Describe constraints — Pre-conditions - Enforce constraints in code — Validity checking Precise specification of instructions — Algorithmic clarity, avoid ambiguity Correctness Termination, execution time - Assumption about primitive statements - Termination of loops — termination “property”, examples Results, side effects - Function name, return type, parameter name(s) & type(s) - Describe results/output — Post-conditions - Document side effects — I/O, class and parameter variables Space Utilization — Trade-off between memory usage and execution time
  • Recursive algorithms Definition Conditional that divides execution into two cases - Base case - Recursive case — creates new instances of parameters and local variables Examples — Towers of Hanoi, others Termination analysis

Chapter 4: Execution-Time Measurement

  • Benchmarking How it should be performed? Possible sources of variance — dependencies Affect of problem size
  • Algorithmic (Asymptotic) Analysis — Big Oh Abstract away small variations — concentrate on how input size affect execution time Platform, compiler, and language independent
  • Constant Time — O(1): Primitive statements, Conditionals, Constant loops
  • Loop analysis: Examples Simple (single) loop — O( n ) Single loop: isPrime — O( ) Independent nested loops — O( n^3 ) Dependent nested loops — O( n^2 ) While loops - Simple, dependent - Binary subdivision — O(log n ) Function calls
  • Summation and the dominant component
  • Common names for various computation complexities
  • Benchmarking When does it help? What does it often indicate? What other factors can affect the execution time of a given algorithm?

n

  • LinkedList data structure Header: firstLink (head), sentinel (tail), elementCount (count) DoubleLink class: how it works and its methods Link class: difference between it and the DoubleLink class Interfaces implemented (and associated methods) - Bag : addElement, containsElement, findElement, removeElement - Deque : addFirst, getFirst, removeFirst, addLast, getLast, removeLast Execution times for various methods (expected and worst cases) Enumeration Advantages and disadvantages of LinkedList vs. Vector. Applications: large, positive integers

Chapter 9: List Variations

  • Sorted lists What advantage does a sorted list have over an unsorted list? Fast merge sort. Timing comparison for merge sort: Vector vs. LinkedList.
  • Self-organizing lists Inheritance vs. composition: - SelfOrgList extends LinkedList (inheritance) - SortedList has a LinkedList data member (composition) - When should you use one over the other?
  • Skip lists) How they work Recursive insert Effect of randomness on height of skip list structure Computational complexity of addition, search, and removal

Chapter 10: Stacks

  • The Stack Abstract Data Type (ADT). Interface methods (not including those inherited from Collection): - addLast - getLast - removeLast
  • Implementations: Vector LinkedList
  • Applications Checking for balanced parentheses Towers of Hanoi 8 Queens problem Knight’s tour

Chapter 11: Deques

  • The Deque Abstract Data Type (ADT). Interface methods (not including those inherited from Collection): - addFirst, getFirst, removeFirst - addLast, getLast, removeLast
  • Searching application: Maze Depth-first Breadth-first Compare and contrast the two methods
  • Implementations: IndexedDeque - How is it implemented? - Computational complexity comparison with LinkedList, VectorQueue, etc.

Chapter 12: Queues

  • The Queue Abstract Data Type (ADT). Interface methods (not including those inherited from Collection): - getFirst - addLast - getLast
  • Types of applications: Print queues Process scheduling
  • Searching application: Maze Depth-first Breadth-first Compare and contrast the two methods
  • Implementations: LinkedList VectorQueue RingBufferQueue Advantages and disadvantage of various implementations Time complexity of various data structures.

Chapter 13: Trees

  • Definitions and characteristics of trees Root node Interior node Leaf node Parent Child Descendents Subtree Path length Height Depth
  • Legal and illegal trees
  • Binary trees Properties of a binary tree Definitions and properties of a full binary tree - # of nodes for a tree of height n - # of leaves for a tree of height n Definition of a complete binary tree Vector representation of a binary tree - When is it efficient and when is it not? - Computing indices of the children/parent in a vector representation. Dynamic memory implementation Application: Animal game — Know how it works.
  • Transform value to an integer Mapping Folding Shifting Casts Combinations of techniques Goals of hash function: Uniformly distribute values
  • Map integer to a valid hash table index Modulus operator with hash table size Why is hash table size often a prime number?
  • Java’s hash function: hashCode When should you override the hashCode method?
  • Perfect hash function: what is it?
  • Collisions
  • Definition
  • Techniques for resolving collisions Open address hashing - Linear probing: increment of 1 or k - Quadratic probing - Random probing Chaining/buckets - Maintain a collection at each table entry. Rehashing
  • Load factor and hash table size
  • Hash table complexity Worst case Best case
  • Sorting algorithms using hash tables Counting sort Radix sort
  • Hash table implementation

Chapter 17: Maps

  • What is a map? A collection of key/value associations.
  • Examples of maps Dictionary Cache
  • Methods in the Map interface
  • Implementation Adaptor between Map interface and Bag interface Inner Association class Why is the Comparator defined at the Map level and not the Bag level?
  • Time complexity of various Bag implementation in the Map interface
  • Application: Silly Sentences What is the structure of the Map association used to implement Silly Sentences? Implementation - Grammar input - Sentence generation

Chapter 20: Graphs

  • What is a graph? Collection of nodes and edges where edges indicate a relationship/connection between two nodes. Often more interested in the relationships between nodes than in the nodes themselves.
  • Types of graphs: Edges: - Directed or undirected - Weighted (labelled) or unweighted Trees (relationships to graphs)
  • Representations: Adjacency matrix — weighted and unweighted Edge list — weighted and unweighted Advantages and disadvantages of the different representations
  • Algorithms: Reachability - Single source - All pairs Warshall’s algorithm: - What is it used for? - How does it work? - Computational complexity Floyd’s algorithm: - What is it used for? - What is the difference between it and Warshall’s algorithm Reachability — Edge list representation: - Maze example - Depth first search - Breadth first search Cost-first search — Dijkstra’s minimum-path graph search algorithm - Weighted graphs - How does it work? - Computational complexity — depends on the graph - Complete (or nearly so) (every vertex connected to every other) — O( V^2 log 2 V ) - c -connected (or sparse) (every vertex connected to at most c others) — O( V log 2 V ) - Special situations allows for O( V ) searchability