Data structures.

Slides:



Advertisements
Similar presentations
Data Structure HKOI training /4/2010 So Pak Yeung.
Advertisements

Stack & Queues COP 3502.
Stacks  a data structure which stores data in a Last-in First-out manner (LIFO)  has a pointer called TOP  can be implemented by either Array or Linked.
Alford Academy Business Education and Computing1 Advanced Higher Computing Based on Heriot-Watt University Scholar Materials Stack and Queues.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 18 Stacks.
Copyright © 2012 Pearson Education, Inc. Chapter 18: Stacks And Queues.
Stack and Queue Dr. Bernard Chen Ph.D. University of Central Arkansas.
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Unit : Overview of Queues.
CS 106 Introduction to Computer Science I 12 / 06 / 2006 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 12 / 11 / 2006 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 10 / 26 / 2009 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 12 / 13 / 2006 Instructor: Michael Eckmann.
CHAPTER 05 Compiled by: Dr. Mohammad Omar Alhawarat Stacks & Queues.
Mastering STACKS AN INTRODUCTION TO STACKS Data Structures.
DATA STRUCTURE & ALGORITHMS CHAPTER 3: STACKS. 2 Objectives In this chapter, you will: Learn about stacks Examine various stack operations Discover stack.
Data Structures (part 2). Stacks An Everyday Example Your boss keeps bringing you important items to deal with and keeps saying: “Put that last ‘rush’
1 Stacks and Queues Based on D.S. Malik, Java Programming: Program Design Including Data Structures.
Data Structures: Advanced Damian Gordon. Advanced Data Structure We’ll look at: – Linked Lists – Trees – Stacks – Queues.
Stacks and Queues Based on D.S. Malik, Java Programming: Program Design Including Data Structures.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 18: Stacks and Queues (part 2)
Stacks And Queues Chapter 18.
Dynamic Data Structures Stacks, Queues and Binary Trees hold dynamic data.
3 Data. Software And Data Data Data element – a single, meaningful unit of data. Name Social Security Number Data structure – a set of related data elements.
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson Slides4-2.ppt Modification date: March 23, Procedures Essential ingredient of high level.
Chapter 16 – Data Structures and Recursion. Data Structures u Built-in –Array –struct u User developed –linked list –stack –queue –tree Lesson 16.1.
Advanced Higher Computing Science Stacks Queues and linked lists.
2005MEE Software Engineering Lecture 7 –Stacks, Queues.
© Oxford University Press All rights reserved. Data Structures Using C, 2e Reema Thareja.
Chapter 3 Lists, Stacks, Queues. Abstract Data Types A set of items – Just items, not data types, nothing related to programming code A set of operations.
30/09/20161 Data Structures Stacks and Queues. 230/09/2016 Learning Objectives Explain: The structures of stacks and queues. The concepts of: First In.
Stacks and Queues ● Introduction to stacks ● Stack implementation ● 4 Standard operations on a stack ● A stack program ● Introduction to queues ● Queue.
STACKS & QUEUES for CLASS XII ( C++).
Data Structures Using C++ 2E
Data Structures Using C, 2e
Queues.
G.PULLAIAH COLLEGE OF ENGINEERING AND TECHNOLOGY
Data Structure By Amee Trivedi.
Chapter 12 – Data Structures
Copy Constructor / Destructors Stacks and Queues
Program based on queue & their operations for an application
Data Structure Interview Question and Answers
Chapter 15 Lists Objectives
Dr. Bernard Chen Ph.D. University of Central Arkansas
Objectives In this lesson, you will learn to: Define stacks
Lectures Queues Chapter 8 of textbook 1. Concepts of queue
Stacks and Queues.
Introduction to Data Structures
In this lecture Global variables Local variables System stack
Introduction to Data Structures
Stack Lesson xx   This module shows you the basic elements of a type of linked list called a stack.
CMSC 341 Lecture 5 Stacks, Queues
Pointers and Linked Lists
Stacks, Queues, and Deques
DATA STRUCTURE QUEUE.
Introduction to Data Structures
Popping Items Off a Stack Lesson xx
Lesson Objectives Aims
Stacks and Queues CSE 373 Data Structures.
Stacks: Implemented using Linked Lists
Stack A data structure in which elements are inserted and removed only at one end (called the top). Enforces Last-In-First-Out (LIFO) Uses of Stacks Evaluating.
CSE 373 Data Structures Lecture 6
Chapter 8 Queues © 2006 Pearson Addison-Wesley. All rights reserved.
QUEUE Visit for more Learning Resources Free Powerpoint Templates.
Stacks and Queues Based on D.S. Malik, Java Programming: Program Design Including Data Structures.
17CS1102 DATA STRUCTURES © 2016 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS.
CSE 373 Data Structures Lecture 6
CSCS-200 Data Structure and Algorithms
Presented by : Aman Gupta PGT CS KV No.1, Narimedu, Madurai
LINEAR DATA STRUCTURES
DATA STRUCTURES IN PYTHON
Presentation transcript:

Data structures

D1 Data structures The features, applications and implications of data types used in computer systems: stack queue array list. The use and application of data types in computer software. The use and implications of data types in computer hardware.

Representation of Data as Bit Patterns – Data Structures – Linked-list A linked list is usually represented by the following diagram End Start Free Space Free End Data Address of next node Node

Representation of Data as Bit Patterns – Data Structures – Linked - list The Free Space is the available memory that the linked-list can grow into Data can be added and removed from any point A node contains two pieces of information Left the data Right the address of the next node

