Your SlideShare is downloading. ×
0
Data Structures and Algorithms
Data Structures and Algorithms
Data Structures and Algorithms
Data Structures and Algorithms
Data Structures and Algorithms
Data Structures and Algorithms
Data Structures and Algorithms
Data Structures and Algorithms
Data Structures and Algorithms
Data Structures and Algorithms
Data Structures and Algorithms
Data Structures and Algorithms
Data Structures and Algorithms
Data Structures and Algorithms
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Data Structures and Algorithms

387

Published on

A guide to Data Structures and Algorithms

A guide to Data Structures and Algorithms

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
387
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Note: by the above definition, a “good” algorithm may still be unusable if it requires too much time/space to solve the problem (i.e. if the algorithm is intractable).
  • Transcript

    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

    ×