Binary Search Flashcards

1
Q

What is algorithm ?

A

An algorithm is a set of instructions for accomplishing a task. Every piece of code could be called an algorithm

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

What is binary search algorithm

A

It is search algorithm where you divide the ordered set each time until you find the item
Ex: search 1 => 50 - 25 - 13 - 7 - 4 - 2 - 1

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

What is the big O - performance - of the binary search?

A

log 2 n

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

What is big O notition?

A

Run time of algorithms, It’s a notation that describe how fast the algorithm is
The formula => O(n) where n is number of steps

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

What the difference between array and linked list?

A

Array = > store item together in the memory, when new item added and there is no space next to the rest, the array will move to another slots where items can store togather
Array is random access

In search -> o(1)
In insert and delete -> o(n)

Linked list => store item in any free slot - not nessary togther - and each item will point to the next item.
List is sequential acess

In search -> o(n)
In insert and delete -> o(1)

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

What is selection sort algorithm?

A

It is a sorting algotithm where it is performance is O(n^2)

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