Searching Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

How many compares are used for search hits in sequential search in the worst case?

A

N compares

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

How many compares to insert into an inittally empty Linked List Symbol Table?

A

N^2 / 2

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

How many compares does a search hit use in a BST?

A

2 ln N

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

How many compares do insertions and search misses in a BST require?

A

2 ln N

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

What is the height of a red-black BST?

A

2 lg N

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

What is the average lenth of a path from root to node in a RB tree?

A

1.00 lg N

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

Which operations take logarithmic time in the worst case in a RB BST?

A
  • Search
  • inesrt
  • min
  • max
  • floor
  • ceiling
  • rank
  • select
  • delete min
  • delete max
  • range count
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the compares used for search and insert in the worst case for 2-3 trees?

A

lg N

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

What is the average length of the lists in separate chaining?

A

N / M

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

Why is the probability that the number of keys in a list is within a small constant factor of N/M, close to 1?

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

What is the growth rate of the average length of the longest list in a separate chaining?

A

log N / log log N

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

What are the number of compares for miss and insert in a Separate Chaining has table?

A

N/M

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

How does get() work in sequential search in an unordered symbol table?

A

Scan through list, using equals() to compare search key with key in each node.

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

How does put() work in a linked list implementation of an unordered symbol table?

A

Same as get(), however update value once match is found, else inserted at beginning.

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

How does binary search work?

A

Compare search against key in middle half.
* If search < middle, search left, else right.

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

How many compares does Binary Search in an ordered array use?

A

lg N + 1

17
Q

How many accesses does it take to insert a key into an ordered array, in the worst case?

A

2N

18
Q

What is the order of growth for get, contains, floor, ceiling, rank in an ordered array?

A

log N

19
Q

What is the order of growth for deleteMin, delete and put in an ordered array ST?

A

N

20
Q

How many accesses does it take to insert a key into an initially empty table?

A

N^2

21
Q

What is the worst case for search and insert, in sequential search? (Unordered linked lists)

A

N

22
Q

What is the worst case for search and insert in binary search (ordered arrays)?

A

lgN, 2N

23
Q

What are the pros and cons of SequentialSearchST?

A
  • Best fow tiny ST’s
  • Slow for large STs
24
Q

What are the pros and cons of BinarySearchST?

A
  • Optimal search and space, order based
  • Slow insert
25
Q

What are the pros and cons of BST?

A
  • Easy implement, order based
26
Q

What are the pros and cons of RedBlack BSTs?

A
  • Optimal search and insert, order based
  • Space for links
27
Q

What are the pros and cons of Hash Tables?

A
  • Fast search/insert for common data
  • Need hash for each type, no order, space for links/empty
28
Q

What is the recursive relation of Binary Search?

A