set12 - 1 Data Structures Data Structures Last modified:...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Data Structures Data Structures Last modified: Jan. 2001 1998 Dr. M. Moussavi 2 Classification of data structures: Classification of data structures: Linear data structures Queues (FIFO) Stacks (LIFO) Linked lists singly linked list doubly linked list multiple list Last modified: Jan. 2001 1998 Dr. M. Moussavi 3 Classification of Data Structures Classification of Data Structures (Continued) (Continued) Hierarchical structures trees Graph structures Set structures3 Hashing Last modified: Jan. 2001 1998 Dr. M. Moussavi 4 Stack a Last in First out structure Stack a Last in First out structure Implementing a stack in an array: Data push 43 push 23 push 53 pop pop push 100 Last modified: Jan. 2001 1998 Dr. M. Moussavi 5 Stack a Last in First out structure Stack a Last in First out structure (Continued) (Continued) 1 4 2 3 1 4 2 3 43 1 4 2 3 23 43-1 Stack-Head Stack-Head 1 Stack-Head Push 23 Push 43 Start Last modified: Jan. 2001 1998 Dr. M. Moussavi 6 Stack a Last in First out structure Stack a Last in First out structure (Continued) (Continued) 1 4 2 3 23 43 53 2 Stack-Head 1 4 2 3 23 43 53 1 4 2 3 23 43 53 1 Stack-Head Stack-Head Push 53 Pop Pop 1 4 2 3 100 43 53 1 Stack-Head Push 100 Note: There will be an error if trying to push onto a stack which is full, or to pop from a stack which is empty (stack-Head == -1). Last modified: Jan. 2001 1998 Dr. M. Moussavi 7 Queues (FIFO) Queues (FIFO) Queues are an abstraction of such natural occurrences as ticket lines and store checkouts. Used in operating systems and multi programming I/Os. Enter at the end of the line, pass through the line one position at a time, and leave from the head of the line. Deletions are made from the head of the queue. Last modified: Jan. 2001 1998 Dr. M. Moussavi 8 Queues (FIFO) Queues (FIFO) Additions are made to the tail of the queue. Queues can be implemented with an array and two pointers (a Head pointer, and tail pointer). The head pointer points to the entry, which will be removed from the queue. The tail pointer points to the location where the next entry will be stored. Last modified: Jan. 2001 1998 Dr. M. Moussavi 9 OFFSET DATA 1 2 3 Head Pointer-1 Tail Pointer OFFSET DATA 1 2 3 A Head Pointer Tail Pointer 1 Add A to the Queue: OFFSET DATA 1 2 3 A B Head Pointer Tail Pointer 2 Add B to the Queue: OFFSET DATA 1 2 3 A B C Head Pointer Tail Pointer 3 Add C to the Queue: Queues (FIFO) Queues (FIFO) Queue is empty: Last modified: Jan. 2001 1998 Dr. M. Moussavi 10 OFFSET DATA 1 2 3 A B C Head Pointer 1 Tail Pointer 3 Delete from the Queue: Queues (FIFO) Queues (FIFO) Last modified: Jan. 2001 1998 Dr. M. Moussavi1998 Dr....
View Full Document

This note was uploaded on 07/10/2011 for the course ENEL 409 taught by Professor Moussavi during the Fall '11 term at University of Calgary.

Page1 / 42

set12 - 1 Data Structures Data Structures Last modified:...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online