Data Types and Structures

Slides:



Advertisements
Similar presentations
Database Design IST 7-10 Presented by Miss Egan and Miss Richards.
Advertisements

Validation and Verification
Chapter 5: Data Types (2013) Revision Candidates should be able to know: Identify different data types? Key terms: File, record, field and key field Database.
Term 2, 2011 Week 5. CONTENTS Data and information Information purposes Types of data – Integer data types – Floating point numbers – Character data types.
Term 2, 2011 Week 1. CONTENTS Problem-solving methodology Programming and scripting languages – Programming languages Programming languages – Scripting.
Data Structures and Algorithms Lecture 1 Instructor: Quratulain Date: 1 st Sep, 2009.
Mr C Johnston ICT Teacher
Data Handling in Algorithms. Activity 1 Starter Task: Quickly complete the sheet 5mins!
Course Aims This course will help you understand the latest technologies & how they work. You will lean how to develop computer programs to solve problems.
OCR ICT for AS © Hodder Education 2008 Chapter 1 Data, information, knowledge and processing.
Chapter 9: Data types and data structures OCR Computing for A Level © Hodder Education 2009.
Input, Output and Processing.. What data needs to be input into the system? Identify the sources – i.e. where does the data come from? What is the volume.
Data Types Mr Tottman Link. Data Types Programs need to use data for calculations and for output to various devices The best programs will always use.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Data Capture Forms What are they?. Example 1 Example 2.
N5 Databases Notes Information Systems Design & Development: Structures and links.
7 - Programming 7J, K, L, M, N, O – Handling Data.
DATA TYPES.
Primary and Secondary Storage
Input, Output, and Specialist Devices
Image and Sound Representation
Chapter # 2 Part 2 Programs And data
Unit 2 Technology Systems
Chapter 1.2 Introduction to C++ Programming
IP and MAC Addresses, DNS Servers
Unit 1 Logical operators.
Component 1.6.
CST 1101 Problem Solving Using Computers
Additional hardware components, and Embedded Systems
Component 1 Logical operators.
Binary, Denary, Hexadecimal Conversion Binary Addition
Arithmetic Shifts and Character Representation
Homework 1 Hints.
Databases Chapter 9 Asfia Rahman.
Component 1.6.
Chapter 1.2 Introduction to C++ Programming
Data Structures I (CPCS-204)
Data Types Variables are used in programs to store items of data e.g a name, a high score, an exam mark. The data stored in a variable is entered from.
Chapter 6: Data Types Lectures # 10.
Documentation Need to have documentation in all programs
Unit 16 – Database Systems
Week 12 Option 3: Database Design
Other Kinds of Arrays Chapter 11
Other Kinds of Arrays Chapter 11
Chapter 8 Arrays Objectives
Chapter 1: Data Structures 1A, B
Component 1 Revision Chapter 1 - Hardware.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Databases.
IDENTIFIERS CSC 111.
Arrays An Array is an ordered collection of variables
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
GCSE Computing Databases.
Databases Lesson 2.
Chapter 8 Arrays Objectives
Data Types & File Size Calculations
Data Types and Data Structures
Database Theory.
Variables In today’s lesson we will look at: what a variable is
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Spreadsheets, Modelling & Databases
Introduction to Data Structure
Chapter 8 Arrays Objectives
The ultimate in data organization
Chapter 9: More About Data, Arrays, and Files
Data Structures & Algorithms
Databases This topic looks at the basic concept of a database, the key features and benefits of a Database Management System (DBMS) and the basic theory.
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Variables and Constants
Introduction to Computer Science
Presentation transcript:

Data Types and Structures Component 1.4 Data Types and Structures

Starter: Pre-Reading Recap What is Data? What data type would a phone number be? Why? What are the four main data types? What does a Data Structure mean? Give an example of some data that would be a string Give two types of data structure Give an example of some data that would be a Boolean Explain what an Array is Explain what a record is What is the difference between an integer and a float (real) What can a record hold that an Array can’t?

Learning Intentions and Outcomes Grade 4 Describe the concept of data types, including integer, Boolean, real, character and string Describe, design, interpret and manipulate data structures including records, one-dimensional and two-dimensional arrays Grade 5 Design files and records appropriate for a particular application Explain and use appropriate techniques for data validation and verification Grade 6 Use and explain appropriate data types to design files and records appropriate for a particular application Grade 7 Evaluate a collection of data to determine appropriateness of data types and structures

