u2 Flashcards

1
Q

precondition

A

a proposition concerning the inputs of an algorithm, such that if every precondition holds, then the algorithm will terminate with the correct output.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

postcondition

A

a proposition relating the outputs to the inputsof an algorithm, such that if every precondition holds, then when the algorithm terminates, each postcondition holds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Inertial convention

A

Aspects of an ADT’s state not referred to in the postcondition for an operation are unaffected by the operation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

invariant

A

a proposition concerning ADTs state that is always TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Binary search

A

•Set the partition to be the input sequence.
•Find the index of the midpoint of the partition. If the target is at the midpoint then the item is found. Otherwise divide the partition into two halves, Left and Right, at the midpoint. If the targetis less than the item at the midpoint then make Left the new partition. Otherwise make Right the new partition. Repeat the process with the new partition.
O(log n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly