3.1 - sort/searches Flashcards

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

what is a search algorithm used for?

A

finding a specific item of data within a data set

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

what is an effective search?

A

where the search will always find the solution/ target data

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

what is an efficient search?

A

a search that would find the solution quickly no matter its position in the data set

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

describe the concept of a linear search in terms of finding a piece of paper in a stack of paper

A
  • work from top of stack to bottom

- check each paper along the way

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

state the pros and cons for linear search

A

pros - easier to code/implement

      - list does not need to be sorted 
      - little memory used to store data 
       - good for small/medium sized lists 

cons -> inefficient/slow on a long list

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

what is the phrase used to describe binary search? —— and ——

A

divide-and-conquer algorithm

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

describe the concept of a binary search in terms of finding a certain page in a book

A
  • split book in two
  • see whether page required is before/after split
  • repeat on that side of the data set
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

describe the pros and cons of binary search

A

pros -> Faster than linear search on a large dataset

cons -> dataset must be sorted before starting
- more complicated to code

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

what does a sort algorithm do?

A

arranged a dataset in a particular order

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

pros and cons of bubble sort

A

Pros:

  • Easy to code/write
  • Does not use much memory

Cons:
- Poor for efficiency (very slow with large list)

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

pros and cons of merge sort

A

Pros:

  • Faster sorting algorithm
  • can easily sort longer lists of data

Cons:

  • Can be slower for small lists.
  • Needs additional memory.
  • complicated to code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what kind of sort is merge sort?

- describe how it works

A

divide and conquer algorithm

  • break large list into half, then pairs
  • then sort out small pairs
  • merge them together to one large list
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

how can you measure the efficiency of an algorithm?

A
  • time it takes to run

- amount of space it uses on a computer

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

define a trace table

A

a technique used to analyse the output of an algorithm on paper

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

compare a binary and linear search

A

binary search - list has to be ordered
- more efficient

linear- search any array of data type (not ordered)

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