Learning Outcome Sheet Fill in your learning outcome RAG sheet, stick this in underneath your title. Grade 4 Describe the concept of data types, including integer, Boolean, real, character and string Describe, design, interpret and manipulate data structures including records, one- dimensional and two-dimensional arrays Grade 5 Design files and records appropriate for a particular application Explain and use appropriate techniques for data validation and verification Grade 6 Use and explain appropriate data types to design files and records appropriate for a particular application Grade 7 Evaluate a collection of data to determine appropriateness of data types and structures

What is Data? Data is words, numbers, dates, images, sounds etc. without context When we apply context (knowledge) through processing the data we get information

Data Types Data type Description Examples Integer Whole numbers, positive or negative 42, -11, 0 Real Numbers, including fractions or decimal points 12.9, -17.50, 28.0 Boolean True or false 1 or 0 Character Letter, digit, space, punctuation mark or various other symbols 'A', 'b', '7','?' String A sequence of characters ‘Computer science’ ‘The cat sat on the mat’

Strings and Characters The String or Character data type can hold any letter, number, symbol or punctuation mark. It is sometimes referred to as 'alphanumeric' or 'string'. The data can be pure text or a combination of text, numbers and symbols. In python we make a variable a string by putting str() around it: Name = str(“Alex”) Examples of text data types in use:

Integers Integers are whole numbers represented as binary values. Most programming languages provide a data type called 'integer', often called 'int' for short. In python we make a variable an integer by putting int() around it: Age = int(15)

Real (Floats) Floating point numbers are numbers that have a fractional part, usually represented using two components: the main number and the fractional part, each of which is a binary number. This is known as a floating-point representation. Most programming languages provide one or more data types based on floating-point representations. They are usually given names like 'float', 'single', 'double', 'real' or 'longreal'. In python we make a variable a float by putting float() around it: Pi = float(3.14)

Booleans Boolean data holds one of two allowable values, for example: Yes or No True or False A Boolean data type is used to answer questions that have exactly two responses. If a third response were present it is not Boolean data Examples of Boolean data questions: Are you over 15? Do you have a job? Do you have blue eyes?

Grade 4 – Data types Complete the first question of the graded exercises. Extension: Explain how a variable can have each data type cast over it in python: Boolean Float String Integer Data Type Contains Example Variable Name Example Data String / Character   Integer Float (Real) Boolean A Boolean data type is used to answer questions that have exactly two responses. If a third response were present it is not Boolean data. Over18 True / False

Data Structures A data structure is a specific way of organising data within memory so that it can be processed efficiently. There will be a relationship between the data items that will vary according to the type of data structure being used. Exactly what the relationships are determine what type of data structure is being used. Typical operations on a data structure are: ADD INSERT DELETE or REMOVE FIRST NEXT LAST LOCATE

Static and Dynamic Data Structures A static data structure is designed to store a known number of data items. The values of the data can be changed but the memory size is fixed As static data structures store a fixed number of data items they are easier to program, as there is no need to check on the size of the data structure or the number of items stored. For example a high scores board on a video game may record the last 10 high scores. If a new one is entered the last one is lost! Dynamic data structures are designed to allow the data structure to grow or shrink at runtime. It is possible to add new elements or remove existing elements without having to consider memory space. Dynamic data structures make the most efficient use of memory but are more difficult to program, as you have to check the size of the data structure and the location of the data items each time you use the data. For example a shopping list may have different amounts of items on it each week. A program to make a shopping list will need to be dynamic and let the number of entries change!

Static and Dynamic Data Structures

Lists A list is a data structure that has the data items stored in the order they were originally added to memory. If the list is made up of a set number of data items, then it can be a static data structure. If the list can vary in the number of data items, then it will be a dynamic data structure.

Arrays An array is a data structure that can hold a fixed number of data items, which must be of the same data type i.e. real, integer, string etc. The data items in an array are known as elements. An array is an example of a static data structure; we can change the values of the elements in the array but we cannot alter the memory size allocated to the array. The elements in an array are identified by a number that indicates their position in the array. This number is known as the index. The first element in an array usually has an index of 0. 42 56 6 26 4 76 37 11 0 1 2 3 4 5 6 7 Elements Index

arrays There are 8 elements in this array. The index always starts at position 0. Each element can be accessed using its index. The element at index 5 is 56. This type of array is known as a one-dimensional array.

One Dimensional Arrays A one dimensional array has one index – it stores an element in one position. The element is referenced by calling the Array name and the location: ArrTopScore = [50, 45, 44, 43, 40] ThirdPlace = ArrTopScore[2]

Two-Dimensional Arrays Often the data we want to process comes in the form of a table. The data in a two-dimensional array must all be of the same data type. For example a spreadsheet that contains all of the marks for your test this year.. Elements in a two-dimensional array are indexed by two numbers – one for the row it is in and one for the column. If the two-dimensional array is called testMark then the command to declare this array would be: testMark [4,5] In this declaration, the 4 refers to the number of pupils (rows) and the 5 to the number of tests (columns). The index for Sam’s marks for Test 2 would be [0,1].

