









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This doc is DSA notes for IT students
Typology: Slides
1 / 17
This page cannot be seen from the preview
Don't miss anything!










1 05/21/
Learning Outcome 02 Understand the fundamentals of various common algorithms 2 05/21/
Algorithm 4 05/21/ An algorithm is a procedure having well defined steps for solving a particular problem. Algorithm is finite set of logic or instructions, written in order for accomplish the certain predefined task. It is not the complete program or code, it is just a solution (logic) of a problem, which can be represented either as an informal description using a Flowchart or Pseudo code.
Algorithm – problem solving 5
05/21/
Algorithm – problem solving 7 (^) Example 3: Determine whether a temperature is Below or Above the Freezing Point Algorithm: Step 1: Input temperature, Step 2: If it is less than 32, then print "below freezing point", otherwise print "above freezing point Step 3: Print output 05/21/
Algorithm – problem solving 8 Example 4: log in to Facebook account Algorithm: Step 1: Enter www.facebook.com in your browser. (I/O) Step 2: Facebook Home page loads (PROCESS) Step 3: Enter your Email ID and Password (I/O) Step 4: Is Email ID and Password Valid (DECISION) if NO then Log in error (PROCESS) go to step 3 else Display Facebook Account (I/O) Stop 05/21/
Miscellaneous problems solving 10
1. Do You Owe Me Money?
05/21/
Solution 11 05/21/ The questions would be, “Are you James?”(The goal is to find John, the one that owes you money?) If the person is James, he will answer “NO”(because he lies) If the person is John, he will say “Yes”(he owes you money and he lies) If the person is William, he will say “No”(he tells the truth) So, if the answer is “yes” you know that it is John and you can then demand your money. You have a 50% probability of knowing if it is James with this question.
Characteristics of an Algorithm 13 05/21/ An algorithm must follow the mentioned below characteristics: Input: An algorithm must have 0 or well defined inputs. Output: An algorithm must have 1 or well defined outputs, and should match with the desired output. Feasibility: An algorithm must be terminated after the finite number of steps. Independent: An algorithm must have step-by-step directions which is independent of any programming code. Unambiguous: An algorithm must be unambiguous and clear. Each of their steps and input/outputs must be clear and lead to only one meaning.
Performance of Algorithm The performance of algorithm is measured on the basis of following properties: i. Time complexity: It is a way of representing the amount of time needed by a program to run to the completion. ii. Space complexity: It is the amount of memory space required by an algorithm, during a course of its execution. Space complexity is required in situations when limited memory is available and for the multi user system. Each algorithm must have: iii. Specification: Description of the computational procedure. iv. Pre-conditions: The condition(s) on input. v. Body of the Algorithm: A sequence of clear and unambiguous instructions. vi. Post-conditions: The condition(s) on output. 14
Algorithms – contd. Commonly used algorithms include are useful for:
16
Next – Asymptotic Analysis 17 05/21/