DOC PREVIEW
TRINITY CSCI 1320 - Lecture Notes

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1Binary I/O11/14/20072Opening Discussion■Do you have any questions about the quiz?■Let's look at solutions to the interclass problem.■Quantum computers: if and when.3Quicksort■Quicksort can sort in place. At each step we pick a special element called the pivot. We move elements so that the pivot is in its proper place. Then we recursively call quicksort on the parts below and above the pivot.■All the work happens going down the recursion.■Expected behavior is O(n log n), but poor pivot selection leads to worst case of O(n2).■For our code we will just take the first element as the pivot. We could easily pick another and swap it to the first spot.4Binary Files vs. Text Files■We have already played with files, but the files that we used were text files.■Text files have the advantage that they are human readable and can be easily edited with any text editor.■Most files that programs use a binary files. These are typically smaller and more efficient. With binary files we write the data to the disk as it appears in the memory of the machine.■Binary files also allow us to do direct access which is vital in many applications.5Using Binary Files■Working with binary files we use fopen and fclose just like normal, but you need to specify that it is a binary file in the fopen.■Instead of fprintf or fscanf we use fread and fwrite.■These functions directly copy from disk to memory or from memory to disk.■Let's look at the man pages for these functions.6Random Access■What really makes binary files significant is the ability to jump to any place in the file to read or write.■This random access ability makes them very fast for accessing large amounts of data. Databases are built around this ability.■The simplest form of direct access involves fixed length records. This is basically like having an array on disk.7Code■Let's write some code to see how this works.8Minute Essay■What are going to be some of the problems/challenges of dealing with random access files?■Interclass Problem – Make a binary file that has an array of integers. If you want a challenge, write a function to sort that which doesn't use an array, but sorts it on the file never loading more than two numbers at a


View Full Document

TRINITY CSCI 1320 - Lecture Notes

Documents in this Course
Functions

Functions

10 pages

Functions

Functions

10 pages

Graphics

Graphics

10 pages

Graphics

Graphics

11 pages

Loops

Loops

4 pages

Loops

Loops

3 pages

Strings

Strings

9 pages

Functions

Functions

10 pages

Loops

Loops

11 pages

Graphics

Graphics

11 pages

Graphics

Graphics

12 pages

Sorting

Sorting

11 pages

Sorting

Sorting

10 pages

Arrays

Arrays

10 pages

Loops

Loops

18 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?