Grade 4 – Data Structures and Arrays Complete questions 1-11 of the Data Structures and Arrays questions Extension Explain the difference between a one and two dimensional array, providing examples of when each array would be used.

Records Arrays can only hold data if it is all of the same data type. If you need to hold related data of different data types you will need to use a data structure called a record. A record will be made up of information about one person or thing. Each piece of information in the record is called a field. For example, an after school club wants to store data about its members’ emergency contact information. Field Name Field Type Example data Membership Number Integer 1074 First name String Sara Surname Davies Date of Birth Date 12/07/2004 Contact Name Mrs Davies Contact phone number 07564 191919

Records: Key Fields Each record in a file should have a key field. That is an item of data that is unique and can be used to identify the individual record. In this example the membership number would be the key field.

Files For a computer to function it must have data flowing through the central processing unit (CPU) under the control of a program. More often than not this data will have come from a stored file. A program will load the file from secondary storage, such as a hard disc, into the computer’s memory. The data will be manipulated by the CPU and then output. The output could be another data file, screen images or a document. Data stored in a file will have a structure and organisation known as the file format. A data file will be made up of records. It would be most efficient for the fields in a record to be stored next to each other so that the data can be read into the record data structure in memory for processing by the CPU. In summary – files are made of records of the same structure and records are made up of fields containing information about one person or item.

Grade 4 – Records and Files Complete questions 1-4 of the Records and Files questions Extension Find out what a foreign key is and explain how it is related to records. You will need to complete independent research for this. A good website is www.w3schools.com

Validation Validation is a process to check that input data is reasonable or sensible. Frequently used validation algorithms include; For example you might ask someone to input their date of birth. My date of birth is 25/03/1991.. But I could enter 07/05/1989 if I wanted to. Both sets of data are valid because they are both sensible – however Presence checks Used to prevent further progress if a required field is left blank. Format checks Used to ensure data matches a specific pattern, such as dd/mm/yyyy for a date. Input masks are often used to create format checks on database forms. Length checks Used to ensure an input data string is a sensible length e.g. number of characters in ‘firstName’ to be between 3 and 16 Type checks Used to ensure input data is a particular data type e.g. quantity ordered to be integer or cost to be real. Range checks Used to ensure input data lies within a specified range e.g. over time hours to be > 0 and < 15.

Verification Surname String National Insurance (NI) number Standard format LL123456L Job title Apprentice, semi-skilled, skilled, supervisor Week no. Integer Full time Y or N, Full time = 38 hours per week Hours worked Integer, hours worked in current week, maximum 10 hours overtime in one week. Overtime rate = 1.5 x pay rate Pay rate Real, hourly pay rate, max £15.00 / hour Verification is a process for checking data is correct. It can be carried out as a user enters data, such as via a keyboard and also when data is copied from one part of a system to another. Copying should not change the data. Examples of verification of user input include double entry and screen based verification. Double entry involves comparing two versions of data input. e.g.” re- enter your email address”. A verification algorithm will compare the two versions and inform the user if they are not identical.

Grade 4 – Validation and Verification Complete questions 1-5 of the Validation and Verification exam questions Extension Move on to the Exam Questions at the front of the room.

Graded Exam Questions Exercises Complete Grade 5-7 Graded Exercises When you have completed these self-assess them using the mark schemes provided Extension Move on to the Grade 8 Extension Remember to be smart when using the Internet: Wikipedia is often complicated – sometimes even I don’t understand! BBC Bitesize, Teach ICT, and Revision World are better places to find your information!

Crib Sheet – What I must remember about ___ Starting Point: Read the learning outcomes from the exam board Record the key facts that you need to remember about Data Types and Data Structures! Think about what you have learnt today, what questions you have been asked, definitions of words, or anything else you think is important!

Homework Graded Exercises Complete up to your year 11 target grade Question Sheets Q51 – Data Types Revision At least 2 pages of revision resources. For example: Cue Cards Mind Maps Notes Posters

Traversing an Array Traversing an array simply means using a loop to use each element of the array in a section of a program. If you wanted to print out the contents of an array called myArray that has 10 elements you would use a ‘for . . . . next’ loop. Like this:

Inserting into and deleting from an array You can add an element to an array at a given index. myArray[3] = 27 This would store the value 27 at the index 3 of the array You can delete an element from an array. myArray[6] = “” This would leave the memory at index 6 blank. Search Arrays can be search using the index or the value stored at the index.