## 12.3.A few Algorithms To Analyse

• Bubblesort: Complexity (compare): O( )

Complexity in worst case (compare): O( )

Complexity in average case (compare): O( )

Complexity in best case (swap): O(1)

• Shakersort: Complexity: O( )

• Looking up an element in a BST. We assume, that each node have two children and only the leaves has no children:

Procedure Look_up(node n_r, label x): Complexity: O( )

• The 8 queens problem:

Procedure 8_queen(int nqueen, boolean board ) • The Tower of Hanoi algorithm:

Procedure move(int n_rings, peg from, peg to, peg over): Complexity: O( )

• The quicksort algorithm:

Procedure void quicksort(array numbers, int lo, int hi ) Complexity (average): O( )

• A s permutati Pr Main pr Y ind a C pr

```1.   /users/faculty/hpbischo/221/Src/perm.c
2.   /users/faculty/hpbischo/221/Src/knapsack.c
```

A difficult alg

Newtons algorithmn: find x such that f(x) = 0.

The algorithmn as a Nassi Shneidermann diagram: find(x) as a Nassi Shneidermann diagram:

Procedure find(real x) Beware of f'(x) == 0.