DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.

Slides:



Advertisements
Similar presentations
Stacks, Queues, and Linked Lists
Advertisements

Senem Kumova Metin Spring2009 STACKS AND QUEUES Chapter 10 in A Book on C.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
1 Chapter 24 Lists Stacks and Queues. 2 Objectives F To design list with interface and abstract class (§24.2). F To design and implement a dynamic list.
CS 206 Introduction to Computer Science II 10 / 26 / 2009 Instructor: Michael Eckmann.
Circular List Next field in the last node contains a pointer back to the first node rather than null pointer From any point in such a list it is possible.
1 Lecture 26 Abstract Data Types – IV Overview  The List ADT  Implementing Stacks as Linked List  Linked List Implementation of Queues .  Preview:
Computer Programming 2 Lecture 2: Advanced Array Data Structure Using Methods Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION & HIGHER.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 6 Introduction to classes and objects.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 15: Linked data structures.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 7 Decision Making : selection statements.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
1 Chapter 7 Stacks and Queues. 2 Stack ADT Recall that ADT is abstract data type, a set of data and a set of operations that act upon the data. In a stack,
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Computer Programming 2 Lecture 9: Object Oriented Programming Array Of Objects Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION &
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Computer Engineering Rabie A. Ramadan Lecture 6.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To introduce the basic concepts of linked lists ❏ To introduce the basic concepts.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 18 Recursion & Pointers in Java.
slides adapted from Marty Stepp and Hélène Martin
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Lecture 16 Stacks and Queues Richard Gesick. Sample test questions 1.Write a definition for a Node class that holds a number. 2.Write a method that sums.
Stacks II David Lillis School of Computer Science and Informatics
Presented By: Mahmoud Rafeek Alfarra
Chapter 15 Lists Objectives
Building Java Programs
Presented By: Mahmoud Rafeek Alfarra
Pointers and Linked Lists
Introduction To Programming Information Technology , 1’st Semester
Chapter 15 Lists Objectives
Data Structures and Database Applications Stacks in C#
Cs212: Data Structures Computer Science Department Lab 7: Stacks.
Building Java Programs
Building Java Programs
Array Based Collections
Presented By: Mahmoud Rafeek Alfarra
Lecture 7: Linked List Basics reading: 16.2
Introduction To Programming Information Technology , 1’st Semester
ADT list.
CSE 214 – Computer Science II Stacks
Building Java Programs
Review & Lab assignments
Introduction To Programming Information Technology , 1’st Semester
Presented By: Mahmoud Rafeek Alfarra
slides adapted from Marty Stepp and Hélène Martin
Building Java Programs
Building Java Programs
Mutable Data (define mylist (list 1 2 3)) (bind ((new (list 4)))
Presented By: Mahmoud Rafeek Alfarra
Introduction To Programming Information Technology , 1’st Semester
Lecture 16 Stacks and Queues CSE /26/2018.
Building Java Programs
Stacks LIFO C C B B B B A A A A A Push (A) Push (B) Push (C) Pop Pop.
slides created by Marty Stepp
Recall: stacks and queues
Building Java Programs
Lecture 7: Linked List Basics reading: 16.2
slides adapted from Marty Stepp
slides created by Marty Stepp
Lecture 16 Stacks and Queues CSE /26/2018.
Presented By: Mahmoud Rafeek Alfarra
Stack Implementations
slides created by Marty Stepp
slides created by Marty Stepp and Hélène Martin
Presentation transcript:

DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Information Technology, 3’rd Semester Lecture 10: Operations of Stack

Outline  Implementing the Push  Implementing the Pop  Implementing the Peek  Implementing the Clear  Implementing the Printall  Emank X Mezank !!

Implementing the Push operation  New nodes should be inserted at the front of the list, so that they become the top of the stack. 3 Presented & Prepared by: Mahmoud R. Alfarra Top

Pseudo code of the Push operation 3 Presented & Prepared by: Mahmoud R. Alfarra Create new object If top pointer points to null top = new new.next = null Else set the new.next = top top = new size++ index++

Implementing the Pop operation  The removed element should be removed from the back (Top) of the list. 3 Presented & Prepared by: Mahmoud R. Alfarra Top

Pseudo code of the Pop operation 3 Presented & Prepared by: Mahmoud R. Alfarra If top pointer points to null print (the stack is empty) Else top = top.next top = new Size-- Index--

Implementing the Peek operation  The retrieved element should be element of the back (Top) of the list. 3 Presented & Prepared by: Mahmoud R. Alfarra Top 617 Top.name Top.ID Top.data…

Pseudo code of the Peek operation 3 Presented & Prepared by: Mahmoud R. Alfarra If top pointer points to null print (the stack is empty) Else return top

Implementing the Clear operation  The clearing of stack means removing all the elements, which should be done set the top points to null. 3 Presented & Prepared by: Mahmoud R. Alfarra Top 617

Pseudo code of the clear operation 3 Presented & Prepared by: Mahmoud R. Alfarra If top pointer points to null print (the stack is empty) Else Top = null; index = -1; size = 0;

Implementing the Printall operation  The Print of all elements' data of the stack means that we have to create a new pointer points every time to the next element 3 Presented & Prepared by: Mahmoud R. Alfarra Top 617

Pseudo code of the Printall operation 3 Presented & Prepared by: Mahmoud R. Alfarra If top pointer points to null print (the stack is empty) Else create current pointer points to top for (current = top; current!= null ; current = current.next) print current.data Depending on your understanding of the printAll() operation, write a find method which search about a specific data. HW 10.1 Depending on your understanding of the printAll() operation, write a sort method which sorts the elements of the stack based on the name field. HW 10.2

Function of the PrintAll operation 3 Presented & Prepared by: Mahmoud R. Alfarra public void PrintAll() { Student current; string all = "name\tage\n"; if (Top == null) Console.WriteLine("The Stack is empty!!"); else { for (current = Top; current != null; current = current.next) all = all + current.name + "\t" + current.age + "\n"; } Console.WriteLine(all); }

Emank X Mezank !! أعظم أسبـاب النجاة اتقِ الله

Next Lecture Queue