[an error occurred while processing this directive]

Class 10 Notes

Lecture Slides, Suitable For Printing

Notes

Big-Oh: upper bound. A function g is in O (f) iff there are positive constants c and n0 such that g(n) ≤ cf(n) for all n ≥ n0.

Ω: lower bound. A function g is in Ω (f) iff there are positive constants c and n0 such that g(n) ≥ cf(n) for all n ≥ n0.

Θ: tight bound. A function g is in Θ (f) iff g is in O(f) and g is in Ω(f).


Best-First Sort

(define (sort lst cf)
  (if (null? lst) lst
      (let ((best (find-best lst cf)))
        (cons best (sort (delete lst best) cf)))))

(define (find-best lst cf)
   (if (= 1 (length lst)) (car lst)
  (pick-better cf (car lst) (find-best (cdr lst) cf))))

Insertion Sort

(define (insertsort cf lst)
  (if (null? lst) null
      (insertone cf (car lst) (insertsort cf (cdr lst)))))

(define (insertone cf el lst)
  (if (null? lst) (list el)
      (if (cf el (car lst)) (cons el lst)
          (cons (car lst) (insertone cf el (cdr lst))))))
What is the asymptotic running time of the sort procedures?






Which sort procedure is faster?






Why are these operators useful for understanding the cost of evaluating procedures?






Electrical Computers

Why are logical gates important?



What can one do with transistors made from semiconductors?



We consider simple machine operations, such as addition, to take Θ(1) time. This is sometimes called constant time. [an error occurred while processing this directive]