©Brooks/Cole, 2003 Chapter 11 Data Structures. ©Brooks/Cole, 2003 Data Structure Data structure uses collection of related variables that can be accessed.

Slides:



Advertisements
Similar presentations
Chapter 22 Implementing lists: linked implementations.
Advertisements

Lists CS 3358.
Linked Lists.
Data Structures: A Pseudocode Approach with C
DATA STRUCTURES USING C++ Chapter 5
11 Data Structures Foundations of Computer Science ã Cengage Learning.
CHP-5 LinkedList.
Data Structure Lecture-3 Prepared by: Shipra Shukla Assistant Professor Kaziranga University.
Chapter 12 Binary Search Trees
M180: Data Structures & Algorithms in Java
Foundation of Computing Systems Lecture 2 Linked Lists.
Chapter Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Data Structures: A Pseudocode Approach with C
Ceng-112 Data Structures I 1 Chapter 3 Linear Lists.
Linked Lists Compiled by Dr. Mohammad Alhawarat CHAPTER 04.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are crated using the class definition. Programming techniques.
©Brooks/Cole, 2003 Chapter 11 Data Structures. ©Brooks/Cole, 2003 Understand arrays and their usefulness. Understand records and the difference between.
©Brooks/Cole, 2001 Chapter 9 Pointers. ©Brooks/Cole, 2001 Figure 9-1.
Lecture - 1 on Data Structures. Prepared by, Jesmin Akhter, Lecturer, IIT,JU Data Type and Data Structure Data type Set of possible values for variables.
Data Structures & Algorithms
1 Problem Solving Abstraction Oftentimes, different real-world problems can be modeled using the same underlying idea Examples: Runtime storage, Undo operation.
©Brooks/Cole, 2001 Chapter 9 Pointers. ©Brooks/Cole, 2001 Figure 9-1.
©Brooks/Cole, 2001 Chapter 8 Arrays. ©Brooks/Cole, 2001 Figure 8-1.
©Brooks/Cole, 2001 Chapter 3 Structure of a C Program.
©Brooks/Cole, 2001 Chapter 10 Pointer Applications.
©Brooks/Cole, 2001 Chapter 11 Strings. ©Brooks/Cole, 2001 Figure 11-1.
Summary of lectures (1 to 11)
Linked Lists list elements are stored, in memory, in an arbitrary order explicit information (called a link) is used to go from one element to the next.
Variations of Linked Lists CS 308 – Data Structures.
©Brooks/Cole, 2001 Chapter 4 Functions. ©Brooks/Cole, 2001 Figure 4-1.
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the basic concepts and uses of arrays ❏ To be able to define C.
Linked Lists list elements are stored, in memory, in an arbitrary order explicit information (called a link) is used to go from one element to the next.
1 Chapter 16-1 Linked Structures Dale/Weems. 2 Chapter 16 Topics l Meaning of a Linked List l Meaning of a Dynamic Linked List l Traversal, Insertion.
Data Strcutures.
D ATA S TRUCTURE Ali Abdul Karem Habib MSc.IT. P OINTER A pointer is a variable which represents the location of a data item. We can have a pointer to.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
A first look an ADTs Solving a problem involves processing data, and an important part of the solution is the careful organization of the data In order.
Department of Computer Science Data Structures Using C++ 2E Chapter 5 Linked Lists.
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 17: Linked Lists.
Python Arrays. An array is a variable that stores a collection of things, like a list. For example a list of peoples names. We can access the different.
The List ADT A sequence of zero or more elements A 1, A 2, A 3, … A N-1 N: length of the list A 1 : first element A N-1 : last element A i : position i.
Chapter 11 Data Structures. Understand arrays and their usefulness. Understand records and the difference between an array and a record. Understand the.
CS2006- Data Structures I Chapter 5 Linked Lists III.
1. Circular Linked List In a circular linked list, the last node contains a pointer to the first node of the list. In a circular linked list,
1 Data Organization Example 1: Heap storage management –Keep track of free chunks of memory Example 2: A simple text editor –Maintain a sequence of lines.
Chapter Lists Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Department of Computer Science 1 Some Practice Let’s practice for the final a little bit. OK?
 Array is a data structure were elements are stored in consecutive memory location.in the array once the memory is allocated.it cannot be extend any more.
