Review & Lab assignments

Slides:



Advertisements
Similar presentations
Dynamic Allocation and Linked Lists. Dynamic memory allocation in C C uses the functions malloc() and free() to implement dynamic allocation. malloc is.
Advertisements

Stacks, Queues, and Linked Lists
Linked Lists.
Linked Lists CSE 2451 Matt Boggus. Dynamic memory reminder Allocate memory during run-time malloc() and calloc() – return a void pointer to memory or.
418115: II. Linked List A linked list can be thought of a chain of linked list elements. A linked list element contains a single data item, and contains.
Singly Linked List BTECH, EE KAZIRANGA UNIVERSITY.
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-5
Data Structure Lecture-3 Prepared by: Shipra Shukla Assistant Professor Kaziranga University.
Chapter 6 Structures By C. Shing ITEC Dept Radford University.
Advanced Data Structures Stack –a stack is dynamic data items in a linear order, such that the item first "pushed" in is the last item "popped" out. Think.
CS1061: C Programming Lecture 21: Dynamic Memory Allocation and Variations on struct A. O’Riordan, 2004, 2007 updated.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Data Structures.
CS113 Introduction to C Instructor: Ioannis A. Vetsikas Lecture 7 : September 8.
C How to Program, 6/e © by Pearson Education, Inc. All Rights Reserved.
Memory allocation CSE 2451 Matt Boggus. sizeof The sizeof unary operator will return the number of bytes reserved for a variable or data type. Determine:
Linked Lists in C and C++ By Ravi Prakash PGT(CS).
1 Chapter 6 Priority Queues (Heaps) General ideas of priority queues (Insert & DeleteMin) Efficient implementation of priority queue Uses of priority queues.
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.
 2006 Pearson Education, Inc. All rights reserved Data Structures.
Dynamic Allocation and Linked Lists. Dynamic memory allocation in C C uses the functions malloc() and free() to implement dynamic allocation. malloc is.
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
Complex Structures Nested Structures Self referential structures A structure may have Data variables Internal structures/unions Pointer links Function.
Chapter 12 Data Structure Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
CGS 3460 Pointer n To hold the location of another variable n Declaration: la type and a name with an asterisk lE.g. int *ptr; n Assigning a value lptr.
Reference: Vinu V Das, Principles of Data Structures using C and C++
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Custom Templatized Data Structures.
 2006 Pearson Education, Inc. All rights reserved Data Structures.
 2007 Pearson Education, Inc. All rights reserved C Data Structures.
Introduction to Data Structures Systems Programming.
17. ADVANCED USES OF POINTERS. Dynamic Storage Allocation Many programs require dynamic storage allocation: the ability to allocate storage as needed.
Lecture 14 Linked Lists 14-1 Richard Gesick. Linked Lists Dynamic data structures can grow and shrink at execution time. A linked list is a linear collection.
(1 - 1) Introduction to C Data Structures & Abstract Data Types Instructor - Andrew S. O’Fallon CptS 122 (August 26, 2015) Washington State University.
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.
Self-Referential Classes A Self-referential class is a class that contains a reference to an object that has the same class type. –A self-referential class.
Introduction to Data Structures Systems Programming Concepts.
Data Structures: Advanced Damian Gordon. Advanced Data Structure We’ll look at: – Linked Lists – Trees – Stacks – Queues.
1 Chapter 17 – Data Structures Outline Introduction Self-Referential Classes Dynamic Memory Allocation Linked Lists Stacks Queues Trees.
Programming Practice 3 - Dynamic Data Structure
C How to Program, 7/e © by Pearson Education, Inc. All Rights Reserved.
Data Structures. Abstract Data Type A collection of related data is known as an abstract data type (ADT) Data Structure = ADT + Collection of functions.
Complex Structures Nested Structures Self referential structures A structure may have Data variables Internal structures/unions Pointer links Function.
ENEE150 – 0102 ANDREW GOFFIN Dynamic Memory. Dynamic vs Static Allocation Dynamic  On the heap  Amount of memory chosen at runtime  Can change allocated.
Linked List. LINKED LIST Link is collection of similar type of elements. There are two ways of maintaining a list in memory. The first way is store the.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Linked Lists Outline Introduction Self-Referential Structures.
Data Structures - Prabir Sarkar. AGENDA Stack Queue Linked List Trees Graphs Searching and Sorting Algorithm.
Fig Storage of a C program. Fig Memory allocation with malloc.
STACKS & QUEUES for CLASS XII ( C++).
Chapter 12 – Data Structures
Dynamic Allocation Review Structure and list processing
5.13 Recursion Recursive functions Functions that call themselves
Linked Lists Chapter 6 Section 6.4 – 6.6
12 C Data Structures.
Review Deleting an Element from a Linked List Deletion involves:
12 C Data Structures.
Chapter 22 Custom Generic Data Structures
Data Structures and Algorithms
CISC181 Introduction to Computer Science Dr
Introduction to Data Structures
Chapter 16-2 Linked Structures
EENG 212 ALGORITHMS And DATA STRUCTURES
Data Structures and Algorithms
Chapter: 7-12 Final exam review.
Chapter 17: Linked Lists.
(1 - 2) Introduction to C Data Structures & Abstract Data Types
Comp 208 Computers in Engineering Yi Lin Fall, 2005
CS148 Introduction to Programming II
Linked Lists.
Presentation transcript:

Review & Lab assignments Lab guide #11 C Data Structures Review & Lab assignments

Key points Self-Referential Structure Dynamic Memory Allocation Dynamic data structures Linked lists Stacks Queues Trees

Self-Referential Structures Structure contains a pointer to a structure of the same type struct node { int data; struct node *nextPtr; } nextPtr Points to an object of type node Referred to as a link

Dynamic Memory Allocation malloc (): Obtain memory for a new structure Takes number of bytes to allocate Return a void * pointer or Null Example: newPtr = malloc( sizeof( struct node ) ); free (): Release memory Deallocates memory allocated by malloc Takes a pointer as an argument free ( newPtr );

Dynamic data structures Data structures that grow and shrink during execution Linked lists Allow insertions and removals anywhere Can be used when the number of data element is unpredictable Stacks Allow insertions and removals only at top of stack Rule: Last in first out Queues Allow insertions at the back and removals from the front Rule: First in, first out Binary trees High-speed searching and sorting of data and efficient elimination of duplicate data items

Lab assignments Fig 12.3 Fig 12.8 Fig 12.13 Fig 12.19