Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Week 12: Data Structures 1 Stewart Blakeway FML 213

Slides:



Advertisements
Similar presentations
Months of the year December January November October February
Advertisements

Learn all about the year.
PROGRAMMING LANGUAGE (JAVA) UNIT 42 BY ROBERT BUTTERFIELD TELEPHONE Data Structures and Algorithms.
Databases Using Information. What is a Database? A database package allows the user to organise and store information. This information can be sorted,
ICDL Software Applications - Database Concepts. Unit 6 Data and Data Representation Database Concepts –File Structure –Relationships Database Design –Data.
Overview of Data Structures and Algorithms
Programming Logic and Design Sixth Edition
Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Week 5: Steps in Problem Solving Stewart Blakeway FML 213
Chubaka Producciones Presenta :.
The Months and The Seasons Prepared by Claudia Doria and Terra Myers.
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.
Faculty of Sciences and Social Sciences HOPE Variables and Trace Tables Stewart Blakeway FML 213
Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Week 8: Java: Selection and Repetition Stewart Blakeway.
Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Week 6: Problem Solving Exercises Stewart Blakeway FML.
Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Week 7: Java basics Stewart Blakeway
Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Data Structures 3 Stewart Blakeway FML
Faculty of Sciences and Social Sciences HOPE Data Structures 2 Stewart Blakeway
Faculty of Sciences and Social Sciences HOPE Java: Loops within loops Stewart Blakeway FML 213
2012 CALENDAR. JANUARY 2012 Sunday 日 Monday 月 Tuesday 火 Wednesday 水 Thursday 木 Friday 金 Saturday 土
Faculty of Sciences and Social Sciences HOPE Structured Problem Solving An Introduction Stewart Blakeway
2012 JANUARY Sun Mon Tue Wed Thu Fri Sat
January 2012 Monday Tuesday Wednesday Thursday Friday Sat/ Sun / /8 14/15 21/22 28/
CS1061 C Programming Lecture 14: Strings A. O’Riordan, 2004.
Computing Concepts Searching and Sorting. What we have done so far in data structures data structure as a way of organising the storage of data brief.
CS100J 17 March 2005 Arrays. Reading: Secs 8.1, 8.2, 8.3. The last Java feature to study in this course Quote for the Day: Computer science has its field.
Chapter 1 Program Design
1 CS100J 25 October 2006 Arrays. Reading: Secs 8.1, 8.2, 8.3. Listen to the following lectures on loops on your Plive CD. They are only 2-3 minutes long,
MONDAYTUESDAYWEDNESDAYTHURSDAYFRIDAYSATURDAYSUNDAY WEEK WEEK WEEK WEEK WEEK CALENDAR PROJECT.
MATHEMATICS Time – Dates, Calendars and Timetables.
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
Using Object-Oriented JavaScript CST 200- JavaScript 4 –
Introduction CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
Copyright © Wondershare Software Introduction to Data Structures Prepared by: Eng. Ahmed & Mohamed Taha.
What day is today? What`s the date?. Sunday Monday Tuesday Wednesday Thursday Friday Saturday What day is today?
Introduction to Data Structures. Definition Data structure is representation of the logical relationship existing between individual elements of data.
Introduction. 2COMPSCI Computer Science Fundamentals.
VOCABULARY Vacation Review May HFW List 1 Pronounce the following words: things always day become nothing stays everything.
Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie desJardins University of Maryland, Baltimore County.
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 5 Arrays.
Structures in C++ UNIVERSITY OF THE PUNJAB (GUJRANWALA CAMPUS) 1 ADNAN BABAR MT14028 CR.
Lists CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Data Structures and Algorithms Lecture 1 Instructor: Quratulain Date: 1 st Sep, 2009.
WORD JUMBLE. Months of the year Word in jumbled form e r r f b u y a Word in jumbled form e r r f b u y a february Click for the answer Next Question.
1 On (computational) simplicity We are trying to teach not just Java, but how to think about problem solving. Computer science has its field called computational.
DATE POWER 2 INCOME JANUARY 100member X 25.00P2, FEBRUARY 200member X 25.00P5, MARCH 400member X 25.00P10, APRIL 800member.
Chapter 2 Sets and Functions Section 2.1 Sets. A set is a particular type of mathematical idea that is used to categorize or group different collections.
By Monica Hilgemann Second Grade Teacher
Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Week 3: Algorithms Stewart Blakeway FML 213
2011 Calendar Important Dates/Events/Homework. SunSatFriThursWedTuesMon January
Perl Tutorial - 2 林光龍. Memory Address (1/2) A number that is assigned to each byte in a computer’s memory that the CPU uses to track where data and instructions.
Data Structure and Algorithms
VOCABULARY Vacation Review May HFW List 1 Read aloud the following words: things always day become nothing stays everything.
JavaScript and Ajax (JavaScript Arrays) Week 5 Web site:
Fall Weather Unit Your Fall Weather Update! By: Reporter ____________.
The Calendar.
July 2007 SundayMondayTuesdayWednesdayThursdayFridaySaturday
1 CS Oct 2008 Arrays. Reading: Secs 8.1, 8.2, 8.3 Listen to the following lectures on loops on your Plive CD. They are only 2-3 minutes long, and.
Course Developer/Writer: A. J. Ikuomola
Practical Office 2007 Chapter 10
Introduction to Data Structures
Programming We have seen various examples of programming languages
Introduction to Data Structure
Teacher name August phone: Enter text here.
The ultimate in data organization
2015 January February March April May June July August September
Introduction to Computer Science
Presentation transcript:

Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Week 12: Data Structures 1 Stewart Blakeway FML

Faculty of Sciences and Social Sciences HOPE What we have done already Seen what an algorithm is – a set of instructions that, if carried out, will lead to a successful conclusion Learned how to represent algorithms in – Structured English – Flow charts Used variables to remember 2

Faculty of Sciences and Social Sciences HOPE What we have done already Applied the top down, stepwise refinement approach to creating algorithms Looked at problems more oriented towards being solved on a computer – stacks, queues, functions, procedures Seen how high level languages like Java are used to create programs with the aid of compilers The problem solving constructs in Java Nested for loops Used and manipulated strings of characters 3

Faculty of Sciences and Social Sciences HOPE What we shall do in this part of the course – next three weeks Concept of a data structure Examples of data structures – records – arrays – sequences (lists, queues, stacks) 4

Faculty of Sciences and Social Sciences HOPE Aims of the Presentation To look at the definition of various data structures To focus on arrays and records 5

Faculty of Sciences and Social Sciences HOPE Why data structures? We use variables to remember data If we have lots of things to remember we need to organise them (“structure” them) in some way Examples – list of jobs – shopping list – a diary – record cards for a quiz league 6

Faculty of Sciences and Social Sciences HOPE An example of a data structure Set of record cards containing quiz league details 7

Faculty of Sciences and Social Sciences HOPE Where is the structure in this? The information is organised in a logical way – One card for each team – Same 5 pieces of information for each team – Each piece of information made up of words and numbers – Each word made up of letters – Each number made up of digits 8

Faculty of Sciences and Social Sciences HOPE A question The simplest level of data structure in the English Football League is the player. What levels of data structure can you identify? – individual players – players forming a team – teams forming a division – divisions forming the Football League 9

Faculty of Sciences and Social Sciences HOPE Important point There is a difference between a data structure and the data stored in it In the quiz team example the data structure is: – Box for the cards – Blank cards 10

Faculty of Sciences and Social Sciences HOPE Data types Each part of the card holds a particular type of information 11 Black Arrows The Red LionWest Road, Bolton Monday type nametype address type telephone number type home night

Faculty of Sciences and Social Sciences HOPE Types of Data structures What we have already seen – sequences (queues and stacks) – Scalar data structures (variables) What we will see – records – arrays (including tables) – sequences (lists) – trees 12

Faculty of Sciences and Social Sciences HOPE Record A collection of different data types describing a person or thing – E.g. name, address, telephone number held in a record describing a person – E.g. name, description, unit price, quantity in stock in a record describing a product for sale A record is the only data structure that is a collection of different data types Normally requires a database to implement this structure We can also use multi-dimensional arrays with a little tweaking 13

Faculty of Sciences and Social Sciences HOPE Record structure Each piece of information is called a field For each field we need to know: – its identifier or label – the type of information it can contain No two fields can have the same name The order of the fields is important 14

Faculty of Sciences and Social Sciences HOPE Arrays and tables 15 e.g. array holding names of days of the week 0Sunday 1Monday 2Tuesday 3Wednesday 4Thursday 5Friday 6Saturday If the number of items to be collected in a data structure is fixed and the items are of the same type then an array may be used.

Faculty of Sciences and Social Sciences HOPE Arrays and tables If each item is a record then the array is known as a table 16 0January31 1February28 2March31 3April30 4May31 5June30 6July31 7August31 8September30 9October31 10November30 11December31 Each record has two data types: Name of month Number of days in month (non-leap year)

Faculty of Sciences and Social Sciences HOPE Power of arrays Information can be found quickly in arrays E.g. searching ten million records for owner of a car with a given registration number – Searching covered next week! Requires the size of the array to be fixed! 17

Faculty of Sciences and Social Sciences HOPE Sequences The size of the sequence data structure can grow and shrink E.g. quiz league secretary’s box of record cards – Number of cards grows as teams join the league – Number shrinks as teams leave 18

Faculty of Sciences and Social Sciences HOPE Sequences The size of the sequence data structure can grow and shrink E.g. list of airplanes in an air traffic control system’s airspace – As planes enter the airspace the list grows – As planes land or leave the list shrinks What does an empty list signify? 19

Faculty of Sciences and Social Sciences HOPE Special sequences – restricted way of joining and leaving Stacks – LIFO Queues – FIFO 20

Faculty of Sciences and Social Sciences HOPE Trees Sometimes more complex data structures needed 21

Faculty of Sciences and Social Sciences HOPE Fixed size so use an array of 10 elements. 22

Faculty of Sciences and Social Sciences HOPE We need to store two items of information in each element so use a table of 10 records We could also use a multi-dimensional array as the data types are the same 23

Faculty of Sciences and Social Sciences HOPE 24

Faculty of Sciences and Social Sciences HOPE 25

Faculty of Sciences and Social Sciences HOPE End of Quick Overview Records Arrays Sequences Trees 26

Faculty of Sciences and Social Sciences HOPE Let’s Recap An Array is a data structure that contains more than 2 of the same data type. Referenced by using an index A record is similar to an array, with the exception that is can use different data types A multidimensional array is similar to a record, except we must use the same data type

Faculty of Sciences and Social Sciences HOPE Text fields: name, nationality, sex, ID number Date fields: date of birth Image field Could also have, for example, – audio field(voice print) – fingerprint field 28

Faculty of Sciences and Social Sciences HOPE Table Example Different data types: Must be a record! NameNationalityDOBSexID Number Image String DateCharStringObject

Faculty of Sciences and Social Sciences HOPE A list of car manufactures Ford Volkswagen Nissan Rolls Royce

Faculty of Sciences and Social Sciences HOPE Array Example Index range is [4] Each element is a name 31 Array name Array elements Array indices (plural of index) Same data type and Only one field. Must be an array!

Faculty of Sciences and Social Sciences HOPE Identifying an array element Ford is Manufacturers[1] Volkswagen is Manufacturers[2] 32

Faculty of Sciences and Social Sciences HOPE Describing an array completely The index for the array Manufacturers lies in the range 1..4 The elements are of type Name. Name stores String data type 33

Faculty of Sciences and Social Sciences HOPE Quick question What is the value of Manufacturers[3] ? 34

Faculty of Sciences and Social Sciences HOPE Another example What are the contents of the element in the array PlayOffTeams which has index 3 ? What is the value of PlayOffTeams[2] ? 35

Faculty of Sciences and Social Sciences HOPE Another example Describe completely the structure of the array PlayOffTeams. 36

Faculty of Sciences and Social Sciences HOPE Another example The index for the array PlayOffTeams lies in the range 1..4 The elements are of type Name Type name as a data type of String 37

Faculty of Sciences and Social Sciences HOPE Summary A record is a collection of different data types An array is a fixed size collection of same data types – 1D – Multidimensional A sequence is a variable size collection of same data types To come Multidimensional arrays Sorting Arrays Implementing arrays / multidimensional arrays in Java 38