Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Ten Puzzling Problems in Computer Engineering: A Freshman Seminar Series, Study notes of Physics

A presentation slides from a ten-week, one-unit freshman seminar course at university of california, santa barbara, titled 'ten puzzling problems in computer engineering'. The slides cover various puzzling problems in computer engineering, their solutions, and the connection to ce problems. The course aims to keep students motivated during their first two years of taking basic courses by exposing them to interesting major-specific problems.

Typology: Study notes

Pre 2010

Uploaded on 09/17/2009

koofers-user-kpo
koofers-user-kpo 🇺🇸

10 documents

1 / 17

Toggle sidebar

Related documents


Partial preview of the text

Download Ten Puzzling Problems in Computer Engineering: A Freshman Seminar Series and more Study notes Physics in PDF only on Docsity! Apr. 2009 Easy, Hard, Impossible! Slide 1 Easy, Hard, Impossible! A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering Apr. 2009 Easy, Hard, Impossible! Slide 2 About This Presentation Edition Released Revised Revised First Apr. 2007 Apr. 2008 Apr. 2009 This presentation belongs to the lecture series entitled “Ten Puzzling Problems in Computer Engineering,” devised for a ten-week, one-unit, freshman seminar course by Behrooz Parhami, Professor of Computer Engineering at University of California, Santa Barbara. The material can be used freely in teaching and other educational settings. Unauthorized uses, including any use for financial gain, are prohibited. © Behrooz Parhami Apr. 2009 Easy, Hard, Impossible! Slide 5 Course Expectations and Resources Grading: Pass/Fail, by attendance and class participation 0 absence: Automatic “Pass” 1 absence: “Pass” is you submit a written explanation for the absence 2 absences: “Pass” if you had prior approval for your second absence or else had strong participation in class or out of class (via e-mail) 3 absences: Can earn a “Pass” by taking a final oral exam covering the missed lectures 4 or more absences: “Fail” Attendance slips distributed at the beginning of class and to those arriving no more than 10 minutes late. Complete and turn in at the end. Course website: http://www.ece.ucsb.edu/~parhami/ece_001.htm (PowerPoint and PDF presentations, addresses of relevant websites) Instructor’s office hours: T 2:00-3:30, R 10:00-11:30, HFH 5155 Apr. 2009 Easy, Hard, Impossible! Slide 6 Now, on to Today’s Topic of Discussion: Easy, Hard, Impossible Apr. 2009 Easy, Hard, Impossible! Slide 7 Easy: Euclid Sequences Form a sequence of number pairs (integers) as follows: Begin with any two positive numbers as the first pair In each step, the next number pair consists of (1) the smaller of the current pair of values, and (2) their difference Stop when the two numbers in the pair become equal Challenge: Repeat this process for a few more starting number pairs and see if you can discover something about how the final number pair is related to the starting values (10, 15) (10, 5) (5, 5) (9, 23) (9, 14) (9, 5) (5, 4) (4, 1) (1, 3) (1, 2) (1, 1) (22, 6) (6, 16) (6, 10) (6, 4) (4, 2) (2, 2) Why is the process outlined above guaranteed to end? Apr. 2009 Easy, Hard, Impossible! Slide 10 Easy, Not So Easy, Very Hard Euclid: Form a sequence of number pairs (integers) as follows: Begin with any two positive numbers as the first pair In each step, the next number pair consists of (1) the smaller of the current pair of values, and (2) their difference Stop when the two numbers in the pair become equal Collatz: Form a sequence of numbers (integers) as follows: Begin with a given number To find the next number in each step, halve the current number if it is even or triple it and add 1 if it is odd Fibonacci: Form a sequence of numbers (integers) as follows: Begin with any two numbers as the first two elements In each step, the next number is the sum of the last two numbers already in the sequence Stop when you have generated the j th number (j is given) Apr. 2009 Easy, Hard, Impossible! Slide 11 What Makes a Computational Problem Easy? Euclid: Form a sequence of number pairs (integers) as follows: Begin with any two positive numbers as the first pair In each step, the next number pair consists of (1) the smaller of the current pair of values, and (2) their difference Stop when the two numbers in the pair become equal Analysis: Number of steps in the worst case (1, n) (1, n – 1) (1, n – 2) . . . (1, 1) Algorithm: gcd(x , y), greatest common divisor of x and y If x = y, then output x and stop Otherwise, compute gcd(min(x, y), |x – y|) (n – 1 steps) When the number of steps is a polynomial function of the problem size, the problem is considered computationally easy or tractable The idea is that modern computers can perform many billions of computations per second, so even n2 or n5 steps may be manageable Apr. 2009 Easy, Hard, Impossible! Slide 12 Easy Problems: Degrees of Ease Consider the computation of x mod y (remainder of dividing x by y), where x and y are positive integers Analysis: Number of steps in the worst case (n, 1) (n – 1, 1) (n – 2, 1) . . . (0, 1) Algorithm: rem(x , y), remainder of dividing x by y If x < y, then output x and stop Otherwise, compute rem(x – y, y) (n steps) For example, if n ≈ 1016 (i.e., a 16-digit decimal number), and if each computation step takes 1 ns (10–9 s), then the execution time of this algorithm would be 1016/109 s = 107 s ≈ 2778 hr ≈ 116 days ≈ 4 mo Long division would yield the answer much quicker, in time that depends on the number of digits in n (i.e., log n) and not on n itself Computer scientists and engineers pursue more efficient algorithms Apr. 2009 Easy, Hard, Impossible! Slide 15 Getting a Handle on Difficult Problems Use the computer to experiment and find solutions for many instances; then, try to generalize from the results and patterns observed Diagrams from: Weisstein, Eric W., “Collatz Problem,” MathWorld (http://mathworld.wolfram.com/CollatzProblem.html) Number of steps for the Collatz sequence to reach 1, as a function of n In CE, the computer is both an object of study and a tool to help the study Apr. 2009 Easy, Hard, Impossible! Slide 16 Are Collatz Sequences Useful? Not directly, but they help us understand the nature of difficult problems Decision problem: Is there an algorithm to decide whether a given program computing f(n) will eventually stop for every input n? Program in question Decision Algorithm Yes/No Program: Collatz(n ), Collatz sequence for n Print n and set x := n While x > 1 repeat If x is even then x := x/2 else x := 3x + 1 In either case, print the new value of x Collatz’s conjecture is true Collatz’s conjecture is falseSuppose such a decision algorithm exists Apr. 2009 Easy, Hard, Impossible! Slide 17 Two Other Easy-Looking Hard Problems The subset sum problem: Given a set of n numbers, determine whether there is a subset whose sum is a given value x S = {3, –4, 32, –25, 6, 10, –9, 50} x = 22 Can’t do fundamentally better than simply trying all 2n subsets (exponential time, intractable for even moderately large n) The traveling salesperson problem: Given a set of n cities with known travel cost cij between cities i and j, find a path of least cost that would take a salesperson through all cities, returning to the starting city 5 2 1 2 1 3 4 5 1 3 34 In the worst case, must examine nearly all the (n– 1) ! cycles, which would require exponential time
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved