9 août 2018 · All the high-school students will be taught the fundamentals of computer There are dozens of introductory textbooks for Computer Science; add in the fact that there are multiple (PDF) documents Comments should not be
Previous PDF | Next PDF |
[PDF] Computer Science I - CSE-UNL - University of Nebraska–Lincoln
9 août 2018 · All the high-school students will be taught the fundamentals of computer There are dozens of introductory textbooks for Computer Science; add in the fact that there are multiple (PDF) documents Comments should not be
[PDF] K-12 Computer Science Curriculum Guide - Education Development
Middle School Pathways in Computer Science PLTW High School Computer Science student (available as a free PDF or a softcover book for purchase),
[PDF] Computer Science Field Guide - Everything Computer Science
It is aimed at high-school level, and is intended to bring you to the point where you systems and books that you can use to teach yourself programming and as a downloadable PDF file (although it's much better viewed in the other formats
[PDF] Download Full Book (PDF) - Introduction to Computing: Explorations
19 août 2011 · This book started from the premise that Computer Science should be taught as Sussman when I was a first year student at MIT, and that course an input program written in a high-level language that is easier for humans to
[PDF] Bachelor of computer science books pdf - Squarespace
BSc Computer Science Books Students are advised to pass some of the books science, or thinking in a computational way, falls somewhere in the middle: you
[PDF] COMPUTER SCIENCE - NCERT
8 avr 2019 · This book is sold subject to the condition that it shall not, by Computer Science (CS) at the higher secondary stage of school education
[PDF] Introduction to Computer Science - Department of Computer Sciences
2 mar 2021 · delivery high-quality programs on time; be able to express control flow and The single most important skill in programming, computer science, and science in general is How does this class (studying Java) fit into the study of Computer Philosophy is written in this grand book, the universe which stands
[PDF] Computer Science in Elementary and Secondary Schools
lack financial resources Key Words: computer science curriculum, elementary education problem solving that is working on a Model High School Computer Science Curriculum There is even an algorithm for writing an essay or a book
[PDF] A High-School Program in Computer Science
high-school curriculum in computer science and supervising the prepa- ration of a However, courseware (study books, teacher's guides, etc ) were not always
[PDF] Multimedia for Computer Science - DIMACS
Computer Science (CS0) textbook For grades of Java programming “objects first,” for both undergraduates and high school students One preface or http:// www cse lehigh edu/~glennb/um/1intro pdf for the first chapter of the book Blank
[PDF] high school ela curriculum
[PDF] high school english 12 syllabus
[PDF] high school physics book pdf
[PDF] high school syllabus template pdf
[PDF] high temperature and high humidity reduce the transmission of covid 19 pdf
[PDF] high speed train routes in europe
[PDF] higher education course scheduling
[PDF] higher education in switzerland
[PDF] higher education meaning
[PDF] higher education vs secondary education wes
[PDF] higher learning commission
[PDF] higher learning commission equity
[PDF] highest indian population in massachusetts
[PDF] highest standard of living
ComputerScienceI
Dr. Chris Bourke
cbourke@cse.unl.eduDepartment of Computer Science & Engineering
University of Nebraska{Lincoln
Lincoln, NE 68588, USA
2018/08/09 16:16:18
Version 1.3.6" "
Copyleft (Copyright)The entirety of this book is free and is released under aCreative Commons Attribution-
ShareAlike 4.0 International License
(seehttp://creativecommons.org/licenses/ by-sa/4.0/for details). iDraft NoticeThis book is a draft that has been released for evaluation and comment. Some of the later
chapters are included as placeholders and indicators for the intended scope of the nal draft, but are intentionally left blank. The author encourages people to send feedback including suggestions, corrections, and reviews to inform and in uence the nal draft. Thank you in advance to anyone helping out or sending constructive criticisms. iii Preface\If you really want to understand something, the best way is to try and explain it to someone else. That forces you to sort it out in your own mind... that's really the essence of programming. By the time you've sorted out a complicated idea into little steps that even a stupid machine can deal with, you've certainly learned something about it yourself." |Douglas Adams,Dirk Gently's Holistic Detective Agency[8]
\The world of A.D. 2014 will have few routine jobs that cannot be done better by some machine than by any human being. Mankind will therefore have become largely a race of machine tenders. Schools will have to be oriented in this direction. All the high-school students will be taught the fundamentals of computer technology, will become procient in binary arithmetic and will be trained to perfection in the use of the computer languages that will have developed out of those like the contemporary Fortran" |Isaac Asimov 1964 I've been teaching Computer Science since 2008 and was a Teaching Assistant long before that. Before that I was a student. During that entire time I've been continually disappointed in the value (note, not quality) of textbooks, particularly Computer Science textbooks and especially introductory textbooks. Of primary concern are the costs, which have far outstripped in ation over the last decade [30] while not providing any real additional value. New editions with trivial changes are released on a regular basis in an attempt to nullify the used book market. Publishers engage in questionable business practices and unfortunately many institutions are complicit in this process. In established elds such as mathematics and physics, new textbooks are especially questionable as the material and topics don't undergo many changes. However, in Computer Science, new languages and technologies are created and change at breakneck speeds. Faculty and students are regularly trying to give away stacks of textbooks (\Learn Java 4!," \Introduction to Cold Fusion," etc.) that are only a few years old and yet are completely obsolete and worthless. The problem is that such books have built-in obsolescence by focusing too much on technological specics and not enough on concepts. There are dozens of introductory textbooks for Computer Science; add in the fact that there are multiple languages and many gimmicks (\Learn Multimedia Java," \Gaming with JavaScript," \Build a Robot with C!"), it is a publisher's paradise: hundreds of variations, a growing market, and customers with few alternatives. v PrefaceThat's why I like organizations like OpenStax (http://openstaxcollege.org/) that attempt to provide free and \open" learning materials. Though they have textbooks for a variety of disciplines, Computer Science is not one of them (currently, that is). This might be due to the fact that there are already a huge amount of resources available online such as tutorials, videos, online open courses, and even interactive code learning tools. With such a huge amount of resources, why write this textbook then? Firstly, layo. Secondly, I don't really expect this book to have much impact beyond my own courses or department. I wanted a resource that presented an introduction to Computer Science how I teach it in my courses and it wasn't available. However, if it does nd its way into another instructor's classes or into the hands of an aspiring student that wants to learn, then great! Several years ago our department revamped our introductory courses in a \Renaissance in Computing" initiative in which we redeveloped several dierent \ avors" of Computer Science I (one intended for Computer Science majors, one for Computer Engineering majors, one for non-CE engineering majors, one for humanities majors, etc.). The courses are intended to be equivalent in content but have a broader appeal to those in dierent disciplines. The intent was to provide multiple entry points into Computer Science. Once a student had a solid foundation, they could continue into Computer Science II and pick up a second programming language with little diculty. This basic idea informed how I structured this book. There is a separation of concepts and programming language syntax. The rst part of this book uses pseudocode with a minimum of language-specic elements. Subsequent parts of the book recapitulate these concepts but in the context of a specic programming language. This allows for a \plug-in" style approach to Computer Science: the same book could theoretically be used for multiple courses or the book could be extended by adding another part for a new language with minimal eort. Another inspiration for the structure of this book is the Computer Science I Honors course that I developed. Usually Computer Science majors take CS1 using Java as the primary language while CE students take CS1 using C. Since the honors course consists of both majors (as well as some of the top students), I developed the Honors version to cover bothlanguages at the same time in parallel. This has led to many interesting teaching moments: by covering two languages, it provides opportunities to highlight fundamental dierences and concepts in programming languages. It also keeps concepts as the focus of the course emphasizing that syntax and idiosyncrasies of individual languages are only of secondary concern. Finally, actively using multiple languages in the rst class provides a better opportunity to extend knowledge to other programming languages{once a student has a solid foundation in one language learning a new one should be relatively easy. The exercises in this book are a variety of exercises I've used in my courses over the years. They have been made as generic as possible so that they could be assigned using any language. While some have emphasized the use of \real-world" exercises (whatever that means), my exercises have focused more on solving problems of a mathematical vi nature (most of my students have been Engineering students). Some of them are more easily understood if students have had Calculus but it is not absolutely necessary. It may be cliche, but the two quotes above exemplify what I believe a Computer Science I course is about. The second is from Isaac Asimov who was asked at the 1964 World's Fair what he though the world of 2014 would look like. His prediction didn't become entirely true, but I do believe we are on the verge of a fundamental social change that will be caused by more and more automation. Like the industrial revolution, but on a much smaller time scale and to a far greater extent, automation will fundamentally change how we live and not work (I say \not work" because automation will very easily destroy the vast majority of today's jobs{this represents a huge economic and political challenge that will need to be addressed). The time is quickly approaching where being able to program and develop software will be considered a fundamental skill as essential as arithmetic. I hope this book plays some small role in helping students adjust to that coming world. The rst quote describes programming, or more fundamentally Computer Science and \problem solving." Computers do notsolveproblems, humans do. Computers only make it possible to automate solutions on a large scale. At the end of the day, the human race is still responsible for tending the machines and will be for some time despite what Star Trek and the most optimistic of AI advocates think. I hope that people nd this book useful. If value is a ratio of quality vs cost then this book has already succeeded in having innite value.1If you have suggestions on how to improve it, please feel free to contact me. If you end up using it and nding it useful, please let me know that too!1 or it might be undened, or NaN, or this book isExceptional depending on which language sections you read vii AcknowledgementsI'd like to thank the Department of Computer Science & Engineering at the University of Nebraska{Lincoln for their support during my writing and maintaining this book.This book is dedicated to my family.
ixContents
Copyleft (Copyright)
iDraft Notice
iiiPrefacev
Acknowledgements
ix1. Introduction
11.1. Problem Solving
21.2. Computing Basics
41.3. Basic Program Structure
51.4. Syntax Rules & Pseudocode
121.5. Documentation, Comments, and Coding Style
142. Basics
172.1. Control Flow
172.1.1. Flowcharts
172.2. Variables
182.2.1. Naming Rules & Conventions
192.2.2. Types
222.2.3. Declaring Variables: Dynamic vs. Static Typing
312.2.4. Scoping
322.3. Operators
332.3.1. Assignment Operators
332.3.2. Numerical Operators
352.3.3. String Concatenation
372.3.4. Order of Precedence
382.3.5. Common Numerical Errors
382.3.6. Other Operators
402.4. Basic Input/Output
412.4.1. Standard Input & Output
422.4.2. Graphical User Interfaces
422.4.3. Output Usingprintf()-style Formatting. . . . . . . . . . . . . 43
2.4.4. Command Line Input
44xi
Contents
2.5. Debugging
462.5.1. Types of Errors
462.5.2. Strategies
492.6. Examples
502.6.1. Temperature Conversion
502.6.2. Quadratic Roots
512.7. Exercises
513. Conditionals
653.1. Logical Operators
653.1.1. Comparison Operators
663.1.2. Negation
683.1.3. Logical And
693.1.4. Logical Or
703.1.5. Compound Statements
713.1.6. Short Circuiting
743.2. The If Statement
753.3. The If-Else Statement
763.4. The If-Else-If Statement
783.5. Ternary If-Else Operator
823.6. Examples
823.6.1. Meal Discount
823.6.2. Look Before You Leap
833.6.3. Comparing Elements
843.6.4. Life & Taxes
853.7. Exercises
874. Loops
954.1. While Loops
974.1.1. Example
984.2. For Loops
994.2.1. Example
1004.3. Do-While Loops
1004.4. Foreach Loops
1024.5. Other Issues
1034.5.1. Nested Loops
1034.5.2. Innite Loops
1034.5.3. Common Errors
1054.5.4. Equivalency of Loops
1064.6. Problem Solving With Loops
1064.7. Examples
1074.7.1. For vs While Loop
1074.7.2. Primality Testing
1084.7.3. Paying the Piper
109xii
Contents
4.8. Exercises
1115. Functions
1335.1. Dening & Using Functions
1345.1.1. Function Signatures
1345.1.2. Calling Functions
1365.1.3. Organizing
1375.2. How Functions Work
1375.2.1. Call By Value
1405.2.2. Call By Reference
1405.3. Other Issues
1425.3.1. Functions as Entities
1425.3.2. Function Overloading
1445.3.3. Variable Argument Functions
1455.3.4. Optional Parameters & Default Values
1455.4. Exercises
1466. Error Handling
1516.1. Error Handling
1536.2. Error Handling Strategies
1536.2.1. Defensive Programming
1536.2.2. Exceptions
1556.3. Exercises
1577. Arrays, Collections & Dynamic Memory
1597.1. Basic Usage
1 607.2. Static & Dynamic Memory
1 627.2.1. Dynamic Memory
1647.2.2. Shallow vs. Deep Copies
1667.3. Multidimensional Arrays
1667.4. Other Collections
1677.5. Exercises
1688. Strings
1778.1. Basic Operations
1778.2. Comparisons
1788.3. Tokenizing
1798.4. Exercises
1799. File Input/Output
1839.1. Processing Files
1839.1.1. Paths
1849.1.2. Error Handling
1859.1.3. Buered and Unbuered
187xiii
Contents
9.1.4. Binary vs Text Files
1879.2. Exercises
18810.Encapsulation & Objects
19710.1. Objects
19810.1.1. Dening
19810.1.2. Creating
19910.1.3. Using Objects
20010.2. Design Principles & Best Practices
20010.3. Exercises
20111.Recursion
20311.1. Writing Recursive Functions
20411.1.1. Tail Recursion
20511.2. Avoiding Recursion
20611.2.1. Memoization
20811.3. Exercises
20912.Searching & Sorting
21112.1. Searching
21112.1.1. Linear Search
21212.1.2. Binary Search
21312.1.3. Analysis
21512.2. Sorting
22012.2.1. Selection Sort
22112.2.2. Insertion Sort
22412.2.3. Quick Sort
22712.2.4. Merge Sort
23212.2.5. Other Sorts
23712.2.6. Comparison & Summary
23712.3. Searching & Sorting In Practice
23812.3.1. Using Libraries and Comparators
23812.3.2. Preventing Arithmetic Errors
23912.3.3. Avoiding the Dierence Trick
24112.3.4. Importance of a Total Order
24212.3.5. Articial Ordering
24212.3.6. Sorting Stability
24312.4. Exercises
24413.Graphical User Interfaces & Event Driven Programming
24714.Introduction to Databases & Database Connectivity
249xiv
Contents
I. The C Programming Language
25115.Basics
25315.1. Getting Started: Hello World
25315.2. Basic Elements
25415.2.1. Basic Syntax Rules
25515.2.2. Preprocessor Directives
25515.2.3. Comments
25815.2.4. Themain()Function. . . . . . . . . . . . . . . . . . . . . . . . 259
15.3. Variables
2 6015.3.1. Declaration & Assignment
26015.4. Operators
262quotesdbs_dbs17.pdfusesText_23