10 November 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.

Slides:



Advertisements
Similar presentations
Data structure is concerned with the various ways that data files can be organized and assembled. The structures of data files will strongly influence.
Advertisements

11 November 2014Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Chapter 4 : File Systems What is a file system?
Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Data Structures 3 Stewart Blakeway FML
Arrays. Memory organization Table at right shows 16 bytes, each consisting of 8 bits Each byte has an address, shown in the column to the left
Connecting with Computer Science, 2e
DISK STORAGE INDEX STRUCTURES FOR FILES Lecture 12.
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
Introduction to Data Structures. Data Structures A data structure is a scheme for organizing data in the memory of a computer. Some of the more commonly.
Introduction to Computer Systems
Review C++ exception handling mechanism Try-throw-catch block How does it work What is exception specification? What if a exception is not caught?
A Level Computing#BristolMet Session Objectives U2#S6 MUST identify different data types used in programming aka variable types SHOULD describe each data.
Chapter 8 Data Abstractions. 2 Chapter 8: Data Abstractions 8.1 Data Structure Fundamentals 8.2 Implementing Data Structures 8.3 A Short Case Study 8.4.
1 Data Abstractions Shyh-Kang Jeng Department of Electrical Engineering/ Graduate Institute of Communication Engineering National Taiwan University.
Chapter 8 Data Abstractions Introduction to CS 1 st Semester, 2015 Sanghyun Park.
25 November 2014Birkbeck College1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems
Computers Data Representation Chapter 3, SA. Data Representation and Processing Data and information processors must be able to: Recognize external data.
Chapter 8: Data Abstractions Senem Kumova Metin. 8-2 Chapter 8: Data Abstractions 8.1 Basic Data Structures – Arrays – Lists, Stacks, Queues – Trees 8.2.
Connecting with Computer Science, 2e Chapter 8 Data Structures.
Chapter 2 ARRAYS.
Lecture Contents Arrays and Vectors: Concepts of array. Memory index of array. Defining and Initializing an array. Processing an array. Parsing an array.
Data Strcutures.
6 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
6 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
1 Hash table. 2 Objective To learn: Hash function Linear probing Quadratic probing Chained hash table.
Overview of Course Java Review 1. This Course Covers, using Java Abstract data types Design, what you want them to do (OOD) Techniques, used in implementation.
Chapter 8 Data Abstractions. © 2005 Pearson Addison-Wesley. All rights reserved 8-2 Chapter 8: Data Abstractions 8.1 Data Structure Fundamentals 8.2 Implementing.
Data Structures and Algorithms Lecture 1 Instructor: Quratulain Date: 1 st Sep, 2009.
HASHING PROJECT 1. SEARCHING DATA STRUCTURES Consider a set of data with N data items stored in some data structure We must be able to insert, delete.
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.
29 September 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
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.
Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems
17 November 2015Birkbeck College1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems
20 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix.
20 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
13 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
1 String Processing CHP # 3. 2 Introduction Computer are frequently used for data processing, here we discuss primary application of computer today is.
3 November 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
17 November 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
1st December 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Department of Computer Science 1 Some Practice Let’s practice for the final a little bit. OK?
Circular linked list A circular linked list is a linear linked list accept that last element points to the first element.
24 November 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Data Structure & Algorithms
1 Data Structures and Algorithms Outline This topic will describe: –The concrete data structures that can be used to store information –The basic forms.
27 October 2015 Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
CHAPTER 51 LINKED LISTS. Introduction link list is a linear array collection of data elements called nodes, where the linear order is given by means of.
11 March 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
INTRODUCTION TO DATA STRUCTURES 1. DATA STRUCTURES A data structure is a scheme for organizing data in the memory of a computer. Some of the more commonly.
UNIT-V ABSTRACT DATA TYPE 1.LIST 2.STACK 3.QUEUE EC6301-II-ECE-C.
Introduction to Computer Systems
UNIT – I Linked Lists.
Introduction to Computer Systems
Chapter 11: File System Implementation
Data Structures Interview / VIVA Questions and Answers
Chapter 8: Data Abstractions
Chapter 11: File System Implementation
Disk storage Index structures for files
Chapter 11: File System Implementation
Chapter 8: Data Abstractions
CS148 Introduction to Programming II
Chapter 11: File System Implementation
CS148 Introduction to Programming II
Presentation transcript:

