programming in engineering

Upload: victor-miclovich

Post on 30-May-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 programming in engineering

    1/4

    Algorithms and Scientic Programming series:Lecture 2 Agenda 1 hour

    Victor Miclovich

    November 16, 2009

    Todays session might be our last this year... but the good thing is thatyou are all getting the hang of things and programming in Python. Learningto become good developers is the eventual goal of this program.These are things I shall expect from you after the holidays:

    1. Commitment ( there wont be room for sloppiness or reviews of previouswork early next year )

    2. Do all the assignments and readings that I shall still be sending you

    weekly3. Program! Meet S60 phone owners in this research group and do the

    programs in the book I left. This by the way is the lab experimentof this course. Because of our limited resources, we cant always havephones around... I prefer to use a real phone and not an emulator.What are the advantages of having a real phone?

    You will have real time analysis of output like messaging The audio API is nice on a real phone sockets libraries are used to connect to the Internet. I want you

    be able to take an image with using the camera api and be able tocreate services that can upload images either via a TCP stream or urllib module (this is part of the limited edition of PyS60

    If you still want to use the emulator go ahead... but trust me,the best experience is with a real phone. We shall use emulatorssometime in the future... Also, try to program your phone using a bluetooth console... you can send python les to your phone via bluetooth; install the les as python scripts Note: I mention python scripts not python lib modules...

    1

  • 8/14/2019 programming in engineering

    2/4

  • 8/14/2019 programming in engineering

    3/4

    Merge sort

    Asymptotic analysis

    1.2 Complexity

    Imagine a scenario where you have just come up with a recipe or algorithmto shorten an engineering process be it reduction in time of churning somecream in factory, or optimizing the way a circuit sends signals, etc.I remember telling of you some algorithms that we are to use and enhance

    synchronization algorithms (the phone keeps sending data to a databasebefore transferring it over a strong connection to a database/repository)

    Multi-modal transfers

    Packetization: breaking up large data into segments that are queuedup before transfers across packet/cellular networks while using a back-ground service to constantly check for cellular coverage

    These are all algorithms... we shall initially look at naive algorithms thenwork our way up to advanced algorithms. Why?Everything from the User interface in a phone to basic phone utilities/servicesin a development environment are all similar worldwide; we use known de-sign patterns and procedures in development, but what makes a product

    different from the rest? I think you can guess the answer: Its performance.Performance lies in the design of algorithms and their analysis.

    Application development steps in my sketchy way:

    1. Problem: everything in development starts with a problem that needsa solution

    2. Requirements engineering: the next logical step is to analyze that prob-lem which could involve lots of things from surveys, interviews, etc,then draft some kind of document... I think it is called a request for proposal or something like that

    3. Design an Information architecture: this is just like designing a user experience; the big question here is to look at the context where thisapplication will be used, and write up stories called user stories about how the experience should proceed.... ( isnt that an algorithm? )

    4. Build a prototype: building this also requires another analysis and re-quirements gathering stage... it is not wise to do every requirement gathering as a fast step... in my own opinion I prefer that you iter-atively gather requirements from your user and add features to every

    3

  • 8/14/2019 programming in engineering

    4/4

    stage of development or/and product... here you actually meet the tech

    needs... like what kind of networks is your app going to work on, how is it going to send data upstream 2 , how is the app going to use thephones resources to connect to a service, etc

    5. A step inside every other step: this is a crucial step... it happens in the previous steps too and designs its own bullet point :) Documen-tation is what makes the product... so within every step we document everything from our source to other scraps of paper we might be using

    6. The forever loop: every product isnt 100% efficient... we shall alwayskeep rening the existing application... and if the worst case is tocome, create it from scratch...

    7. Next step is... Go to step one!

    What is the complexity this section is about? This section is abouthow you determine the efficiency of an algorithm?Wow! Then what kind of efficiency are you talking about?: Well,the efficiency could mean speed at which something gets done, it couldmean how well limited resources are used (amount of CPU, memory anddisk usage).The whole deal is to know whether an algorithm does the right thing theright way when given an input.

    Generally, complexity is a measure of the amount of a particular resourcerequired to perform a given function.

    1.3 Big-O notation

    Complexity of an algorithm is dened in terms of the order of magnitude of the number of operations required to perform a function.

    0(1) denotes a function that runs in constant time

    O (n ) denotes a function that runs in linear time

    O(

    n 2

    ) denotes a function that runs in quadratic time O (log n ) denotes a function that runs in logarithmic time

    O (n log n ) denotes a function that runs in time proportional to thesize of the problem and the logarithmic time

    O (n !) denotes a function that runs in factorial time

    etc.

    2 this means sending data to a server

    4