KENDRIYA VIDYALAYA SANGATHAN (AGRA REGION)

Slides:



Advertisements
Similar presentations
LINKED LIST, STACKS AND QUEUES Saras M Srivastava, PGT – Comp. Sc. Kendriya Vidyalaya TengaValley.
Advertisements

CHP-5 LinkedList.
C Structures What is a structure? A structure is a collection of related variables. It may contain variables of many different data types---in contrast.
Data Structure Lecture-3 Prepared by: Shipra Shukla Assistant Professor Kaziranga University.
Dynamic Memory Allocation in C.  What is Memory What is Memory  Memory Allocation in C Memory Allocation in C  Difference b\w static memory allocation.
Ceng-112 Data Structures I Chapter 5 Queues.
WELCOME TO Linked List, Stack & Queue By VINAY ALEXANDER PGT COMPUTER SCIENCE) KV JHAGRAKHAND.
Computer Programming Link List (Insertion, Printing and Deletion functions) Lecture 23.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Data Structures.
More on Dynamic Memory Allocation Seokhee Jeon Department of Computer Engineering Kyung Hee University 1 Illustrations, examples, and text in the lecture.
Dynamic Memory Allocation in C++. Memory Segments in C++ Memory is divided in certain segments – Code Segment Stores application code – Data Segment Holds.
Chapter 12 C Data Structures Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
WELCOME TO Linked List, Stack & Queue By VINAY ALEXANDER PGT COMPUTER SCIENCE) KV JHAGRAKHAND.
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
Prof. amr Goneid, AUC1 CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 10. Pointers & Dynamic Data Structures.
Dynamic Memory Allocation. Domain A subset of the total domain name space. A domain represents a level of the hierarchy in the Domain Name Space, and.
Lists, Stacks and Queues in C Yang Zhengwei CSCI2100B Data Structures Tutorial 4.
Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix.
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
ENEE150 – 0102 ANDREW GOFFIN Dynamic Memory. Dynamic vs Static Allocation Dynamic  On the heap  Amount of memory chosen at runtime  Can change allocated.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To introduce the basic concepts of linked lists ❏ To introduce the basic concepts.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Linked Lists Outline Introduction Self-Referential Structures.
  A linked list is a collection of components called nodes  Every node (except the last one) contains the address of the next node  The address of.
STACKS & QUEUES for CLASS XII ( C++).
Data Structure By Amee Trivedi.
Chapter 12 – Data Structures
Dynamic Allocation Review Structure and list processing
5.13 Recursion Recursive functions Functions that call themselves
Stacks and Queues Chapter 4.
CSCI-255 LinkedList.
Lectures linked lists Chapter 6 of textbook
Program based on queue & their operations for an application
UNIT – I Linked Lists.
12 C Data Structures.
Data Structure Interview Question and Answers
12 C Data Structures.
Data Structure and Algorithms
Chapter 15 Lists Objectives
ENERGY 211 / CME 211 Lecture 25 November 17, 2008.
Linked lists.
ENERGY 211 / CME 211 Lecture 12 October 17, 2008.
Stack and Queue APURBO DATTA.
C++ Interlude 2 Pointers, Polymorphism, and Memory Allocation
Pointers Revisited What is variable address, name, value?
Introduction to Data Structures
Stack Lesson xx   This module shows you the basic elements of a type of linked list called a stack.
Dynamically Allocated Memory
Basic notes on pointers in C
CSC 253 Lecture 8.
Data Structures and Analysis (COMP 410)
STACK By:- Rajendra ShakyawalP.G.T. Computer Science KV-No.1, AFS, Tambaram, Chennai.
Chapter 15 Lists Objectives
DATA STRUCTURE QUEUE.
CSC 253 Lecture 8.
Lists, Strings & Multi-dimensional arrays
Further Data Structures
Dynamic Memory Allocation
LINKED LIST.
EENG 212 ALGORITHMS And DATA STRUCTURES
Review & Lab assignments
Chapter 17: Linked Lists.
CS148 Introduction to Programming II
RUN-TIME STORAGE Chuen-Liang Chen Department of Computer Science
Linked lists.
Pointers, Dynamic Data, and Reference Types
Run-time environments
Variable Storage Memory Locations (Logical) Variable Classes Stack
Arrays and Pointers.
Lecture 4 – Data collection List ADT
Presentation transcript:

KENDRIYA VIDYALAYA SANGATHAN (AGRA REGION) COMPUTER SCIENCE- XII DATA STRUCTURE IN C++ (LINKED LIST, STACK & QUEUE) 13-11-2018 VENUE: K V NO.2 AGRA CANTT, AGRA

DATA STRUCTURES:- LINKED LIST STACK QUEUE BY:- DEEPAK SHARMA PGT COMPUTER SCIENCE, KV2 AGRA

PRE KNOWLEDGE REQUIRED:- 1. C++ MEMORY MAP 2. TYPES OF MEMORY ALLOCATION 3. BASIC CONCEPTS OF POINTERS 4. IMPORTANCE OF DATA TYPES IN POINTERS 5. SELF REFENCIAL STRUCTURE

C++ MEMORY MAP THERE ARE FOUR REGIONS IN C++ MEMORY MAP (MEMORY MEANS MAIN MEMORY (RAM) 1. PROGRAM CODE 2. GLOBAL VARIABLE 3. STACK 4. HEAP

MEMORY ALLOCATION STATIC MEMORY ALLOCATION When the amount of memory to be allocated is known beforehand and the memory allocated during compile time itself, it is known as static memory allocation. For example:- int x; DYNAMIC MEMORY ALLOCATION:- When the amount of memory to be allocated is not known beforehand rather it is required to allocate memory as and when required during runtime. This type of memory allocation is known as dynamic memory allocation. C++ offers two operators for dynamic memory allocation: new 2. delete The memory allocated dynamically using new operator must be de- allocated by delete operator

Dynamic Memory Allocation:- General Form:- <data type> <pointer variable>= new <data type> for example:- int * x; x=new int; OR int * x=new int;

Importance of data type in pointers:- float x; // normal variable int *y; // pointer type variable Y=&x; float x 4 bytes Integer type pointer will access only two bytes from first byte. So there will be loss of information.

Self Referential Structure struct Node { Int info; Node * link; }; Node ob1; Node * Newptr; // wild pointer of type Node Newptr=new Node;

Ob1.info=5; Ob1.link=Null; Newptr info=5; Newptrlink=Null; Stack (LIFO) Data Structures Queue(FIFO) Array Linked List Array Linked List

BEGINNING √ INSERTION MIDDLE LINKED LIST DELETION MIDDLE END END √

INSERTION IN BEGINNING OF THE LINKED LIST START 1000 NEWPTR=7000 1000 3000 2000 4000

HOW TO CREATE NEW NODE DYNAMICALLY Node * NEWPTR; NEWPTR= new Node; NEWPTRinfo=17; NEWPTRLink=NULL; NEWPTR=7000 Link= NULL

Logic : If (START=NULL) START=NEWPTR; else { NEWPTRLink=START; } OR SAVE=START; NEWPTRLink=SAVE;

INSERTION IN END OF THE LINKED LIST START 1000 NEWPTR=7000 1000 3000 2000 4000

Logic:- If (START==NULL) START=REAR=NEWPTR; else { REARLink=NEWPTR; }

DELETION FROM THE BEGENINNG OF THE LINKED LIST START 1000 1000 3000 2000 4000

Logic:- If START=NULL PRINT UNDERFLOW; ELSE { TEMP=START; START=STARTLink; Delete TEMP; }

THANK YOU