Circular linked list A circular linked list is a linear linked list accept that last element points to the first element.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the relationship between arrays and pointers ❏ To understand the.
1 M I DAABO COURSE CODE: CSC 355 COURSE TITLE: Data Structures.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To introduce the basic concepts of linked lists ❏ To introduce the basic concepts.
Linked list: a list of items (nodes), in which the order of the nodes is determined by the address, called the link, stored in each node C++ Programming:
Data Structure & Algorithms
Data Structure and Algorithm: CIT231 Lecture 6: Linked Lists DeSiaMorewww.desiamore.com/ifm1.
© Oxford University Press All rights reserved. Data Structures Using C, 2e Reema Thareja.
Data Structures: A Pseudocode Approach with C 1 Chapter 5 Objectives Upon completion you will be able to: Explain the design, use, and operation of a linear.
1 Data Organization Example 1: Heap storage management Maintain a sequence of free chunks of memory Find an appropriate chunk when allocation is requested.
CSCI-255 LinkedList.
Lectures linked lists Chapter 6 of textbook
UNIT – I Linked Lists.
Linked lists.
Lecture 22 Binary Search Trees Chapter 10 of textbook
Chapter 11 Data Structures.
Linked List and Selection Sort
Chapter 17: Linked Lists.
Chapter 11 Data Structures 1.
Linked lists.
Presentation transcript:

©Brooks/Cole, 2003 Chapter 11 Data Structures

©Brooks/Cole, 2003 Data Structure Data structure uses collection of related variables that can be accessed individually or as a whole. There are three types of data structures; 1.Array 2.Records 3.Linked List

©Brooks/Cole, 2003 ARRAYSARRAYS 11.1

Figure 11-1 Twenty individual variables

©Brooks/Cole, 2003 Figure 11-2 Processing individual variables Read 20 times Process 20 times Print 20 times Not efficient, you need a powerful data structure such as an array

©Brooks/Cole, 2003 Figure 11-3 Arrays with subscripts and indexes

©Brooks/Cole, 2003 Figure 11-4 Processing an array Loop Construct makes array processing easy Indexing is the method used to refer to the variable in the array.

©Brooks/Cole, 2003 Figure 11-5 Array Applications - Frequency Arrays

©Brooks/Cole, 2003 Figure 11-6 Histogram

©Brooks/Cole, 2003 Figure Part I Two-dimensional array

©Brooks/Cole, 2003 Figure 11-8 Memory layout Row-major?

©Brooks/Cole, 2003 Row-Major (methods for storing multidimensional arrays in linear m emory)

©Brooks/Cole, 2003 RECORDSRECORDS 11.2

Records A record is a collection of related elements having a single name. Each element is called a field. A field is the smallest element that has meaning. The difference between an array and a record is that all elements in an array can be of the same type however elements in records can be of different type. Data in a record should be related to one object.

©Brooks/Cole, 2003 Figure 11-9 Records

©Brooks/Cole, 2003 The elements in a record can be of the same or different types. But all elements in the record must be related. Note:

©Brooks/Cole, 2003 Accessing Individual Fields Read book P.220

©Brooks/Cole, 2003 LINKEDLISTSLINKEDLISTS 11.3

Inked List A linked list is an ordered collection of data in which each element contains the location of the next element. Each element contains two parts: data and link. The data part holds the useful information. The link part is used to chain data. It contains the pointer (address) that identify the next element. Pointer variable also identifies the first element in the list. Singly linked list contains one link to a single successor

©Brooks/Cole, 2003 Figure Linked lists Null pointer Pointer variable

©Brooks/Cole, 2003 Figure Node

©Brooks/Cole, 2003 Figure Inserting a node 1. Allocate memory for new node 2. New node points to its successor 3. Predecessor node points to new node

©Brooks/Cole, 2003 Figure Deleting a node Allocate the node to be deleted Make predecessor points to the node successor

©Brooks/Cole, 2003 Figure Traversing a list- changing the value, printing Walking pointer to move from a node to a node