5. list of instruction to achieve specific task. Program I/P instruction Processing instruction O/P instruction 2/24/2011 5
6. Programming Toolboxes H/W S/W Os Compiler Text editor Idea ware Algorithm DS Programming Methodologies Structure Design Oop S/W Concepts Information hiding Data encapsulation Data abstraction 2/24/2011 6
8. DS (Data Structure) Data :- factual information Structure :- Arrangement or relationship of elements as particles Data structure :-A means of storing a collection of data 2/24/2011 8
9. DS cont… A data structure can be viewed as consisting of a set of algorithms for performing operations on the data it stores. 2/24/2011 9
10. Variable:- data storage location that has a value that can change during program execution. Constant:- fixed value that can’t change. 2/24/2011 10
11. Applications of Data Structure DS Linear Non-Linear Sequential Linked Linked queues Graphs Tree Linked stacks linked lists queue array stack 2/24/2011 11
13. 1-Array Is a data structure where all elements are stored in contiguous memory n 2 1 0 Individual elements Array 2/24/2011 13
14. Random access Fixed size Less efficient used on data stored in array Array properties Array size Element size 1-in bytes 2-the number of element Data type of array 2/24/2011 14
16. 2-linked list Is a data structure in which the first element is (head) stored on its own Data List head / Dummy Node Null 2/24/2011 16
17. Linked list properties The size not fixed grow/shrink The extra space is needed to store the pointer of each element More time Implement linked list use array but not efficient Complex to code and manage 2/24/2011 17
18. Appending Node add Node to the end of the list. Traversing check the linked list. Inserting Node add Node in the middle of a list. Deleting Node from memory Modified links Destroy Operation on linked list 2/24/2011 18
19. Which is fast array or linked list? Why? 2/24/2011 19
20. Is a data structure consisting of data nodes connected to each other with pointers. Each node connected to 2 or more other nodes. 2/24/2011 20 5-Trees
21. The order of the tree:- is the max number of nodes to which any single node connected. binary tree:- is the simplest tree is of order 2. each child have two pointers. Root node:- the topmost node in the tree. leaf node:- node with no children. 2/24/2011 21 Tree properties
22. Data right left Data right left Data right left 2/24/2011 22
23. Create binary tree Inserting Node Traversing the tree recursion Searching the tree Deleting the tree 2/24/2011 23 Binary search tree op…
24. Logical sequence of steps describe complete solution to solve problem in finite amount of time May involve alternation, iteration or recursion More than one algorithm possible for the same task Algorithms 2/24/2011 24
26. What resources are required to accomplish the task How one algorithm compares with other algorithms How much time or space is required Measured in terms of common basic operations Efficiency of Algorithms 2/24/2011 26
27. Worst-case: (usually) T(n) = maximum time of algorithm on any input of size n. Average-case: (sometimes) T(n) = expected time of algorithm over all inputs of size n. Need assumption of statistical distribution of inputs. Best-case: (bogus) Cheat with a slow algorithm that works fast on some input. 2/24/2011 27 Kinds of analyses
28. Running time: On a particular input, it is the number of primitive operations (steps) executed. One line may take a different amount of time than another, but each execution of line i takes the same amount of time c . Running time of the algorithm is Ʃ (cost of statement)*(number of times statement is executed) 2/24/2011 28
29. How efficiency varies with the size of the task E.g. if the size of the task increases linearly, do the efficiency measures increase linearly, quadratically, exponentially,...? Expressed in terms of standard functions of n Complexity 2/24/2011 29
30. notations Big o Big Ɵ Big Ω F(n)=g(n) C1g(n)<=f(n)<=c2g(n) F(n)<=g(n) F(n)>=g(n) Data shape Ex - insertion sort best case Data method Ex – insertion sort worst case 2/24/2011 30
31. PseudoCodeconventions Indentation indicates block structure. While, for, repeat , if , then, and else. ▹indicates comment. indicates assignment. Variables are local by default. Array elements accessed as in A[i]. 2/24/2011 31
32. Calculate x^n, where n is an integer greater than 0. Algorithm 1. Set r = 1 2. Set i = 1 3. Repeat 3.1 If i=n then terminate loop 3.2 Multiply r by x 3.3 Add 1 to i 4. Exit with result r ExampleSimple Power Algorithm 2/24/2011 32
33. O(n) - the algorithm requires n multiplications. Time complexity 2/24/2011 33
34. Formulate a Concise Specification of the Problem Design a high-level strategy for a solution Refine steps 1 and 2 if necessary Complete the details of the design Implement in the chosen language How to Approach Recursive Algorithms 2/24/2011 34
35. Calculate x^n, where n is an integer greater than 0. Recursive Algorithm 1. If n=0 then 1.1 set r = 1 2. Else 2.1 set p = n/2 (dropping any remainder) 2.2 set r = (xp)2 2.3 if n is odd then 2.3.1 multiply r by x 3. Exit with result r Recursive Power Algorithm 2/24/2011 35
36. static int power (int x, int n) { int r; if (n == 0) r = 1; else { r = power(x,n/2); r = r*r; if (n%2 != 0) r *= x; } return r; } 2/24/2011 36 implementation
37. O(log n) - the algorithm requires approximately log n multiplications. 2 Time complexity 2/24/2011 37
49. SDLC (s/w Development life cycle) Design Problem analysis Maintenance Testing Requirement definitions Implementation Using program Delivery 2/24/2011 49