The Data Types and Data Structures

Slides:



Advertisements
Similar presentations
C++ for Engineers and Scientists Third Edition
Advertisements

Programming Logic and Design Fourth Edition, Comprehensive
Chapter 7: Arrays. In this chapter, you will learn about: One-dimensional arrays Array initialization Declaring and processing two-dimensional arrays.
Data and its manifestations. Storage and Retrieval techniques.
External data structures
Indexed and Relative File Processing
A Level Computing#BristolMet Session Objectives#U2 S7 MUST understand the difference between an array and record SHOULD be able to estimate the size of.
CSci 111 – computer Science I Fall 2014 Cynthia Zickos WRITING A SIMPLE PROGRAM IN JAVA.
P p Chapter 11 discusses several ways of storing information in an array, and later searching for the information. p p Hash tables are a common approach.
Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Third Edition by Tony Gaddis.
SVBIT SUBJECT:- Operating System TOPICS:- File Management
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Chapter 9: Data types and data structures OCR Computing for A Level © Hodder Education 2009.
( ) 1 Chapter # 8 How Data is stored DATABASE.
Arrays Chapter 7.
Introduction toData structures and Algorithms
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 8: Namespaces, the class string, and User-Defined Simple Data Types.
Week 2 - Wednesday CS 121.
4. Java language basics: Function
Module 11: File Structure
IGCSE 4 Cambridge Data types and arrays Computer Science Section 2
INLS 623– Database Systems II– File Structures, Indexing, and Hashing
CHP - 9 File Structures.
3.2.3 Data types and data structures
Indexing Goals: Store large files Support multiple search keys
TMF1414 Introduction to Programming
LEARNING OBJECTIVES O(1), O(N) and O(LogN) access times. Hashing:
Foundations of Programming: Arrays
Ch. 8 File Structures Sequential files. Text files. Indexed files.
Chapter 7 Part 1 Edited by JJ Shepherd
Chapter 8 Arrays Objectives
Chapter 13: File Input and Output
Chapter 11: File System Implementation
Arrays, For loop While loop Do while loop
The relational operators
Disk Storage, Basic File Structures, and Hashing
Arrays An Array is an ordered collection of variables
File and Database Concepts
Topics Introduction to File Input and Output
Physical Database Design
Programming Logic and Design Fourth Edition, Comprehensive
Chapter 8 Arrays Objectives
Java Programming Loops
CH 9.2 : Hash Tables Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++, Goodrich, Tamassia and.
Files [Computing] Computing.
Topic 1: Problem Solving
File I/O in C Lecture 7 Narrator: Lecture 7: File I/O in C.
Can store many of the same kind of data together
Coding Concepts (Basics)
Hash Tables Chapter 12 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common.
Starting Out with Programming Logic & Design
CH 9.2 : Hash Tables Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++, Goodrich, Tamassia and.
File Storage and Indexing
RDBMS Chapter 4.
Other ISAs Next, we’ll first we look at a longer example program, starting with some C code and translating it into our assembly language. Then we discuss.
Other ISAs Next, we’ll first we look at a longer example program, starting with some C code and translating it into our assembly language. Then we discuss.
Introduction to Data Structures
Building Java Programs
Hash Tables Chapter 12 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common.
Chapter 8 Arrays Objectives
Indexing 4/11/2019.
Java Programming Loops
Chapter 9: More About Data, Arrays, and Files
Topics Introduction to File Input and Output
Testing & Security Dr. X.
Arrays Introduction to Arrays Reading for this Lecture:
PROGRAMMING CONCEPTS CHAPTER 8
Arrays.
Dictionaries and Hash Tables
Presentation transcript:

The Data Types and Data Structures Chapter 3 The Data Types and Data Structures

Data Types

Scanner userinput = new Scanner(System. in); System. out Scanner userinput = new Scanner(System.in); System.out.println("Welcome to Java Calculator"); System.out.print("Enter First Number:") num1= userinput.nextInt(); System.out.print("Enter Second Number:"); String num2= userinput.nextInt(); System.out.print("Enter operation to perform (+,-,x,/):"); String operation = userinput.next();

for(char loop = a ; loop <= z ; loop++ ) System.out.println(loop);

Data Structures Arrays Records

Arrays An array stores multiple values of the same data type but say that we want to store values of multiple data types. For example a person on a database will have data about their name, age and gender; all of which could not be stored in an array (as they are data types string, integer and character). This is where records are useful as they can store a number of fields on a particular situation that requires a number of different data types.

Indexed Sequential Files Direct Access Files/Random Access File Types of files: Serial Files Sequential Files Indexed Sequential Files Direct Access Files/Random Access File Random Files

Serial Files Is a file in which the data is stored in the order in which it arrives. New data is simply added to the end. When data is deleted a gap is made and the only way to remove this gap is to rewrite the file. To find something you need to search the entire file.

Sequential Files Stored in a logical sequence such that library books would be stored by their reference number. New data is added to the middle of the file by creating a new file, moving all of the data before the particular point to the new file, adding the new data to the new file and then migrating the rest of the data to the new file. Pascal does this automatically. Searching is the same as serial files.

Indexed Sequential Files Same as sequential files except data can be searched for from any of the fields, not just the logical sequence field.

Direct Access Files/Random Access File If the records of a sequential file are of a fixed length and so data can be read from the file, if you now its position in the file, without having to read through the whole file; for example a file with record of 50 bytes then the records will be stored at 0, 50, 100, 150, 200 etc. bytes into the file. Formula for accessing the nth record.

Random Files Data can be stored in memory or on disk in the most efficient way possible by breaking up the records. The records are broken up through the use of a hash algorithm. It is the quickest as to access data you only need its location and you don't have to read through the entire file. It is very useful for large databases.

Scanner scan = new Scanner(System. in); System. out Scanner scan = new Scanner(System.in); System.out.println("Enter strings to change "); int input = scan.nextLine(); int result = input.toUpperCase(); System.out.println(result);

Working with files Opening Opening files usually means just declaring the file as a variable and using an open command (or similar) in most languages. Not too much to it really. It is also good practice to have the file open for as little time as possible so that to minimalise memory usage, processor time and also other applications may also need to have access to the same file, especially on a network.

Working with files Reading Some languages provide different methods of reading from files (Pascal uses the read command which reads the file line by line). In some files it maybe necessary to check that you have not reached the end of the file before reading the next line otherwise errors may occur, or place the reading the file inside a repeat loop that continues until end of file has been reached.

Working with files Writing This may include appending, editing, rewriting files and a variety of other tasks that differ between programming languages and types of files and I can't be bothered to do lots of research: so let me google that for you instead

Working with files Estimating File Sizes Determine the size of each record by adding up the size of each variable (see table at top). Multiple this number by the number of records in the file. Add 10% for overheads. Divide by 1000 (1024 for the perfectionists) to convert to kilobytes. Repeat above step to convert to next levels of data storage if necessary - Megabytes, Gigabytes etc.