17
Universidade Federal da Paraíba Centro de Informática Introduction Lecture 1 1107186 – Estruturas de Dados Prof. Christian Azambuja Pagot CI / UFPB

Data Structures - 01. Introduction

Embed Size (px)

DESCRIPTION

Slide da cadeira de Estrutura de Dados, ministrado pelo Prof. Dr. Christian Pagot, na Universidade Federal da Paraíba.

Citation preview

Page 1: Data Structures - 01. Introduction

Universidade Federal da ParaíbaCentro de Informática

IntroductionLecture 1

1107186 – Estruturas de Dados

Prof. Christian Azambuja PagotCI / UFPB

Page 2: Data Structures - 01. Introduction

2Universidade Federal da ParaíbaCentro de Informática

What are Data Structures?

● “(...) a data structure is a way of storing and organizing data in a computer so that it can be used efficiently.”

Wikipedia

Page 3: Data Structures - 01. Introduction

3Universidade Federal da ParaíbaCentro de Informática

One Example

● Suppose the following set S of integer numbers:

2 1

4

614

10

5

9

11

3

15

7

8

12

13S =

How a computer could answer the following question:

Does S contains the integernumber 14?

Page 4: Data Structures - 01. Introduction

4Universidade Federal da ParaíbaCentro de Informática

Array-based Solution

● First, read the S elements into an array:

● Second, look for the value '14' looping over the array.

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Index

Value

int s[15];s[0] = 1; s[1] = 2; …s[14] = 15; 

C code excerpt:

Can it be done faster through the use of an alternate

data structure?14 steps to find the value!

Page 5: Data Structures - 01. Introduction

5Universidade Federal da ParaíbaCentro de Informática

Tree-based Solution

● First, read the S elements into a binary tree, according to the following rules: – Given a node, with a value V, the values of the

nodes of its left subtree are smaller than V while the values of the nodes of its right subtree are greater then V.

Page 6: Data Structures - 01. Introduction

6Universidade Federal da ParaíbaCentro de Informática

Tree-based Solution

8

4

2

1 3 5 7 9 11 13 15

106 14

12

2 14

614

10

59

113

15

7

812

13S =

3 steps to find the value!!!

Can it be done faster through the use of an alternate

data structure?

Page 7: Data Structures - 01. Introduction

7Universidade Federal da ParaíbaCentro de Informática

Hash-like-based Solution

● First, set the S elements in an array:

● Second, look for the value '14' computing the hash value (value-1 = 13) and checking the flag at this position.

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

T T T T T T T T T T T T T T T F F F F F

Index (=Value-1)

ExistenceFlag

bool s[20];s[0] = true; s[1] = true; …s[19] = false; 

C code excerpt:

1 step to find the value!!!!!!!

Page 8: Data Structures - 01. Introduction

8Universidade Federal da ParaíbaCentro de Informática

Course Outline

● C programming language.● Data types. ● Memory allocation.● Linked lists.● Stacks, queues and deques.● Dictionaries ans hash tables.● Asymptotic analysis.● Recursion.● Trees.● Graphs.

Page 9: Data Structures - 01. Introduction

9Universidade Federal da ParaíbaCentro de Informática

Background

● Algorithms:– Simple variables.

– Structured variables.

– Functions.

– Parameters (by value, by reference).

● C programming skills:– General syntax.

– Compiling.

– Debugging.

Page 10: Data Structures - 01. Introduction

10Universidade Federal da ParaíbaCentro de Informática

To pass this course...

● Attend classes regularly and participate.● Understand the concepts.● Do the assignments.● Do the exams.

Page 11: Data Structures - 01. Introduction

11Universidade Federal da ParaíbaCentro de Informática

To fail this course...

● Do not attend classes regularly and/or do not participate.

● Avoid understanding the concepts.● Don't do, or cheat, the assignments.● Don't do, or cheat, the exams.

Page 12: Data Structures - 01. Introduction

12Universidade Federal da ParaíbaCentro de Informática

Grading Policy

NF1=( ( P1+P2 )

2×0.60)+( (T1+T2+⋯+Tn )

n×0.40)

● NF1 = Final grade.● P1 = Exam 1.● P2 = Exam 2.● T1, T2, …, Tn = Assigments.

Page 13: Data Structures - 01. Introduction

13Universidade Federal da ParaíbaCentro de Informática

Bibliography

● Weiss, M. A. Data Structures and Problem Solving Using Java. Addison Wesley, 1998.

● Tenembaum, A. M.; Langsam, Y.; Augenstein, M. J. Estruturas de Dados usando C. McGraw-Hill.

● Szwarcfiter, J. L. e Markenzon, L. Estruturas de Dados e seus Algoritmos. LTC – Livros Técnicos e Científicos Ed., 1994.

● Tremblay, J. e Sorenson, P. G. An Introduction to Data Structures with Applications. McGraw-Hill, 1987.

Page 14: Data Structures - 01. Introduction

14Universidade Federal da ParaíbaCentro de Informática

Useful Tools

● A (Text editor + C compiler) or IDE:– DevC++.

– Code::Blocks.

– Vi + gcc.

– Eclipse + C compiler.

– Microsoft Visual C++.

– Etc.

Page 15: Data Structures - 01. Introduction

15Universidade Federal da ParaíbaCentro de Informática

Classroom Policy

● Participate every lecture.● Focus on the lessons. ● Disconnect from the whole world for a while.

– Mute/turn off cell phones.

– Don't use social networks, messengers, and anything else strictly related to the class.

● Willing to ask and answer questions.

Page 16: Data Structures - 01. Introduction

16Universidade Federal da ParaíbaCentro de Informática

Our Website

● All relevant stuff will be available in our Moodle page at UFPB Virtual: – http://portal.virtual.ufpb.br

The student is responsible forkeeping his data up to date

in the Moodle system!

Page 17: Data Structures - 01. Introduction

17Universidade Federal da ParaíbaCentro de Informática

Next class...

● Review of the C programming language.

http://themanfromporlock.blogspot.com.br