Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

No Downloads

Total views

1,032

On SlideShare

0

From Embeds

0

Number of Embeds

2

Shares

0

Downloads

33

Comments

0

Likes

1

No embeds

No notes for slide

- 1. DATA STRUCTURES
- 2. Objectives At the end of the lesson, the student should be able to: Explain the process of problem solving Define data type, abstract data type and data structure Identify the properties of an algorithm Differentiate the two addressing methods – computed addressing and link addressing Use the basic mathematical functions to analyze algorithms Measure complexity of algorithms by expressing the efficiency in terms of time complexity and big-O notation
- 3. Problem Solving Process Programming – a problem-solving process which could be viewed in terms of the following domains: Problem domain ▪ input or the raw data to process ▪ output or the processed data ▪ E.g.: sorting of a set of numbers, ▪ raw data: set of numbers in the original order ▪ Processed data: sorted numbers Machine domain ▪ storage medium - consists of serially arranged bits that are addressable as a unit ▪ processing unit - allow us to perform basic operations(i.e. arithmetic, comparisons) Solution domain - links the problem and machine domains
- 4. Problem Solving Process Problem Domain
- 5. Problem Solving Process Machine Domain
- 6. Problem Solving Process Solution Domain
- 7. Problem Solving Process Two related tasks at the solution domain Structuring of higher level data representations Synthesis of algorithms NOTE: Data Structures and Algorithms are the building blocks of computer programs
- 8. Data Type, Abstract Data Type and Data Structure Data type - kind of data that variables can assume in a programming language and for which operations are automatically provided Abstract Data Type (ADT) - mathematical model with defined operations. In Java, an ADT can be expressed with an interface
- 9. Data Type, Abstract Data Type and Data Structure public interface Stack{ public int size(); /* returns the size of the stack */ public boolean isEmpty(); /* checks if empty */ public Object top() throws StackException; public Object pop() throws StackException; public void push(Object item) throws StackException; } Data structure – the implementation of ADT in terms of the data types or other data structures. In Java, a data structure can be expressed with a class
- 10. Algorithm Finite set of instructions which, if followed, will accomplish a task Finiteness - an algorithm must terminate after a finite number of steps Definiteness - ensured if every step of an algorithm is precisely defined Input - domain of the algorithm which could be zero or more quantities Output - set of one or more resulting quantities; also called the range of the algorithm Effectiveness - ensured if all the operations in the algorithm are sufficiently basic that they can, in principle, be done exactly and in finite time by a person using paper and pen
- 11. Addressing Methods Computed Addressing Method - used to access the elements of a structure in pre-allocated space int x[10][20]; a = x[4][3]; Link Addressing Method – used to manipulate dynamic structures where the size and shape are not known beforehand or changes at runtime class Node{ Object info; Node link; Node() { } Node (Object o, Node l){ info = o; link = l; } }
- 12. Addressing Methods Memory pool or avail list - source of the nodes from which linked structures are built class AvailList { Node head; AvailList(){ head = null; } AvailList(Node n){ head = n; } }
- 13. Addressing Methods Two basic procedures that manipulate the avail list are getNode and retNode, which requests for a node and returns a node respectively. Node getNode(){ Node a; if ( head == null) { return null; /* avail list is empty */ } else { a = head.link; /* assign node to return to a */ head = head.link.link; return a; } } void retNode(Node n){ n.link = head.link; /* adds the new node at the start of the avail list */ head.link = n; }
- 14. Mathematical Functions Floor of x ( ⎣ x ⎦ ) - greatest integer less than or equal to x, x is any real number e.g.: ⎣ 3.14 ⎦ = 3 ⎣ 1/2 ⎦ = 0 ⎣ -1/2 ⎦ = -1
- 15. Mathematical Functions Ceiling of x ( ⎡ x ⎤ ) - smallest integer greater than or equal to x, where x is any real number e.g.: ⎡ 3.14 ⎤ = 4 ⎡ 1/2 ⎤ = 1 ⎡ -1/2 ⎤ = 0
- 16. Mathematical Functions Modulo – remainder operator e.g.: 10 mod 3 = 1 24 mod 8 = 0 -5 mod 7 = -5
- 17. Mathematical Functions Identities ⎡ x ⎤ = ⎣ x ⎦ if and only if x is an integer ⎡ x ⎤ = ⎣ x ⎦ + 1 if and only if x is not an integer ⎣ - x ⎦ = - ⎡ x ⎤ ⎣ x ⎦ + ⎣ y ⎦ <= ⎣ x + y⎦ x = ⎣ x ⎦ + x mod 1 z ( x mod y ) = zx mod zy
- 18. Complexity of Algorithms Algorithm Efficiency Space utilization - amount of memory required to store the data Time efficiency - amount of time required to process the data ▪ Execution time - amount of time spent in executing instructions of a given algorithm. Notation: T(n). Several factors that affect the execution time include: ▪ input size ▪ Instruction type ▪ machine speed ▪ quality of source code of the algorithm implementation ▪ quality of the machine code generated from the source code by the compiler

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment