Sorting Data. FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz Home HOME Arrays.

Slides:



Advertisements
Similar presentations
Chapter 7: Arrays In this chapter, you will learn about
Advertisements

Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
Chapter 9: Advanced Array Manipulation
Programming with Microsoft Visual Basic 2005, Third Edition
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
PHP (2) – Functions, Arrays, Databases, and sessions.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 8 Arrays.
Understanding Arrays and Pointers Object-Oriented Programming Using C++ Second Edition 3.
Chapter 9: Arrays and Strings
Arrays Data Structures - structured data are data organized to show the relationship among the individual elements. It usually requires a collecting mechanism.
Guide To UNIX Using Linux Third Edition
C++ for Engineers and Scientists Third Edition
Chapter 8 Arrays and Strings
Programming Logic and Design Fourth Edition, Comprehensive
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Chapter 1 Program Design
Introduction to programming in MATLAB MATLAB can be thought of as an super-powerful graphing calculator Remember the TI-83 from calculus? With many more.
Finding roots of equations using the Newton-Raphson method
Chapter 7: Arrays. In this chapter, you will learn about: One-dimensional arrays Array initialization Declaring and processing two-dimensional arrays.
IE 212: Computational Methods for Industrial Engineering
MySQL + PHP.  Introduction Before you actually start building your database scripts, you must have a database to place information into and read it from.
Use of Matlab for Analysis and Plotting of Accoustic Well Data.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
Lists in Python.
Array Processing Simple Program Design Third Edition A Step-by-Step Approach 7.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Chapter 17: Arrays Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Chapter 8 Arrays and Strings
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Analytical Solution of the Diffusivity Equation. FAQReferencesSummaryInfo Learning Objectives Introduction Analytical Solution Linear Systems Radial Systems.
Scientific Computing Division A tutorial Introduction to Fortran Siddhartha Ghosh Consulting Services Group.
Array Processing.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Arrays.
Lecture Contents Arrays and Vectors: Concepts of array. Memory index of array. Defining and Initializing an array. Processing an array. Parsing an array.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper.
Arrays Module 6. Objectives Nature and purpose of an array Using arrays in Java programs Methods with array parameter Methods that return an array Array.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Term 2, 2011 Week 1. CONTENTS Problem-solving methodology Programming and scripting languages – Programming languages Programming languages – Scripting.
C++ for Engineers and Scientists Second Edition Chapter 11 Arrays.
Scientific Computing Introduction to Matlab Programming.
Numerical Solution of the Diffusivity Equation. FAQReferencesSummaryInfo Learning Objectives Introduction Discrete Systems Taylor Series Approximation.
Introduction To UNIX. FAQReferencesSummaryInfo Resources Introduction Learning Objectives Log on User Interface Commands List of Commands Useful Info.
1 Objectives ❏ To understand the basic concepts and uses of arrays ❏ To be able to define C arrays ❏ To be able to pass arrays and array elements to functions.
Array Objectives To understand the concept of arrays To understand the purpose to which we use arrays. To be able to declare references to arrays. To be.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
Chapter 8 Arrays. A First Book of ANSI C, Fourth Edition2 Introduction Atomic variable: variable whose value cannot be further subdivided into a built-in.
Course Code #IDCGRF001-A 5.1: Searching and sorting concepts Programming Techniques.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
CHAPTER EIGHT ARRAYS © Prepared By: Razif Razali1.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Arrays.
Arrays Chapter 7. MIS Object Oriented Systems Arrays UTD, SOM 2 Objectives Nature and purpose of an array Using arrays in Java programs Methods.
Two Dimensional Arrays. Students will be able to: code algorithms to solve two- dimensional array problems. use 2-D arrays in programs. pass two-use 2-D.
Copyright © 2014 Curt Hill Algorithms From the Mathematical Perspective.
Overview of Previous Lesson(s) Over View VP is the methodology in which development allows the user to grab and use the desired tools like menus, buttons,
Arrays Declaring arrays Passing arrays to functions Searching arrays with linear search Sorting arrays with insertion sort Multidimensional arrays Programming.
Lecture #15 ARRAYS By Shahid Naseem (Lecturer). 2 ARRAYS DEFINITION An array is a sequence of objects of same data type. The objects in an array are also.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Arrays.
Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Third Edition by Tony Gaddis.
Solution of linear equations using Gaussian elimination Author: Jon Kleppe NTNU Assistant producer: Joachim Tro.
Arrays Chapter 7.
Web Database Programming Using PHP
Unit 2 Technology Systems
Computer Programming BCT 1113
Web Database Programming Using PHP
Computing Oil Reserves Using Statistical Distribution of Porosities
Computer Programming.
Presentation transcript:

Sorting Data

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz Home HOME Arrays Subroutine Subprograms Introduction Programming Exercise Resources Quiz

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz Learning Objectives Learning objectives in this module 1.Develop problem solution skills using computers and numerical methods 2.Review of methods for sorting of tabular data 3.Develop programming skills using FORTRAN New FORTRAN elements in this module sorting arrays subroutines

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz Introduction Sorting of tabular data may seem trivial, and perhaps not worth spending time learning. After all, most of our needs may be filled by the capabilities of Excel or some other spreadsheet program. Just by marking the data to be sorted, and pressing the Sort- button, and the job is done. However, frequently we have measured data from the laboratory or the field, or data-sets that have been generated numerically, that we need to input to a computer program that requires that the numbers are sorted in ascending or descending order. Although we in most cases may easily import the data into Excel and perform sorting of the data before returning it to the input file of the computer program, it will in many cases be convenient to be able to call a subroutine that checks if an input data set is properly sorted, and if not, do a sorting procedure. Next

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz Introduction Several methods for sorting exist, as you may see in the reference above. For our purpose, we will use the Straight insertion method to illustrate sorting of data. Straight insertion is an N 2 routine, and should be used only for small N, say < 20. The technique is exactly the one used by experienced card players to sort their cards:  Pick out the second card and put it in order with respect to the first; then pick out the third card and insert it into the sequence among the first two; and so on until the last card has been picked out and inserted. As a curiosity, in 1999 IBM set a world record in sorting of data. In 17 minutes their parallel processing computer RS6000 SP was able to sort one billion bytes of data (1012 bytes). See sreleases/1999/Jul/spsort_record.html Click Here See the Procedure

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz Procedure  Straight insertion is a simple method which uses simple picking and insertion for sorting one number at a time.  Given an initial sequence of unsorted data, the first run finds the first number (1) that is out of sequence relative to the first number (7), and puts it into sequence.  Then, the next number out of sequence (4) is located and put into it’s right place. In the third run, the third number out of sequence (6) is put in it’s right place, and so on. For this particular table, it takes 6 runs to sort the entire sequence of numbers. More...

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz Arrays  Many scientific computations use vectors and matrices. The data type Fortran uses for representing such objects is the array.  A one-dimensional array corresponds to a vector, while a two-dimensional array corresponds to a matrix. One-dimensional arrays Two-dimensional arrays

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz One-dimensional arrays  The simplest array is the one-dimensional array, which is just a linear sequence of elements stored consecutively in memory. For example, the declaration: REAL A(5) declares A as a real array of length 5 (fx A=[0, 4, 6, 3, 9])  By convention, Fortran arrays are indexed from 1 and up. Thus the first number in the array is denoted by A(1) and the last by A(5). ”I’m beginning to get a hold of it, but I could use some extra information and maybe an example!” More…

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz One-dimensional arrays  Each element of an array can be thought of as a separate variable. You reference the I'th element of array a by A(I). Here is a code segment that stores the 10 first square numbers in the array SQ: INTEGER I, SQ(10) DO 10 I = 1, 10 SQ(I) = I**2 100CONTINUE  This program would take the vector SQ = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] and return the following vector SQ = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz Two-dimensional arrays  Matrices are very important in linear algebra. Matrices are usually represented by two-dimensional arrays. For example, the declaration REAL A(3,5) defines A as a two-dimensional array of 3*5=15 real numbers. It is useful to think of the first index as the row index, and the second as the column index. Hence we get the graphical picture: (1,1)(1,2)(1,3)(1,4)(1,5) (2,1)(2,2)(2,3)(2,4)(2,5) (3,1)(3,2)(3,3)(3,4)(3,5) Click on number to view it’s index Click for more

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz Subroutine Subprograms  Subroutine Subprograms will be further discussed in the next module, we will here just have a quick overview of how it works.  Subroutine subprograms is quite similar to Function Subprograms; they are located after the main program, and have syntax much the same as the main program.  As opposed to function subprograms, subroutines are referred to by a call statement followed by the subroutine name and a list of arguments See the Program Structure

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz Subroutine Subprograms: Structure subroutine name (list-of-arguments) declarations statements return end Program name Declarations Statements call subroutinename (list-of-arguments) Stop end If the subroutine name was sort, you should refer to it by call sort (list-of-arguments) Main program Subprogram

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz Program Exercise  Make a MAIN PROGRAM that reads tabular data (N pairs of values of XT and YT) from an input file IN.DAT, and a FORTRAN subroutine, SORT(N,XT,YT), that may be called with the data as input arguments, which sorts the values in ascending order before returning the results to the calling program.  Print the initial data table as well as the sorted table to an output file OUT.DAT  Test the subroutine on the following data: xf(x) 0,20,008 1,0 0,40,064 0,60, ,80,512 SoSo k ro 0,330,03 0,20 0,820,7 0,530,2 Resources

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz Resources Introduction to Fortran Fortran Template here The whole exercise in a printable format here Web sites  Numerical Recipes In Fortran Numerical Recipes In Fortran  Fortran Tutorial Fortran Tutorial  Professional Programmer's Guide to Fortran77 Professional Programmer's Guide to Fortran77  Programming in Fortran77 Programming in Fortran77

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz This section includes a quiz on the topics covered by this module. The quiz is meant as a control to see if you have learned some of the most important features Hit object to start quiz (Depending on your connection, this make take a few seconds...) Quiz

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz General information Title:Sorting Data Teacher(s):Professor Jon Kleppe Assistant(s):Per Jørgen Dahl Svendsen Abstract:Provide a good background for solving problems within petroleum related topics using numerical methods 4 keywords:Sorting, Subroutines, Fortran, Arrays Topic discipline: Level:2 Prerequisites:None Learning goals:Develop problem solution skills using computers and numerical methods Size in megabytes:0.5 MB Software requirements:MS Power Point 2002 or later, Flash Player 6.0 Estimated time to complete: Copyright information:The author has copyright to the module and use of the content must be in agreement with the responsible author or in agreement with About the author

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz FAQ No questions have been posted yet. However, when questions are asked they will be posted here. Remember, if something is unclear to you, it is a good chance that there are more people that have the same question For more general questions and definitions try these Dataleksikon Webopedia Schlumberger Oilfield Glossary

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz References W. H. Preuss, et al., “Numerical Recipes in Fortran”, 2nd edition Cambridge University Press, 1992  References to textbook: Sorting:page 321 (Chapter 8)  The Textbook can also be accessed online: Numerical Recipes in Fortran

FAQReferencesSummaryInfo Learning Objectives Introduction Arrays Subroutine subprograms Program Exercise Resources Quiz Summary Subsequent to this module you should...  be able to construct subroutines  write and handle DO loops  have a feel for the output format  know the conditional statements and use the IF structure