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.

Successfully reported this slideshow.

Like this presentation? Why not share!

590 views

Published on

A guide to Data Structures and Algorithms

No Downloads

Total views

590

On SlideShare

0

From Embeds

0

Number of Embeds

3

Shares

0

Downloads

0

Comments

0

Likes

1

No embeds

No notes for slide

- 1. Data Structures and AlgorithmsSnehal Masnewww.TechProceed.comwww.iSnehal.com
- 2. 2learn ...... how to design “good” algorithms and datastructures... how to evaluate the performance of algorithms... how to program basic algorithms and datastructuresGoals
- 3. 3learn ...... how to solve the most common algorithmicproblems, such assearching a data collectionsorting dataexploring a graph/networktext processingGoals
- 4. 4Michael T. Goodrich, Roberto Tamassia:Algorithm Design: Foundations, Analysis,and Internet Examples.John Wiley & Sons, Inc., 2001.Mark Allen Weiss:Data Structures and Algorithm Analysisin Java.2nd edition, Addision Wesley, 2007.Literature
- 5. 5Thomas H. Cormen, Charles E. Leiserson,Ronald L. Rivest, Clifford Stein:Introduction to Algorithms.3rd edition, The MIT Press, 2009.Donald E. Knuth:The Art of Computer Programming.Vol. 1: Fundamental Algorithms.Vol. 3: Sorting and Searching.Addision Wesley, 1997/98.Literature
- 6. 6• an algorithm is a step-by-step procedure forsolving a problem in a finite amount of time andspace• an algorithm is “good” if it is correct and solves theproblem in lowest time/space known for thatproblemAlgorithmsInput Algorithm Output
- 7. 7• a program is a description of an algorithm in aprogramming language• a program repesents exactly one algorithm• an algorithm represents a multitude of programs• writing a good program requires designing a goodalgorithmNo algorithm, no program!Programs
- 8. 8Problem – Algorithm - ProgramProblemAlgorithm 1 Algorithm 2Program 21Program 22. . .. . .. . .. . .. . .
- 9. 9[ 1] int mod(int a, int b) {[ 2] /* Requirements (input): a: a>=0; b: b>0 */[ 3] /* Guarantee (output): r: a=t*b + r and 0<r<=b */[ 4] /* (1) Declaration */[ 5] int r;[ 6] /* (2) Initialization */[ 7] r=a;[ 8] /* (3) Iteration start */[ 9] while (r>=b) {[10] /* (4) Problem reduction */[11] r=r-b;[12] /* (5) Iteration end */[13] }[14] /* (6) Output formation */[15] return(r);[16] }Iteration
- 10. 10[ 1] int mod(int a, int b) {[ 2] /* Requirements (input): a: a>=0; b: b>0 */[ 3] /* Guarantee (output): r: a=t*b + r and 0<r<=b */[ 4] /* (1) Declaration */[ 5] int r;[ 6] /* (2) Initialization */[ 7] r=a;[ 8] /* (3) Trivial case */[ 9] if (r<b) return(r);[10] /* (4) Problem reduction */[11] r=r-b;[12] /* (5) Recursion step */[13] return(mod(r,b));[14] }Recursion
- 11. 11• elementary types (in Java):–logical type: boolean–integer type: int, short, byte, long–floating point type: float, double–character type: char• composed data types (concrete data structures):–arrays, e.g., int[], char[]–records/structs (not available in Java)–listsData Types
- 12. 12• an abstract data type (ADT) is an abstraction of aconcrete data structure• an ADT specifies:–data stored (auxiliary data, inclusive)–operations on the data–error conditions associated with operations• an ADT abstracts from the implementation of thedata and operationsAbstract Data Types
- 13. 13• a class is an ADT implementation in an OOPL• an instance of an ADT (or a class) has anoperational life span, during which a state (anelement of the ADT„s data set) is always beingassigned to the object• methods of an ADT are programs manipulating thestate of an object• a state of an object can only be manipulated byADT methods (encapsulation)Objects
- 14. 14• ADT modeling a simple stock trading system• the data stored are buy/sell orders• the operations supported are:–Order buy(Stock st, Shares sh, Price p)–Order sell(Stock st, Shares sh, Price p)–void cancel(Order)• error conditions are:–buy/sell a nonexistent stock–cancel a nonexistent orderExample of an Abstract Data Type

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