CS 240 – Computer Science I

Total Page:16

File Type:pdf, Size:1020Kb

CS 240 – Computer Science I CS 240 – Computer Science I Acknowledgements: These slides were created by Dr. Travis Doom with information, graphics, materials, or aid kindly ppyrovided by Dr. Matt Rizki, Gaddis’s “Starting Out with Java” ( Addison Wesle y), Patt’s “Introduction to com puters” and McConnell’s “Code Complete”.. Wright State University, College of Engineering CS 240 Dr. T. Doom, Computer Science & Engineering Computer Science I 1 An engineer’s introduction to abstraction and the digital computer Thdhe modern genera l purpose diildigital computer Abstraction/Encapsulation Design decomposition What is a computer? z What is computation? z There are many sorts of computing devices, they fall into two categories: – Analog: machines that produce an answer that measures some continuous physical property such as distance, light intensity, or voltage. Examples? – Digital: machines that perform computations by manipulating a fixed finite set of elements. Examples? – The difficulty with analog devices is that it is very hard to increase their accuracy. z Before modern digital computers, the most common digital machines were adding machines. – Adding machines perform exactly one sort of operation. z General purpose digital computers also perform one operation… – Mo dern compu ters accep t a se t o f inst ructi ons th at t ell it h ow t o d o any sort of comput ati on. z We now make a clear distinction between “calculators” and “computers” Wright State University, College of Engineering CS 240 Dr. T. Doom, Computer Science & Engineering Computer Science I 3 How do we get the electrons to do the work? z We describe our problems in English or some other natural language. Computer problems are so lve d by e lec trons flow ing aroun d ins ide th e comput er. z It is necessary to transform our problem from a natural language to the voltages that influence the flow of electrons. z This transformation is really a sequence of systematic transformations , developed and improved over the last 50 years, which combine to give the computer the ability to carry out what may appear to be very complicated tasks. In reality, these tasks must decomposed into a number of simple and straight- forward subtasks. z Engineering design – Top down design – Decomposition into smaller problems (Divide and Conquer!) – Levels of Abstraction Wright State University, College of Engineering CS 240 Dr. T. Doom, Computer Science & Engineering Computer Science I 4 The principle of design abstraction z General model for Engineering (Byrne, 1992) Alteration Reverse Con- re-think Con- Forward EiEngineeri ng ceteptual ceptual EiEngineeri ng Abstraction Refinement Requirementsre-specify Requirements Design re-design Design re-build Implementation Implementation Existing System Target System Wright State University, College of Engineering CS 240 Dr. T. Doom, Computer Science & Engineering Computer Science I 5 Levels of abstraction in digital computation z Design Process The Problem CS 24x, 4xx Software level Computer Science Algorithm & Language CEG 320 Hardware level Computer Engineering ISA & Microarchitecture CEG 260/360 Logic level Computer/Elect. Engineering Circuits & Devices Wright State University, College of Engineering CS 240 Dr. T. Doom, Computer Science & Engineering Computer Science I 6 The statement of the problem The Problem z We describe problems that we wish to solve wihith a computer in a “ natural ll language.” z Natural languages are fraught with a lot of things unacceptable for providing instructions Algorithm & Language to a computer. z The most important of these unacceptable attributes is ambiguity. To infer the meaning of a sentence, a listener i s of ten h el ped b y context ISA & Microarchitecture that the computer does not have. – “Mary had a little lamb and other nursery rhymes.” z A computer can not deal with any ambiguity, Circuits & Devices thus… Wright State University, College of Engineering CS 240 Dr. T. Doom, Computer Science & Engineering Computer Science I 7 The algorithm The Problem z The first step in the sequence of transformations is to transform the natural language description of the problem to an algorithm. z An algorithm is a step-by-step procedure: – That transforms an input (possibly NULL) into Algorithm & Language some output (or output action) – That is guaranteed to terminate z Definiteness: Each step is precisely stated. z Effective computability: Each step must be ISA & Microarchitecture something the computer can perform z Finiteness: The procedure must terminate/repeat z For any computable problem, there are an infinite number of algorithms to solve it. Circuits & Devices – Which solution is best? Wright State University, College of Engineering CS 240 Dr. T. Doom, Computer Science & Engineering Computer Science I 8 Exponential growth z 10^1 z 10^2 z 10^3 Number of students in the college of engineering z 10^4 Number of students enrolled at Wright State University z 10^6 Number of people in Dayton z 10^8 Number of people in Ohio z 10^10 Number of stars in the galaxy z 10^20 Total number of all stars in the universe z 10^80 Total number of particles in the universe z 10^100 << Number of possible solutions to traveling salesman (100) z Travelling salesman (100) is computable but it is NOT feasible. Wright State University, College of Engineering CS 240 Dr. T. Doom, Computer Science & Engineering Computer Science I 9 The programming language The Problem z The next step is to transform the algorithm into a computer program z Programming languages are unambiguous “mechanical” languages Algorithm & Language z There are two kinds of programming languages: – High-level languages are machine independent. Th“fb”h(dli)hey are “far above” the (underlying) computer ISA & Microarchitecture – Low-level languages are machine dependent. They are tied to the computer on which the program will execute. There is generally only one such language per machine (referred to as its ASSEMBLY language). Circuits & Devices Wright State University, College of Engineering CS 240 Dr. T. Doom, Computer Science & Engineering Computer Science I 10 How do we specify the program? z Contemporary languages – Java, C++, C , C# , Perl , Python, Ruby , and many more . z Languages of yore – Fortran, COBOL, and many more. z Specialty lang uages – VHDL, simulation languages, and many more. z There are over 1 ,000 “ stand ardi zed” programmi ng l anguages tod ay. z The only goal of these languages is to help humans implement their algorithms in the instructions available for a particular ISA – This is what we mean when we say “programming” Wright State University, College of Engineering CS 240 Dr. T. Doom, Computer Science & Engineering Computer Science I 11 Universal computing devices z Turing’s Thesis: Computer scientists believe that ANYTHING that can be comppygppputed by a general purpose computer can be com pyygputed by any general purpose computer (provided that it has enough time and enough memory). z What does this imply? – All computers (from the least expensive to the most expensive) are capable of computing EXACTLY th e same thi ngs IF th ey are gi ven enough ti me and enough memory. – Some computers can do things faster, but none can do more than any other computer. – All comppyguters can do exactly the same things! z Thus, any given problem is either computable or it is not computable – Problems may be computable, but still not feasible (NPC) Wright State University, College of Engineering CS 240 Dr. T. Doom, Computer Science & Engineering Computer Science I 12 The instruction set architecture (ISA) The Problem z The next step is to translate the program into the ins tructi on set of th e parti cul ar comput er th at will b e used to carry out the work of the program. z The Instruction Set Architecture (ISA) is the complete specification of the interface between Algorithm & Language programs that have been written and the underlying hardware that must carry out the work of those programs. – Examples: IA-32 (Intel, AMD, and others), PowerPC (Motorola) ISA & Microarchitecture z Programs are translated from high languages in to the ISA of the computer on which they will be run by a program called a compiler (specific to the ISA). – Some languages are interpreted as they execute. Circuits & Devices z Programs are translated from assembly to the ISA by an assembler. Wright State University, College of Engineering CS 240 Dr. T. Doom, Computer Science & Engineering Computer Science I 13 Compilation vs. Interpretation z Different ways of translating high-level language Get W from the z Interpretation keyboard. – interpreter = program that executes program statements X = W + W – generally one line/command at a time Y = X + X – limited processing Z = Y + Y – easy to dbdebug, ma ke c hanges, v iew intermedi ate resul ts Print Z to screen . – languages: Java, BASIC, LISP, Perl, Matlab, C-shell How many arithmetic z Compilation operations when – translates statements into machine language interpreted? When z does not execute, but creates executable program compiled with – performs optimization over multiple statements optimization? – change requires recompilation z can be harder to debug, since executed code may be different – languages: C++, C, Fortran, Pascal, etc. Wright State University, College of Engineering CS 240 Dr. T. Doom, Computer Science & Engineering Computer Science I 14 The von Neumann Model - Illustration Memory MAR MDR Processing Unit Input ALU TEMP Output (keyboard) (monitor) Control Unit PC IR Memory: holds both data and instructions Processing Unit: carries
Recommended publications
  • Customizing and Extending Powerdesigner SAP Powerdesigner Documentation Collection Content
    User Guide PUBLIC SAP PowerDesigner Document Version: 16.6.2 – 2017-01-05 Customizing and Extending PowerDesigner SAP PowerDesigner Documentation Collection Content 1 PowerDesigner Resource Files.................................................... 9 1.1 Opening Resource Files in the Editor.................................................10 1.2 Navigating and Searching in Resource Files............................................ 11 1.3 Editing Resource Files........................................................... 13 1.4 Saving Changes................................................................13 1.5 Sharing and Embedding Resource Files...............................................13 1.6 Creating and Copying Resource Files.................................................14 1.7 Specifying Directories to Search for Resource Files.......................................15 1.8 Comparing Resource Files........................................................ 15 1.9 Merging Resource Files.......................................................... 16 2 Extension Files................................................................18 2.1 Creating an Extension File.........................................................19 2.2 Attaching Extensions to a Model....................................................20 2.3 Exporting an Embedded Extension File for Sharing.......................................21 2.4 Extension File Properties......................................................... 21 2.5 Example: Adding a New Attribute from a Property
    [Show full text]
  • PL/SQL Data Types
    PPLL//SSQQLL -- DDAATTAA TTYYPPEESS http://www.tutorialspoint.com/plsql/plsql_data_types.htm Copyright © tutorialspoint.com PL/SQL variables, constants and parameters must have a valid data type, which specifies a storage format, constraints, and valid range of values. This tutorial will take you through SCALAR and LOB data types available in PL/SQL and other two data types will be covered in other chapters. Category Description Scalar Single values with no internal components, such as a NUMBER, DATE, or BOOLEAN. Large Object LOB Pointers to large objects that are stored separately from other data items, such as text, graphic images, video clips, and sound waveforms. Composite Data items that have internal components that can be accessed individually. For example, collections and records. Reference Pointers to other data items. PL/SQL Scalar Data Types and Subtypes PL/SQL Scalar Data Types and Subtypes come under the following categories: Date Type Description Numeric Numeric values on which arithmetic operations are performed. Character Alphanumeric values that represent single characters or strings of characters. Boolean Logical values on which logical operations are performed. Datetime Dates and times. PL/SQL provides subtypes of data types. For example, the data type NUMBER has a subtype called INTEGER. You can use subtypes in your PL/SQL program to make the data types compatible with data types in other programs while embedding PL/SQL code in another program, such as a Java program. PL/SQL Numeric Data Types and Subtypes Following
    [Show full text]
  • Boolean Data Type & Expressions Outline Basic Data Types
    Boolean Data Type & Expressions Outline Basic Data Types 1. Boolean Data Type & Expressions Outline Numeric 2. Basic Data Types – int 3. C Boolean Data Types: char or int/ – float Boolean Declaration Non-numeric 4. Boolean or Character? – char 5. Boolean Literal Constants #include <stdio.h> 6. Boolean Expressions/ int main () Boolean Operations ¡ /* main */ 7. Example: Boolean Literal Constants & Expressions float standard_deviation, relative_humidity; int count, number_of_silly_people; 8. Example: Boolean Variables char middle_initial, hometown[30]; ¢ 9. Relational Operations /* main */ 10. Example: Relational Expressions 11. Structure of Boolean Expressions 12. Precedence Order of Boolean Operations 13. Another Boolean Precedence Example 14. Example: Boolean Precedence Order 15. Example: More Relational Expressions 16. Example: More Relational Expressions (continued) 17. Short Circuiting 18. Exercise: Writing a Program 1 2 C Boolean Data Type: char or int Boolean or Character? The C data type typically used for storing Boolean values is char, Question: How does the C compiler know that a particular char although int will also work. declaration is a Boolean rather than a character? Like numeric data types, Booleans have particular ways of being Answer: It doesn’t. stored in memory and of being operated on. % cat shortcircuit.c #include <stdio.h> Conceptually, a Boolean value represents a single bit in memory, char int int main () although the and data types aren’t implemented this ¡ /* main */ way — if for no other reason than that computers can’t address a const int maximum_short_height_in_cm = 170; single bit, since the smallest collection of bits that they can address int my_height_in_cm = 160; char I_am_Henry = 1; is a byte (or, in a few cases, a word).
    [Show full text]
  • The Origins of Word Processing and Office Automation
    Remembering the Office of the Future: The Origins of Word Processing and Office Automation Thomas Haigh University of Wisconsin Word processing entered the American office in 1970 as an idea about reorganizing typists, but its meaning soon shifted to describe computerized text editing. The designers of word processing systems combined existing technologies to exploit the falling costs of interactive computing, creating a new business quite separate from the emerging world of the personal computer. Most people first experienced word processing using a word processor, we think of a software as an application of the personal computer. package, such as Microsoft Word. However, in During the 1980s, word processing rivaled and the early 1970s, when the idea of word process- eventually overtook spreadsheet creation as the ing first gained prominence, it referred to a new most widespread business application for per- way of organizing work: an ideal of centralizing sonal computers.1 By the end of that decade, the typing and transcription in the hands of spe- typewriter had been banished to the corner of cialists equipped with technologies such as auto- most offices, used only to fill out forms and matic typewriters. The word processing concept address envelopes. By the early 1990s, high-qual- was promoted by IBM to present its typewriter ity printers and powerful personal computers and dictating machine division as a comple- were a fixture in middle-class American house- ment to its “data processing” business. Within holds. Email, which emerged as another key the word processing center, automatic typewriters application for personal computers with the and dictating machines were rechristened word spread of the Internet in the mid-1990s, essen- processing machines, to be operated by word tially extended word processing technology to processing operators rather than secretaries or electronic message transmission.
    [Show full text]
  • Xml Schema Boolean Data Type Example
    Xml Schema Boolean Data Type Example Binomial and uncomposable Hussein often inveighs some masterdom alongside or apologizes flawlessly. Sandro is unwitting and congeed worst as ninety Lovell minimises greenly and candling avertedly. Postponed or palsy-walsy, Nahum never sectionalises any height-to-paper! Our solution can be used by sql anywhere enables complex xml data For example Integerlength2 allows 10 99 and 1 but not 100 9 or 10. Implemented across major programming languages and a school setting mode switches for a csv go by first search pattern on the button clicks, including different parts: xml schema boolean data type. Package API xmlschema 142 documentation. Int xmlhttpexamplecom sequence Virtual bool xmlhttpexamplecom virtual. Creating a fact data item in XNAT consists of creating the XSD that defines the data center itself. Wrapping character type. XSD Miscellaneous Data Types Tutorialspoint. XML Schema Instance namespace available. Field Constraints and Validation Nuxeo Documentation. Examples of the schema describing the binary data Overview. OpenClinica supports a subset of many Item Data Types defined in ODM. Use the same type to data type of text. AS CSV GO I consider XML as the best solution in terms of code and performance. Thank you guys so much! Datatype Examples Collection area HL7Wiki. Dependent child elements with xsdassert Oxygen XML Forum. With join syntax limit syntaxx views inserts boolean handling of NULLS. XML Schema Simple Elements. The correct performance: although it else you can be extremely important in schema in property with a namespace declaration will validate xml? Set to b are not validated during the value as the values, and removed the xml schema to be masked in xml schema? All data dictionary and examples and hard to use.
    [Show full text]
  • Declare True in C
    Declare True In C When Trent maladminister his prunes unpins not crazily enough, is Rog draperied? Marlowe is irreducibly repayable after attenuated Miles congregate his mumblers adorably. Emilio often sorrow municipally when relaxant Ximenez mispunctuating scenically and overstrikes her idiotism. Learn more concise, in true then you have just same To lateral the size of your trade in bytes you then use the sizeof operator int a17 sizet n sizeofa On my computer ints are 4 bytes long so n is 6 To determine what number of elements in input array we shall divide those total size of flash array apply the size of one array element. A true boolean data type gonna be used for storing logical values and would only submit two legal values true memory false C does cab have boolean data types and normally uses integers for boolean testing Zero is used to fire false just One is used to fill true. In C any nonzero value is treated as true health a zero value is treated as. Groovy also supports the Java colon variation with colons for char c text. A hollow object declared in this way will have no values other share the. A variable declaration always contains two components the responsible of the variable. 49 Boolean values Learn C. Documentation Advanced Types TypeScript. Operators in C CodesDope. Boolean bool or Bool datatype in C C programming language from C99 supports Boolean data type bool and internally it was referred as Bool as boolean was update a datatype in early versions of C. Bool type C reference Microsoft Docs.
    [Show full text]
  • 4 Data Types
    4 Data Types VHDL is a strongly typed language. Every constant, signal, variable, function, and parameter is declared with a type, such as BOOLEAN or INTEGER, and can hold or return only a value of that type. VHDL predefines abstract data types, such as BOOLEAN, which are part of most programming languages, and hardware-re- lated types, such as BIT, found in most hardware languages. VHDL predefined types are declared in the STANDARD pack- age, which is supplied with all VHDL implementations (see Example 4–14). Data types addresses information about Enumeration Types Enumeration Overloading Enumeration Encoding Integer Types Array Types Record Types Predefined VHDL Data Types HOME CONTENTS INDEX For further assistance, email [email protected] or call your local support center V3.4 VHDL Compiler Reference Unsupported Data Types Synopsys Data Types Subtypes The advantage of strong typing is that VHDL tools can catch many common design errors, such as assigning an eight-bit value to a four-bit-wide signal, or incrementing an array index out of its range. The following code shows the definition of a new type, BYTE, as an array of eight bits, and a variable declaration, ADDEND, that uses this type. type BYTE is array(7 downto 0) of BIT; variable ADDEND: BYTE; The predefined VHDL data types are built from the basic VHDL data types. Some VHDL types are not supported for synthesis, such as REAL and FILE. The examples in this chapter show type definitions and associated object declarations. Although each constant, signal, variable, function, and parameter is declared with a type, only variable and signal declarations are shown here in the examples.
    [Show full text]
  • The Database Language 95030
    Tbe Database Language GEM Carlo Zaniolo Bell Laboratories Holmdel, New Jersey 07733 ABSTRACT GEM (bn acronym for General Entity Manipulator) is a general-purpose query and update language for the DSIS data model, which is a semantic data model of the Entity-Relationship type. GEM is designed as -an easy-to-use extension of the relational language QUEL. providing supporr for. the notions of entities with surrogates, aggregation, generalization, null values, and set-valued attributes. 1. INTRODUCTION generalization. The possibility of extending the relational model to capture more meaning - as A main thrust of computer technology is towards opposed to introducing a new model - was simplicity and ease of use. Database management investigated in [CoddZl, where, surrogates and null systems have come a long way in this respect, values were found necessaryfor the task. particularly after the introduction of the relational approach [Ullml, which provides users with a simple ,-‘Most previous work with semantic data models has tabular view of data and powerful and convenient concentrated on the problem of modeling reality and query languages for interrogating and manipulating on schema design; also the problem of integrating the database. These features were shown to be the the database into a programming environment key to reducing the cost of database-intensive supporting abstract data types has received application programming Ecddll and to providing considerable attention [Brad, KMCI. However, the a sound environment for back-end support and
    [Show full text]
  • Fundamental Programming Concepts
    APPENDIX A Fundamental Programming Concepts The following information is for readers who are new to programming and need a primer on some fundamental programming concepts. If you have programmed in another language, chances are the concepts presented in this appendix are not new to you. You should, however, review the material briefly to become familiar with the C# syntax. Working with Variables and Data Types Variables in programming languages store values that can change while the program executes. For example, if you wanted to count the number of times a user tries to log in to an application, you could use a variable to track the number of attempts. A variable is a memory location where a value is stored. Using the variable, your program can read or alter the value stored in memory. Before you use a variable in your program, however, you must declare it. When you declare a variable, the compiler also needs to know what kind of data will be stored at the memory location. For example, will it be numbers or letters? If the variable will store numbers, how large can a number be? Will the variable store decimals or only whole numbers? You answer these questions by assigning a data type to the variable. A login counter, for example, only needs to hold positive whole numbers. The following code demonstrates how you declare a variable named counter in C# with an integer data type: int counter; Specifying the data type is referred to as strong typing. Strong typing results in more efficient memory management, faster execution, and compiler type checking, all of which reduces runtime errors.
    [Show full text]
  • How to Use Basic Boolean Functions Tutorial
    How to Use Basic Boolean Functions Tutorial Functions -> Programming -> Boolean -> And , Or , Not , Not Or (NOR) , Not And (NAND) , Exclusive Or (XOR) , Not Exclusive Or (XNOR) , True , False This tutorial will explain how to use the Boolean data type and Boolean functions such as those used in Boolean algebra like AND, OR, and NOT (conjunction, disjunction, and negation respectively). These functions are similar to the basic logic gates used to design circuits and only perform two bit input operations. Boolean data types have only two values, “True” and “False”. Booleans are have their own set of functions that deal exclusively with manipulating Booleans that are derived directly from Boolean algebra and are the primary means of manipulating Boolean data types. These functions are also known as logical operators or logic gates which are discussed below. Because of the simplicity of the Boolean data type, they are frequently used as the values used to drive conditional branching and decision making structures. To find the logical operator gates, start by opening the Functions palette and selecting the Programming palette. Then select the Boolean palette . This should bring up the Boolean operator functions. Select the function that you want to use and place it in your block diagram. Each function except the NOT, True, and False functions takes two Booleans as its inputs and, because of the rules of Boolean logic, the order of the inputs does not matter. In addition, each function outputs a Boolean value depending on whether the logical operator evaluates the two inputs as True or False. The NOT function serves as a negation function that takes a Boolean value and outputs the opposite Boolean value (i.e.
    [Show full text]
  • Functional, Actor Based Programming Language
    Oscar Functional, Actor based Programming Language Manager: Ethan Adams EA2678 ​ Language Guru: Howon Byun HB2458 ​ System Architect: Jibben Lee Grabscheid Hillen JLH2218 ​ System Architect: Vladislav Sergeevich Scherbich VSS2113 ​ Tester: Anthony James Holley AJH2186 ​ Table of Contents Introduction Core Concepts Immutability Actor Lexical Conventions Identifiers Keywords Punctuation Operators Types Programming Structure Introduction We will be implementing an Actor-Oriented Language. We all know there are difficulties associated with parallel computation, namely data collision when multiple threads access the same data. Most often, this requires explicitly defining locks and mutexes to control data access to resolve this issue, which adds significant mental and code overhead. The Actor model is a different approach to this problem that relies on the concept of message-passing between processes. The model simplifies the aforementioned difficulties of multiprocessing by abstracting explicit method calls, and relying on each “actor” to handle tasks and encapsulate mutable data. We would like to construct our language based off Erlang and Akka framework. Core Concepts Immutability Values in Oscar are immutable like Haskell and Ocaml. This means that when a non-atomic value is declared, it cannot be reassigned and function parameters are passed by value. For instance, this is not allowed. int x = 5; x = 4; // error For primitive container types like list, map and set, they have an additional property ​ ​ ​ ​ that re-assigning values returns a new copy of the data structure with those updates applied. list<int> initList == [1, 2, 3, 4, 5]; list<int> changedList = (initList[3] = -4); changedList == [1, 2, 3, -4, 5]; initList == [1, 2, 3, 4, 5]; Passing objects by value seems like a massive performance drain.
    [Show full text]
  • Reviews Computer Applications Programs
    REVIEWS COMPUTER APPLICATIONS PROGRAMS INTRODUCTION TO SOFTWARE REVIEWS By Glen McAninch, University of Kentucky "You've come a long way baby!!!" Archivists have come a long way from the development of SPINDEX in the early 1970s. Back then, it seemed that archiv- ists needed software written for mainframe computers in order to have the flex- ibility (i. e. variable length fields and user designated tags) and storage capacity necessary to store and retrieve information on archival material. While SPIN- DEX has not been completely superceded for certain applications (i. e., print- ing lists for large institutions with a high volume of data), archivists in the 1980s have found that micro- and minicomputers can provide a relatively low cost alternative which can offer new features such as on-line searching and the generation of statistics. It was in the early 1980s that I first heard of archivists using commercially available software on microcomputers. They were using word processors and file managers like PFS, Data Factory, and DB Master on Apple computers with limited memory. Later, archivists stepped up to IBM PCs and look-alikes with two or three times the internal memory of the Apples. This enabled them to use more sophisticated relational database managers such as dBase II and later SAVVY, which require programming through the use of a command language. Archivists also began mixing powerful computers and mass storage (fixed disk) with simple file managers, some of which are reviewed in this issue of The Mid- western Archivist. Another software package that took advantage of the added power of the IBM PC was MARCON, a'database manager written especially for archivists by AIRS, a software developer group-with an archival background.
    [Show full text]