Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing...
Transcript of Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing...
![Page 1: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/1.jpg)
A Level Computer Science
Topic 2: Searching and Sorting
Teaching London Computing
William Marsh School of Electronic Engineering and Computer Science
Queen Mary University of London
![Page 2: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/2.jpg)
Aims • Understanding and implement • Linear search • Binary search of sorted lists
• Introduce computational complexity • Understand sorting algorithms • Bubblesort • Insertion Sort • Quicksort
![Page 3: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/3.jpg)
Why Learn Standard Algorithms? • Real programmers never implement these! • They are in the library
• We are going to learn the importance of a good algorithm
Better a slow computer and a fast algorithms than a slow algorithm on a fast computer.
![Page 4: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/4.jpg)
Linear Search
![Page 5: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/5.jpg)
Search: The Problem • Find a target value in the list • Is it there? • If so, at what index?
• Target = 41, found at index 4 • Target = 27, not found
0 1 2 3 4 5 6 7 8 9 10 11
17 31 52 19 41 34 76 11 28 92 44 61
![Page 6: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/6.jpg)
Linear Search
• Idea: look at each entry in turn • Steps • Start at index = 0 • Is Array[Index] equal to the target? • If yes, stop; otherwise increment the index • Stop when index is one less than the length
0 1 2 3 4 5 6 7 8 9
17 31 52 19 41 34 76 11 28 92 34 Target
Index 0
![Page 7: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/7.jpg)
Linear Search – Algorithm • Algorithm in pseudo code • Array is A
index = 0 !while index < length of array! if A[index] equals target! return index! index = index + 1!return -1 to show not found !
![Page 8: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/8.jpg)
Exercise 1.1: Code Linear Search
• Outline of code to complete
• Pseudo code
index = 0 !while index < length of array! if A[index] equals target! return index! index = index + 1!return -1 to show not found !
def findLin(A, target):!# find the target in array A # return index or -1 ...! ... !!print(findLin([2,3,4], 3))!print(findLin([2,3,4], 7))!
![Page 9: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/9.jpg)
Computational Complexity
Compare the efficiency of algorithms
![Page 10: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/10.jpg)
Efficiency – How Fast? • Doesn’t it depend on the power of computer?
Small Computer (£)
Large Computer (£££)
6x times faster
Problem (size N)
Problem (size N)
Time: T
Time: T/6
![Page 11: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/11.jpg)
Efficiency – How Fast? • We only care about how the time increases • Maybe the time stays the same • Maybe doubling the size, doubles the time • Maybe doubling the size, more than doubles the time
Any Computer
Problem (size N) Time: T1
Problem (size 2*N) Time: T2
![Page 12: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/12.jpg)
Linear Search: How Many Steps? • On average, how many steps? • Assume: • Target is present • List length N
• Expect to look at 50% of locations on average • Complexity • Length N à N/2 steps • It does not matter how long each step takes
We are assuming same time to access any location. True in arrays (not generally in lists).
![Page 13: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/13.jpg)
Big-O Notation • Time (size = N) = N / 2 • Suppose for size 10, i.e. 5 steps, times is 15 ms • Size 20 à 10 steps à 30 ms • Size 40 à 20 steps à 60 ms • etc.
• BUT • We do not care about the exact time • We only care how the time increases with the size
• Linear search has complexity O(N)
![Page 14: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/14.jpg)
Exercise 1.2 Complexity • Discuss the statements on the complexity of
linear search • Which is correct?
![Page 15: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/15.jpg)
Binary Search
Searching a sorted list
![Page 16: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/16.jpg)
Searching a Sorted List • Question: why are books in the library kept in
order?
![Page 17: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/17.jpg)
Searching a Sorted List • Question: why are books in the library kept in
order?
• In an ordered array, we do not have to look at every item • “Before this one” • “After this one” • … quickly find the correct location
• What is the best algorithm for looking?
![Page 18: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/18.jpg)
Binary Search – Sorted Lists • Which half is it in? Look in the middle.
0 1 2 3 4 5 6 7 8 9
11 17 19 28 31 34 41 52 76 92 41 Target
Index 4
7
6
![Page 19: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/19.jpg)
Binary Search – Algorithm • Key idea: in which part of the array are we
looking?
left right
![Page 20: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/20.jpg)
Binary Search – 3 Cases
• Case 1: X equals target value • Case 2: X < target value
• Case 3: X > target value
left right mid X
right left
left X
right
![Page 21: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/21.jpg)
Binary Search – Algorithm left = 0!right = length of array!while right > left:! mid = average of left and right! if A[mid] equals target! found it at 'mid'! if A[mid] < target! search between mid+1 & right! otherwise ! search between left & mid!return not found!
![Page 22: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/22.jpg)
Binary Search – Python def BSearch(A, target):! left = 0! right = len(A)! while right > left:! mid = (left + right) // 2! if A[mid] == target:! return mid! elif A[mid] < target:! left = mid+1! else:! right = mid! return -1!
![Page 23: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/23.jpg)
Binary Search – Complexity
• Number of steps = number of binary digit to index • O(log N)
11 17 19 28 31 34 41 52
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
![Page 24: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/24.jpg)
Exercise 1.3 • Using playing cards and a pointer (or pointers),
show how the following search algorithms work • Linear search • Binary search
• A pen or pencil can be used as a pointer
• Do we need a pointer?
![Page 25: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/25.jpg)
How We Describe Algorithms
![Page 26: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/26.jpg)
Steps for Understanding Algorithms 1. The problem to be solved 2. The key idea 3. The steps needed 4. The state represented 5. The cases to consider 6. Pseudo code 7. Code
![Page 27: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/27.jpg)
Understanding Linear Search Steps • The problem to be
solved • The key idea • The steps needed • The state represented • The cases to consider • Pseudo code • Code
Application • Find an item in an unsorted list
• Look at each item in turn • Show it with e.g. cards • How far we have got • Found or not found • …
![Page 28: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/28.jpg)
Understanding Binary Search Steps • The problem to be
solved • The key idea • The steps needed • The state represented • The cases to consider • Pseudo code • Code
Application • Find an item in an sorted list
• Halve the part to be searched • Show it with e.g. cards • The two end of the search space • Left half, found, right half • …
![Page 29: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/29.jpg)
Sorting
![Page 30: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/30.jpg)
Sorting: The Problem
• Arrange array in order • Same entries; in order – swap entries
• Properties • Speed, space, stable,
0 1 2 3 4 5 6 7 8 9
17 31 52 19 41 34 76 11 28 92
11 17 19 28 31 34 41 52 76 92
![Page 31: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/31.jpg)
Discussion • Sort a pack of cards • Describe how you do it
![Page 32: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/32.jpg)
Bubble Sort – Insight
• Librarian finds two books out of order • Swap them over! • Repeatedly
0 1 2 3 4 5 6 7 8 9
17 31 52 19 41 34 76 11 28 92
![Page 33: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/33.jpg)
Bubble Sort – Description
• Pass through the array (starting on the left) • Swap any entries that are out of order • Repeat until no swaps needed
0 1 2 3 4 5 6 7 8 9
17 31 52 19 41 34 76 11 28 92
Quiz: show array after first pass
![Page 34: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/34.jpg)
Bubble Sort – Algorithm • Sorting Array A • Assume indices 0 to length-1
while swaps happen! index = 1! while index < length! if A[index-1] > A[index]! swap A[index-1] and A[index]! index = index + 1!
![Page 35: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/35.jpg)
Exercise 2.1 Bubble Sort • Complete the table to show the successive passes
of a bubble sort
![Page 36: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/36.jpg)
Demo
sortingDemo.py
![Page 37: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/37.jpg)
Bubble Sort – Properties • Stable • Inefficient • O(N2) • Double length – time increases 4-fold
http://www.sorting-algorithms.com/bubble-sort
![Page 38: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/38.jpg)
Insertion Sort – Insight
• Imagine part of the array is ordered • Insert the next item into the correct place
17 31 52 19 41 34 76 11 28 92
ordered not yet ordered
17 31 52 19 41 34 11 28 76 92
ordered not yet ordered
![Page 39: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/39.jpg)
Insertion Sort – Description
• Start with one entry – ordered • Take each entry in turn • Insert into ordered part by swapping with lower
values • Stop when all entries inserted
17 31 52 19 41 34 76 11 28 92
ordered not yet ordered
![Page 40: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/40.jpg)
Exercises 2.2 & 2.4 • Using playing cards (e.g. 6) to show the sort
algorithms • bubble sort • insertion sort
![Page 41: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/41.jpg)
Insertion Sort – Algorithm • Sorting Array A • Assume indices 0 to length-1
index = 1 !while index < length of array! ix = index! while A[ix] < A[ix-1] and ix > 0! swap A[ix] and A[ix-1]! ix = ix – 1! index = index + 1!
• A[0:index] ordered • Same values
Inner loop: insert into ordered list
![Page 42: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/42.jpg)
Quicksort – Insight • How could we share out sorting between two
people? • Choose a value V • Give first person all values < V • Give second person all values > V
• When there is only a single entry – it is sorted
![Page 43: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/43.jpg)
Quicksort Example 17 31 52 19 41 34 76 11 28
28 17 19 11 31 34 76 52 41
all < 31 all >= 31
11 17 19 28
19 28
41 34 52 76
34 41
![Page 44: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/44.jpg)
Quicksort Description • Choose a pivot value • Partition the array • Values less than the pivot to the left • The pivot • Values greater than the pivot to the right
• Repeat process on each partition • Stop when the partition has no more than one
value
![Page 45: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/45.jpg)
Properties • Insertion sort • O(N2) – same as bubble sort • Stable
• Quicksort • More efficient: O(N logN) • Not stable
http://www.sorting-algorithms.com/insertion-sort
http://www.sorting-algorithms.com/quick-sort
![Page 46: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/46.jpg)
Exercises 2.6 • Using playing cards (e.g. 6) to show the sort
algorithms • quicksort
![Page 47: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/47.jpg)
Quick Sort – Recursive Implementation
def quickSort(A):! alen = len(A)! if alen < 2: return A!! p = A[0]! A1 = []! A2 = []! ! for i in range(1, alen):! if A[i] < p:! A1.append(A[i])! else:! A2.append(A[i])!! return quickSort(A1) + [p] + quickSort(A2)!
Quicksort and Mergesort can be described using
recursion: later topic.
![Page 48: Topic 2: Searching and Sorting€¦ · Topic 2: Searching and Sorting T eaching L ondon C omputing William Marsh School of Electronic Engineering and Computer Science Queen Mary University](https://reader034.fdocuments.net/reader034/viewer/2022042415/5f300010665ce8368f7be53d/html5/thumbnails/48.jpg)
Summary • Need for algorithms
• Difference between • O(log N) and O(N) – searching • O(N log N) and O(N2) – sorting
• Divide and conqueror principle