computer engineering rabie a. ramadan lecture 6

48
Computer Engineering Rabie A. Ramadan [email protected] Lecture 6

Upload: barnard-short

Post on 18-Jan-2018

226 views

Category:

Documents


0 download

DESCRIPTION

Linear Lists A Linear List is a list in which each element has a unique successor. In a restricted linear list, addition and deletion of data are restricted to the ends of the list. In a general linear list, addition and deletion of data are allowed everywhere.

TRANSCRIPT

Page 1: Computer Engineering Rabie A. Ramadan Lecture 6

Computer Engineering

Rabie A. [email protected]

Lecture 6

Page 2: Computer Engineering Rabie A. Ramadan Lecture 6

STACKSSTACKS

Page 3: Computer Engineering Rabie A. Ramadan Lecture 6

Linear Lists

A Linear List is a list in which each element has a unique successor.

In a restricted linear list, addition and deletion of data are restricted to the ends of the list.

In a general linear list, addition and deletion of data are allowed everywhere.

Page 4: Computer Engineering Rabie A. Ramadan Lecture 6

StackStack

A stack is a linear list in which additions and deletions of data are restricted to one end, called the top.

If we insert a data series into a stack and then remove it, the order of data is reversed.

This property is known as the last in – first out.

Page 5: Computer Engineering Rabie A. Ramadan Lecture 6

StackStack

Page 6: Computer Engineering Rabie A. Ramadan Lecture 6

Stack AlgorithmsStack Algorithms

6

Create Push Pop Stack Top Empty Stack Full Stack Stack Count Destroy the stack

Page 7: Computer Engineering Rabie A. Ramadan Lecture 6

Push Stack Operation Push Stack Operation

Page 8: Computer Engineering Rabie A. Ramadan Lecture 6

Pop Stack Operation Pop Stack Operation

Page 9: Computer Engineering Rabie A. Ramadan Lecture 6

Stack Top Operation Stack Top Operation

Page 10: Computer Engineering Rabie A. Ramadan Lecture 6
Page 11: Computer Engineering Rabie A. Ramadan Lecture 6

Conceptual and Physical Stack Conceptual and Physical Stack Implementations Implementations

Page 12: Computer Engineering Rabie A. Ramadan Lecture 6

Stack Data Structure Stack Data Structure

Page 13: Computer Engineering Rabie A. Ramadan Lecture 6
Page 14: Computer Engineering Rabie A. Ramadan Lecture 6
Page 15: Computer Engineering Rabie A. Ramadan Lecture 6
Page 16: Computer Engineering Rabie A. Ramadan Lecture 6
Page 17: Computer Engineering Rabie A. Ramadan Lecture 6
Page 18: Computer Engineering Rabie A. Ramadan Lecture 6
Page 19: Computer Engineering Rabie A. Ramadan Lecture 6
Page 20: Computer Engineering Rabie A. Ramadan Lecture 6
Page 21: Computer Engineering Rabie A. Ramadan Lecture 6
Page 22: Computer Engineering Rabie A. Ramadan Lecture 6
Page 23: Computer Engineering Rabie A. Ramadan Lecture 6
Page 24: Computer Engineering Rabie A. Ramadan Lecture 6
Page 25: Computer Engineering Rabie A. Ramadan Lecture 6

Assignment :Implement all of the stack functions ? Use

the concept of classes

25

Page 26: Computer Engineering Rabie A. Ramadan Lecture 6

QUEUES

26

Page 27: Computer Engineering Rabie A. Ramadan Lecture 6

Definition

27

A queue is a linear list in which data can only be inserted at one end, called the rear, and deleted from the other end, called the front.

Hence, the data are processed through the queue in the order in which they are received (first in first out – FIFO)

Page 28: Computer Engineering Rabie A. Ramadan Lecture 6

28

Page 29: Computer Engineering Rabie A. Ramadan Lecture 6

29

Page 30: Computer Engineering Rabie A. Ramadan Lecture 6

30

Page 31: Computer Engineering Rabie A. Ramadan Lecture 6

31

Page 32: Computer Engineering Rabie A. Ramadan Lecture 6

32

Page 33: Computer Engineering Rabie A. Ramadan Lecture 6

33

(Continued)

Page 34: Computer Engineering Rabie A. Ramadan Lecture 6

34

Page 35: Computer Engineering Rabie A. Ramadan Lecture 6

35

Page 36: Computer Engineering Rabie A. Ramadan Lecture 6

36

Page 37: Computer Engineering Rabie A. Ramadan Lecture 6

37

(Continued)

Page 38: Computer Engineering Rabie A. Ramadan Lecture 6

38

Page 39: Computer Engineering Rabie A. Ramadan Lecture 6

39

Page 40: Computer Engineering Rabie A. Ramadan Lecture 6

40

Page 41: Computer Engineering Rabie A. Ramadan Lecture 6

41

Page 42: Computer Engineering Rabie A. Ramadan Lecture 6

42

Page 43: Computer Engineering Rabie A. Ramadan Lecture 6

43

Page 44: Computer Engineering Rabie A. Ramadan Lecture 6

44

Page 45: Computer Engineering Rabie A. Ramadan Lecture 6

45

Page 46: Computer Engineering Rabie A. Ramadan Lecture 6

46

Page 47: Computer Engineering Rabie A. Ramadan Lecture 6

47

Page 48: Computer Engineering Rabie A. Ramadan Lecture 6

48