Docsity

Computability - Introduction to Computing for Engineers | CS 1371, Study notes of Computer Science

Partial preview of the text

Download Computability - Introduction to Computing for Engineers | CS 1371 and more Study notes Computer Science in PDF only on Docsity!

CS

Introduction to Computing

for Engineers

Computability

Introduction

Learning Objectives Learn the issuesassociated withcomputability

Introduction •^

Reasonable vs. Unreasonable Algorithms

Algorithmic Performance Thus Far

•^

Some examples thus far:^ –

O(1)

Insert to front of linked list

O(log N)

Binary Search

O(N)

Simple/Linear Search

O(N Log N)

Merge Sort

O(N

Insertion Sort

•^

But it could get worse:^ –

O(N
5 ), O(N

2000

), etc.

An O(N

5 ) Example

For N = 256 5

N

5

If we had a computer that could execute a million

instructions per second…

-^

1,100,000 seconds = 12.7 days to complete But it could get worse…

The Wise Peasant’s Pay

Day(N) 7

Pieces of Grain

N

How Bad is 2

N

  • 8

Imagine being able to grow a billion(1,000,000,000) pieces of grain a second…

-^

It would take–

585 years to grow enough grain just forthe 64

th

day

Over a thousand years to fulfill thepeasant’s request!

The Towers of Hanoi

A
B
C

Goal: Move stack of rings to another peg

Rule 1: May move only 1 ring at a time

Rule 2: May never have larger ring on top ofsmaller ring

Towers of Hanoi: Solution

  • Move Original State
    • Move
      • Move
        • Move
        • Move
          • Move
          • Move

Towers of Hanoi (

N

) Runtime

For N = 64 13

N^

64

If we had a computer that could execute a million

instructions per second…

-^

It would take 584,000 years to complete But it could get worse…

The Bounded Tile Problem

Match up the patterns in thetiles. Can it be done, yes or no?

Tiling a 5x5 Area

25 available tiles remaining

Tiling a 5x5 Area

24 available tiles remaining

Tiling a 5x5 Area

22 available tiles remaining

Tiling a 5x5 Area

2 available tiles remaining