DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.

18
DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps

Transcript of DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.

Page 1: DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.

DATA STRUCTURES & C# GENERICS

Trent Spangler | Greg Phelps

Page 2: DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.

OUTLINE

Data Structures

• Importance

• Definition

• Examples

• Different Structure Types

• Uses

C# Generics

• Definition

• Pros & Cons

• In Depth

Page 3: DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.

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 Trent Spangler | Greg Phelps.

DATA STRUCTURES

“A particular way of storing and

organizing data.”

Page 5: DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.

Real-world Examples

Page 6: DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.

Structure Types

Array

Linked List

Sorted List

Trees

Hash Table

Queues & Stacks

Page 7: DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.

Arrays

“systematic arrangement of

objects, usually in rows and columns”

1, 2, and 3 Dimensional

Page 8: DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.

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 Trent Spangler | Greg Phelps.

Sorted List

Similar to Linked List

“Nodes” are sorted and are inserted accordingly

Page 11: DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.

Hash Table

Value = phone #

Key = Sandvig

Hash(Sandvig) 5

Hash(Gandalf) 5

Page 12: DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.

Queues & Stacks

Push: insert

Pop: extract

Peek: examine

Page 13: DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.

STACTIVITY

Page 14: DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.

GENERICSWhat are they?

Page 15: DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.

A simple definition:

“Generics allow you to define type-

safe data structures, without

committing to actual data types.”

Page 16: DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.

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 Trent Spangler | Greg Phelps.

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