DATA STRUCTURES & C # GENERICS
description
Transcript of DATA STRUCTURES & C # GENERICS
![Page 1: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/1.jpg)
DATA STRUCTURES & C# GENERICS
Trent Spangler | Greg Phelps
![Page 2: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/2.jpg)
OUTLINEData Structures• Importance• Definition• Examples• Different Structure Types• Uses
C# Generics• Definition• Pros & Cons• In Depth
![Page 3: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/3.jpg)
Why are data structures important?
• Store and manage large amounts of data efficiently• Databases• Sorting or Indexing Services.
• Search structures for information we want
![Page 4: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/4.jpg)
DATA STRUCTURES
“A particular way of storing and
organizing data.”
![Page 5: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/5.jpg)
Real-world Examples
![Page 6: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/6.jpg)
Structure Types
ArrayLinked ListSorted List
TreesHash Table
Queues & Stacks
![Page 7: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/7.jpg)
Arrays“systematic
arrangement of objects, usually in rows and
columns”
1, 2, and 3 Dimensional
![Page 8: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/8.jpg)
Linked List• Data stored in a “node” which means it contains
data and a reference to the next node in the sequence
• Advantage:• Easy insertion or deletion without reorganization
• Disadvantage:• Must search from the beginning because lists are
sequential/ordered
![Page 9: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/9.jpg)
Sorted ListSimilar to Linked List“Nodes” are sorted and are inserted accordingly
![Page 10: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/10.jpg)
TreesEach “node” has no more than two children, referred to as left and right.
Example
![Page 11: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/11.jpg)
Hash Table
Value = phone #Key = SandvigHash(Sandvig) 5Hash(Gandalf) 5
![Page 12: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/12.jpg)
Queues & Stacks
Push: insertPop: extractPeek: examine
![Page 13: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/13.jpg)
STACTIVITY
![Page 14: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/14.jpg)
GENERICSWhat are they?
![Page 15: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/15.jpg)
A simple definition:
“Generics allow you to define type-
safe data structures, without
committing to actual data types.”
![Page 16: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/16.jpg)
GenericsPros & Cons
• Pros• Code Reusability• Type Safety• Increased performance from
less code
• Cons• Complexity• Learning curve
Mainly used with collections/data
structures
![Page 17: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/17.jpg)
Generics In Depth
• Information is stored in objects instead of variables
• Note: You cannot implicitly convert type object to other data types (int, string, etc.)
DraculaExplanation
ofGenerics
![Page 18: DATA STRUCTURES & C # GENERICS](https://reader036.fdocuments.in/reader036/viewer/2022062310/56815fc0550346895dceba9b/html5/thumbnails/18.jpg)
REFERENCES • http://en.wikipedia.org/wiki/Data_structure
• http://en.wikipedia.org/wiki/Main_Page • http://
codersbarn.com/post/2008/04/09/What-are-C-Generics-Part-I.aspx