Algorithm & data structures lec1

748 views

Published on

It covers the basic introduction of algorithms

Published in: Education, Technology, Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
748
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
16
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Algorithm & data structures lec1

  1. 1. Algorithm & Data Structures CSC-112Fall 2011<br />
  2. 2. My Profile<br />Name: <br />Syed Muhammad Raza<br />Education:<br />MSc Wireless Communication <br />LTH – Sweden , 2007-2009<br />BS Computer Information Sciences<br />PIEAS – Pakistan , 2002-2006<br />Contact Information:<br />Email: (Preferred mean of communication)<br />smraza@comsats.edu.pk<br />Cell #: (Only in case of emergencies)<br />0333-5577460<br />
  3. 3. Rules<br />Don’t Mess With Me<br />&<br />I Won’t Mess With You<br />
  4. 4. Course Overview<br />Fundamentals of Algorithms<br />Review of Programming <br />Sorting and Searching<br />Stacks<br />Queues, Priority Queues and Circular Queues<br />Linked List<br />Trees<br />Hashing<br />Graphs<br />
  5. 5. Text Book<br />No Text Book<br />&<br />Every Text Book<br />
  6. 6. Marks Distribution<br />Lab 25% of 100 Marks<br /> Theory 75% of 100 Marks<br /> <br />Sessional1 = 10 Marks<br />Sessional2 = 15 Marks <br /> Final Paper = 50 Marks<br /> Assignment = 15 Marks<br /> Quiz = 10 Marks<br /> Total = 100 Marks<br />
  7. 7. Lets see what you got!<br />
  8. 8. Algorithm<br />
  9. 9. Problem Solving<br />Problem solving is the process of transforming the description of a problem into the solution of that problem by using our knowledge of the problem domain and by relying on our ability to select and use appropriate problem-solving strategies, techniques, and tools.<br />
  10. 10. Algorithms<br />An Algorithm is a step by step solution to a problem<br />Why bother writing an algorithm<br />For your own use in the future - Don't have to rethink the problem.<br />So others can solve the problem, even if they know very little about the principles behind how the solution was derived.<br />
  11. 11. Examples of Algorithms<br />Washing machine instructions<br />Instructions for a ready-to-assemble piece of furniture<br />A Classic: GCD - Greatest Common Divisor - The Euclidean Algorithm<br />
  12. 12. Washing Machine Instructions<br />Separate clothes into white clothes and colored clothes.<br />For white clothes:<br />Set water temperature knob to HOT.<br />Place white laundry in tub.<br />For colored clothes:<br />Set water temperature knob to COLD<br />Place colored laundry in tub.<br />Add 1 cup of powdered laundry detergent to the tub.<br />Close lid and press the start button.<br />
  13. 13. Observations<br />There are a finite number of steps.<br />We are capable of doing each of the instructions.<br />When we have followed all of the steps, the washing machine will wash the clothes and then will stop.<br />Are all of the clothes clean ?<br />Do we want the washing machine to run until all of the clothes are clean ?<br />
  14. 14. Refinement of the Definition<br />Our old definition:<br />An algorithm is a step by step solution to a problem.<br />Adding our observations:<br />An algorithm is a finite set of executable instructions that directs a terminating activity.<br />
  15. 15. Instructions for a Ready-to-Assemble Furniture<br />"Align the marks on side A with the grooves on Part F “<br />Why are these instructions typically so hard to follow ?<br />Lack of proper tools - instructions are not executable<br />Which side is A ? A & B look alike. Both line up with Part F - Ambiguous instructions.<br />
  16. 16. Final Definition<br />An algorithm is a finite set of unambiguous, executable instructions that directs a terminating activity.<br />
  17. 17. History of Algorithms<br />The study of algorithms began as a subject in mathematics.<br />The search for algorithms was a significant activity of early mathematicians.<br />Goal: To find a single set of instructions that could be used to solve any problem of a particular type.<br />
  18. 18. GCD- Euclidean Algorithm<br />Assign M and N the value of the larger and the value of the smaller of the two positive integer input values, respectively.<br />Divide M by N and call the remainder R.<br />If R is not 0, then assign M the value of N, assign N the value of R and return to step 2, otherwise the greatest common divisor is the value currently assigned to N.<br />
  19. 19. Finding GCD of 24 & 9<br />M N R<br />24 9 6<br />9 6 3<br />6 3 0<br />So 3 is the GCD of 24 and 9.<br />Do we need to know the theory that Euclid used to come up with this algorithm in order to use it ?<br />What intelligence is required to find the GCD using this algorithm ?<br />
  20. 20. Idea Behind the Algorithms<br />Once an algorithm behind a task has been discovered<br />Don't need to understand the principles.<br />Task is reduced to following the instructions.<br />Intelligence is "encoded into the algorithm"<br />
  21. 21. Algorithm Representation<br />Syntax and Semantics<br />Syntax refers to the representation itself.<br />Semantics refers to the concept represented.<br />

×