cse 2231 final copy

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/495

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

496 Terms

1
New cards

Abstract class

A "partial" or "incomplete" class that contains bodies for some but (typically) not all of the methods of the interfaces it claims to implement

2
New cards
3
New cards
Factoring out common code

Method bodies that can be written once— and work for any implementation of NaturalNumberKernel because they are programmed to that interface—have been factored out into an abstract class

4
New cards
5
New cards
Can you instantiate an abstract class?

No - You can't use an abstract class like a normal class and create objects from it

6
New cards
7
New cards
UUT

Unit under testing

8
New cards
9
New cards
How to achieve single-point control over change in this situation

"Re-route" all UUT constructor calls to another method, which then calls the UUT constructor, so only the body of that one method needs to be changed to accommodate a different UUT

10
New cards
11
New cards
Class ending with "L"

Kernel class that directly represents the new type using a component from Java libraries

12
New cards
13
New cards
Instance variable

There is a distinct variable (with the same name) for each instance of the class in which it is declared

14
New cards
15
New cards
Criteria for kernel implementation
  1. Easy to understand and write
16
New cards
  1. More efficient
17
New cards
18
New cards
Sequence3 on Stack

Sequence represented as 2 stacks, left and right. Sequence = rev(left) + right

19
New cards

Representation of sequence is 2 stacks "facing each other" in the middle of sequence

20
New cards
21
New cards
Client view

Mathematical models, method contracts

22
New cards

Kernel interface shows WHAT the software does

23
New cards
24
New cards
Implementer view

Data representation, algorithms

25
New cards

Kernel class shows HOW the software does it

26
New cards
27
New cards
Abstract state space

The set of all possible math model values as seen by the client

28
New cards
29
New cards
Concrete state space

The set of all possible math model values of the data representation

30
New cards
31
New cards
Abstraction function

How to interpret any concrete value (that satisfies the representation invariant) as an abstract value?

32
New cards

@correspondence

33
New cards
34
New cards
Representation invariant

What configurations of values of the instance variables can arise?

35
New cards

@convention

36
New cards
37
New cards
Why hashing?
  1. Can be quickly identified
38
New cards
  1. Must contain the item
39
New cards
40
New cards
T/F: Nodes in a linked list must always have consecutive memory addresses?

False

41
New cards
42
New cards
T/F: Nodes in a linked list can be accessed in constant time?

False

43
New cards
44
New cards
T/F: Nodes in a linked list require at least one smart node?

False

45
New cards
46
New cards
T/F: Nodes in a linked list can be accessed sequentially in linear time?

True

47
New cards
48
New cards
T/F: The process of building a heap will completely sort its elements?

False

49
New cards
50
New cards
T/F: A subroutine is needed to adjust the root of a subtree to its proper position, assuming the subtree is a heap except for its root

True

51
New cards
52
New cards
T/F: Heaps are parameterized by a type and an ordering process?

True

53
New cards
54
New cards
T/F: A heap is a binary tree with extra constraints on its shape and organization

True

55
New cards
56
New cards
Collection type definition

Any type whose abstract mathematical model involves: string, set, multiset, tree, binary tree

57
New cards
58
New cards
Collection type examples

Array, queue, set, sequence, stack, map, sorting machine

59
New cards
60
New cards
Array pros

-Direct access

61
New cards

-Constant time access (regardless of length)

62
New cards
63
New cards
Array cons

-Fixed size; can run out of room

64
New cards

-Fixed size; initialization might be expensive if entries go unused

65
New cards

-Adding/removing entires in the middle requires moving other entries, which is slow

66
New cards
67
New cards
Array is represented by…

A contiguous block of memory locations with consecutive memory addresses so the memory address of the entry at index i can be directly calculated from the memory address of the first entry, by using simple arithmetic

68
New cards
69
New cards
JVM

Java Virtual Machine

70
New cards
71
New cards
Binary tree

-Can be empty tree

72
New cards

-Or can be non-empty tree consisting of root node and 2 subtrees

73
New cards

-Mathematical type: Binary trees with any label of type T

74
New cards
75
New cards
Traversal Orders
  1. Pre-order: Root, left, right
76
New cards
  1. In-order: Left, root, right
77
New cards
  1. Post-order: Left, right, root
78
New cards
79
New cards
Binary Search Tree (BST)

A binary tree where the left node < root, and right node > root

80
New cards
81
New cards
Sorting Machine

-Allows adding elements of type T to a

82
New cards

collection of such elements, and then removing them one at a time in sorted order

83
New cards

-Mathematical model: 3-tuple

84
New cards

{insertion_mode: boolean,

85
New cards

ordering: binary relation on T,

86
New cards

contents: finite multiset of T}

87
New cards
88
New cards
Why is sorting machine better than sort?

-If all elements are already sorted by the end of "changeToExtractionMode", then there is no difference in performance

89
New cards

-If elements are not already sorted by the end of "changeToExtractionMode", then the performance advantage is that you don't need to remove all the elements

90
New cards
91
New cards
T/F: Smart nodes can prevent run-time errors arising from the code managing of a linked list?

False

92
New cards
93
New cards
T/F: Smart nodes can provide significantly faster performance when manipulating the elements of a linked list

False

94
New cards
95
New cards
T/F: Smart nodes can make initial setup of the linked list faster

False

96
New cards
97
New cards
T/F: Smart nodes can aid removal of special cases from some methods that work with a linked list

True

98
New cards
99
New cards
What is the data structure of a doubly-linked list?

2 references per node: one to the "next" node and one to the "previous" node

100
New cards