10 November 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems Autumn 2015 Week 7a: Pointers and Linked Lists

Review: Arrays An array is a block of values of the same type. Eg. A 2D array of size 10x November 2015Birkbeck College, U. London2

Review: Array Indexing There is a standard way of referring to the entries in an array. Eg. in Python: A[0], A[9], B[12,1]. In 2D arrays, the order of the indices is row then column. 10 November 2015Birkbeck College, U. London3

Three Dimensional Arrays If C is a 3D array of size 10x10x10, if each entry occupies one memory cell and if C[0,0,0] is stored at x, then C[i, j, k] is stored at x+100*i+10*j+k Thus C[2,5,1] is stored at x+100*2+10*5+1 = x November 2015Birkbeck College, U. London4

10 November 2015Brookshear, Sections 8.2 and 8.75 Pointers  A pointer is a storage area containing the address at which a piece of information is stored.  Example: the program counter in the CPU The programme counter points to memory cell 207 which contains the value 60. programme counter

10 November 2015Brookshear, Section 8.26 Why are Pointers Useful? Each pointer contains a relatively small number of bits. It is easier to move or copy pointers rather than move or copy the data they point to.

10 November 2015Birkbeck College, U. London7 Example: Sorting AZM AZM Array of pointers Data in memory Data in memory Sorted array of pointers

10 November 2015Brookshear, Section 8.28 Example: Alternative List … A Farewell to Arms Hemingway Pointer … For Whom the Bell Tolls Hemingway Pointer … The Sun Also Rises Hemingway Pointer …

10 November 2015Brookshear, Sections 8.1 and 8.39 Lists A list is a collection of data whose entries are arranged sequentially. Example of a list with 4 entries: addressphotodatetel. The entries vary widely in size.

10 November 2015Brookshear, Section Contiguous Storage of a List List entries are stored consecutively in memory Advantage: simple Disadvantage: insertion and deletion are difficult.

10 November 2015Brookshear, Section Linked Lists  Each list entry contains a pointer to the next entry  List entries can be stored in any part of memory.  There is a special head pointer for the first entry and a Nil pointer in the last entry.

10 November 2015Brookshear, Section Example of a Linked List photo86address7date87telNil Head

10 November 2015Brookshear, Section Deletion  Find the preceding list item f1 and the following list item f2. Set f1.pointer=f2 datapointer datapointer datapointer f1 f2 deleted entry new pointer old pointer

10 November 2015Brookshear, Section Insertion  to insert after a list item f1 set newEntry.pointer = f1.pointer f1.pointer = location of newEntry datapointer datapointer datapointer new pointer old pointer f1 newEntrynew pointer

10 November 2015Birkbeck College, U. London15 Pseudocode for Pointers Assign the value 4 to x: f1.x = 4 Point to the next item: f1.next = f2 pointer f1 variable xpointer next

10 November 2015Birkbeck College, U. London16 Printing a Linked List f = head(L); While (f<>nil) print(f.data); f = f.next; EndWhile

10 November 2015BB Ch. 8 Review Problems No. 717 Example 11C 12 13G 14 15E 16 17B 18 19U 20 21F 22 address contents The table represents the contents of some cells in memory, along with the address of each cell. Place addresses in the empty cells such that each cell containing a letter together with the following cell form an entry in a linked list in which the letters appear in alphabetical order. What address should the head pointer contain?

Example of a Tree 10 November 2015Birkbeck College, U. London18 S N VP V NP John hit DN the ball S: sentence NP: noun phrase VP: verb phrase N: noun V: verb D: determiner Colour: data Tree: hidden structure

Binary Tree Each node has the form 10 November 2015Brookshear, Sections 8.3, dataleft pointerright pointer A B C D

Binary Tree Stored in Memory A3339B36nilC D 10 November 2015Birkbeck College, U. London