Representation of Data as Bit Patterns – Data Structures – Linked - list Adding and deleting from a linked-list involves changing the pointers to either incorporate a new node (adding) or redirecting to miss out an existing node (deleting) The new node will be added from the free space The deleted node will be added to the free space There are 3 possible positions that a node can be added or deleted Start of the list End of the list ‘Middle’ of the list

Representation of Data as Bit Patterns – Data Structures – Linked - list If the start of the list is be changed the initial start value needs to be altered to point to the new node If the end of the list is to be changed the new last node needs to be altered so it represents the end of the list Middle nodes have no particular problems

Representation of Data as Bit Patterns – Data Structures – Linked – list Given the following linked-list 1 B 2 F 3 M 4 End

Representation of Data as Bit Patterns – Data Structures – Linked – list The data “K” is to be added to the list 1 B 2 F 3 M 4 End

Representation of Data as Bit Patterns – Data Structures – Linked – list “K” is then added to the free space 1 B 2 F 3 M 4 End Free 5 K 6 7 End

Representation of Data as Bit Patterns – Data Structures – Linked – list The appropriate pointers need moving 1 B 2 F 3 M 4 End Free 5 K 6 7 End

Representation of Data as Bit Patterns – Data Structures – Linked – list Joining the previous node to “K” 1 B 2 F 5 M 4 End Free 5 K 6 7 End

Representation of Data as Bit Patterns – Data Structures – Linked – list Linking “K” to the next node 1 B 2 F 5 M 4 End Free 5 K 3 7 End

Representation of Data as Bit Patterns – Data Structures – Linked – list Recovering the free space 1 B 2 F 3 M 4 End Free 6 K 3 7 End

Representation of Data as Bit Patterns – Data Structures – Linked – list The ‘new’ linked-list 1 B 2 F 5 M 4 End Free 6 K 3 7 End

Representation of Data as Bit Patterns – Data Structures – Linked – list Given the following linked-list 1 B 2 F 3 M 4 End

Representation of Data as Bit Patterns – Data Structures – Linked – list “F” is to be deleted from the list 1 B 2 F 3 M 4 End

Representation of Data as Bit Patterns – Data Structures – Linked – list “F” should be added to the free-space 1 B 2 F 3 M 4 End Free 5 6 7 End

Representation of Data as Bit Patterns – Data Structures – Linked – list “Redirecting the pointers 1 B 2 F 3 M 4 End Free 5 6 7 End

Representation of Data as Bit Patterns – Data Structures – Linked – list Redirecting around “F” 1 B 3 F 3 M 4 End Free 5 6 7 End

Representation of Data as Bit Patterns – Data Structures – Linked – list Adding “F” to the free-space 1 B 3 F 3 M 4 End Free 2 6 7 End

Representation of Data as Bit Patterns – Data Structures – Linked – list Adding “F” to the free-space 1 B 3 F 5 M 4 End Free 2 6 7 End

Representation of Data as Bit Patterns – Data Structures – Linked – list The ‘new’ linked list 1 B 3 F 5 M 4 End Free 2 6 7 End

Representation of Data as Bit Patterns – Data Structures – Linked - list Uses for a linked-list are any situation that would require data to be inserted and deleted at any point – hence retaining the original order of the list

Stack A Stack is a Last In, First Out (LIFO) data structure (or FILO) Items can be added ‘PUSHED’ onto the stack. Items can be removed ‘POPPED’ from the stack It is a dynamic structure as the size of the stack grows depending on how many items are on it. It is controlled by ONE pointer

Stacks [6] [5] [4] [3] [2] [1] Katie Millie Joe Items can be pushed (add), Its can be popped (remove) Can only be added to the top of the Stack maxStackSize = 6 top =3

Stacks

Push/Pop Pseudocode Procedure Push If Top = MaxStackSize Then Write ‘Stack is full’ Else Add 1 to Top Stack[Top] := NewItem EndIf EndProc Procedure Pop If Top = 0 Then Write ‘Stack is empty’ Else PoppedItem := Stack[Top] Subtract 1 from Top EndIf EndProc

Uses of Stacks To store return addresses, parameters, and register contents when subroutines are called When sub routine is called, the return address is pushed onto the stack, until the sub has finished execution where it is then popped off. Undo and Redo functions Reverse Polish Notation

Queues

Queues A Queue is a First In, First Out (FIFO) data structure (or LILO) Data joins the queue at the rear. Data leaves the queue from the front It is a dynamic data structure. It is controlled by TWO pointers No data is added to a full queue. No data can be removed from an empty queue

Queue Declarations Frontpointer position of the first item Rearpointer position of the last item Max the maximum number allowed Numberinqueue number currently in the queue

Queues Fred Jack Matt Ben Front Rear queueSize=4 Add a new item (to the rear) Remove an item (from the front)

Uses of Queue Holding jobs waiting to be processed Spooling output to a disk prior to printing Both having the idea of dealing with tasks in the ‘first come, first served’ manner. It is the ‘fair’ approach.

STACKS AND QUEUES- RESEARCH EXPLAIN WHAT A STACK IS EXPLAIN WHAT A QUEUE IS COMPUTER APPLICATIONS STACKS COULD BE USED FOR COMPUTER APPLICATIONS QUEUES COULD BE USED FOR LABELED DIAGRAM OF STACK LABELED DIAGRAM OF QUEUE