The Lorax Programming Language
|
|
- Hollie Spencer
- 5 years ago
- Views:
Transcription
1 The Lorax Programming Language Doug Bienstock, Chris D Angelo, Zhaarn Maheswaran, Tim Paine, and Kira Whitehouse dmb2168, cd2665, zsm2103, tkp2108, kbw2116 Programming Translators and Languages, Department of Computer Science, Columbia University, New York, NY 10027, USA Abstract Here we propose a language based upon the tree data structure. Whereas a language like Java relies on an inheritance structure deviating from the type Object, we propose a paradigm wherein the tree, which can be used effectively to represent lists, graphs, queues, stacks, etc, becomes the central object around which the language is structured. Much like Lisp and lists, our language seeks to naturalize the tree structure to allow for fast and simple tree based algorithms, while maintaining the flexibility to code other data structures within tree based constructs. 1 Motivation The motivation for our language arose out of frustration with implementing trees and tree based algorithms in other high level programming languages. While languages like C and Java allow you to implement trees, they are not a native aspect of the language. As such, you must define and manage the node structure yourself, which can be a tedious and complicated affair, especially for young programmers, or those who are inexperienced with tree data structures. Trees are often simply a construct of the language, rather than something fundamental to its structure, like the object of an object oriented language, or the function of a functional language. Our language attempts to remedy these problems by handling a lot of the business logic of implementing trees and their algorithms under the hood, and allowing the programmer to use trees in a more native and intuitive way. This simplicity combined with added features of our language allow new and unconventional applications beyond those easily managed by typical object-centric programming languages. An intuitive application is to easily build and maintain a min-heap or a binary search tree of strings. A more complex situation could be to create a tree structure used to manage an organizational hierarchy for a company. A programmer could implement the tree structure in this language to manage and perform operations on an organization?s employees easily. Virtually any tree-based algorithm should now be much easier and more natural to program, and in fewer lines. 1
2 2 Syntax 2.1 Data Types Type Description Example int an integer, typically reflecting a machine s natural integer size 1972 double double-precision floating point 3.14 string capable of holding multiple characters in the local character set I love trees tuple a grouping of data encapsulated in a single tree node 5, five tree a collection of data with a parent-child relationship 1[2, 3[4, 5]] A tree can be initialized a variety of ways. It can be instantiated with null elements, such that children are not defined with any inherent data. Trees can also be defined to hold tuples as their data types. Trees have branching factors, i.e. a maximum number of children. When trees of different branching factors are added together, the larger branching factor is inherited, so that both trees share the same branching factor. A tree can only hold one type of data: thus, whether the children hold data of type double or string or tuples of doubles and strings, all nodes of the tree must be this same type. On the other hand, tuples may contain data of multiple types. This type ruling will be enforced on compile time. 2.2 Arithmetic, Relational, and Logical Operators = = ==!= Compares values within tuples and trees. All comparisons return a tree with no children and a sole integer value, 1 for true, 0 for Accesses the data element of a tree node. This operation is used to access the int, double, and string data types stored within trees. For instance, given a tree x whose 0th child is a tuple 3, six, 9.0. We can access the string six with the operation 0 % These operations induce compile time errors if not used correctly with types. If both types involved are doubles or integers, this simply produces the mathematical addition or subtraction of the two numbers. If both types involved are strings, the + operator simply concatenates the two strings, one following the other. If both types involved are trees, the + operator operation constructs a new tree consisting of both. The two original trees are glued together into an anonymous tree, which can be assigned to a variable. Note: the subtraction - operation cannot be used with strings or trees; this will induce a compile time error. 2
3 2.3 Tokens The following identifiers are reserved for use as keywords, and may not be used otherwise. root(tree) children(tree) print(value) Returns the root of a tree, without any children, but does not dereference its value. The original tree passed in as an argument is unchanged. Returns an ordered set of the children of the input tree. The set can be operated on but cannot be assigned using the = operator. This design choice prevents users from manipulating trees. Prints to standard output the value provided as an argument. Values supported are doubles, ints, and strings. 3 Control Flow 3.1 Statements and Blocks ; The semicolon is a statement terminator. /*Hi I am a comment. */ These are multi-line comments. They are not nestable. // These are single line comments. 3.2 If-Else and Loops if(expression) statement else statement for(expression) The if-else statement is used to express decisions. Any expression evaluated will not compile unless it can evaluate to a valid boolean. For loops contain an assignment, a boolean conditional expression, and an incrementor. 3
4 4 Miscellaneous Standard Library Functions height(tree) empty(tree) type(tree) branchingfactor(tree) Returns a tree with no children and data representing the height of the input tree. Returns whether or not a tree is empty. Note this is the same as checking whether the tree is null, but may not return the same value as height if applied to a tree of height 0. This returns a tree with no children and data representing a boolean 0 or 1. This is helpful when applied to trees who have been declared with branching values, but not defined with any internal data. Returns a tree with no children containing solely a string representation of the type of data stored in the parameter tree s nodes. For instance, a possible return value might be int or int, string, double, int. Returns a tree with no children and data representing the branching factor of the input tree. 5 Program Structure Below we provide a short sample program to demonstrate the syntax and flow of our language. In short, there is a main function and a user defined depthfirstsearch function. The interpreter will only run the main function. Thus, if we did not call depthfirstsearch from within main, that code would never be stepped into during the course of program execution. We provide sparse comments within the program, and point out some important subtleties beneath the complete source code. 1 / a r e c u r s i v e f u n c t i o n moving d e p t h f i r s t through a t r e e p r i n t i n g i t s d a t a / depthfirstsearch ( t r e e ) { 3 i f ( t r e e == n u l l ) return n u l l ; 5 / p r i n t t h e f i r s t v a l u e ( t h e d a t a ) w i t h i n t h e t u p l e / 7 print ( t r e 0) ; 9 / use s e c o n d v a l u e o f t u p l e as key v a l u e f l a g t o mark node as v i s i t e d / t r e 1 = 1 ; 11 / i t e r a t e through t h e t r e e r e c u r s i v e l y / 13 for ( c h i l d = 0 ; t r e e % c h i l d!= n u l l ; c h i l d += 1) { / c h e c k i f we have v i s i t e d c h i l d b e f o r e making r e c u r s i v e c a l l / 15 i f ( ( t r e e % c h i l d 1 == 0) { depthfirstsearch ( t r e e % c h i l d ) ; 17 } } 19 } 4
5 1 / A program must have a main f u n c t i o n, as t h i s w i l l be t h e only c o d e run by t h e i n t e r p r e t e r. Any command l i n e arguments w i l l be p a s s e d in in a t r e e d a t a s t r u c t u r e. / main ( command line arguments ) { 3 / a i s a multi l e v e l t r e e with i n t e g e r c h i l d r e n / 5 a = 1 [ 2, 3 [ 4, 5 ] ] ; 7 / b i s a t r e e with no c h i l d r e n, whose d a t a i s i n t e g e r 6 / b = 6 [ ] ; 9 / c i s a t r e e with no data, no c h i l d r e n, and a d e c l a r e d max d e g r e e o f 4 / 11 c = [ ] ( 4 ) ; 13 / d i s a t r e e whose c h i l d r e n a r e t u p l e s o f t y p e <i n t, s t r i n g, double > / d = <101, h e l l o, 3.14 >[ <102, goodbye, > ] ; 15 / a c c e s s t h e 0 th d a t a e l e m e n t w i t h i n t r e e d, r e t u r n i n g i n t e g e r 101 / 17 0 ; / a c c e s s t h e 0 th d a t a e l e m e n t w i t h i n t r e e a, r e t u r n i n g i n t e g e r 1 / 19 0 ; 21 / a c c e s s t h e 0 th c h i l d o f t r e e a, r e t u r n i n g a t r e e whose d a t a item i s 2 / a % 0 ; 23 / a c c e s s t h e 0 th d a t a e l e m e n t in t h e 0 th c h i l d o f a, r e t u r n i n g i n t e g e r 2 / a % 0 ; 25 t r e e t o p r i n t = <1, 0 >[ <2, 0 >, <3, 0 >[ <4, 0 >, <5, 0 > ] ] ; 27 / t h i s f u n c t i o n c a l l w i l l p r i n t / depthfirstsearch ( t r e e t o p r i n t ) ; 29 } A couple important notes to make about the program above, before we dive more explicitly into the code. In the creation of all of these trees the compiler will be sure to keep the integrity of the tree data structure. Some rules that it will obey: 1. A tree can only have at most one parent 2. A tree cannot be parent to his own parent 3. A tree cannot be parent to his brother Note, as a result of these rules, that our language does not support internal loops, or any form of graphs. In the beginning lines of the main function above, we defined trees a and b. The definition a = 1[2, 3[4, 5]]; is displayed below in a visual sense:
6 Each leaf node, i.e. the nodes without any children, points to null. The compiler will conclude that this tree contains data type int and degree 2. Initializing a tree with improper combinations of data types would result in a compile time error. The definition of tree b = 6[]; is a little more difficult to explain with diagrams. This tree has no children, but has the integer 6 in its data field. There are a couple of other ways in which we could have defined this tree. For instance, we could have defined b as b = 6 [];. Here we use the explicit tuple bracket operators. Importantly, every data item in a tree is actually a tuple. Tuples are very much related to trees. They contain collections of items. However, unlike trees, tuples can contain data of different types. Trees cannot mix data types. It would have also been possible to define b simply as b = 6. This reveals the inherent tree-ness of our language. Even primitive data types are initialized and stored in tree data structures. Here we will look at the two more obscure operators in the program above, operator and the % operator. The % operator allows us to access the internals of a tree s structure; that is, its children. Because children are kept in an ordered listing we can refer to them with indexing. Note that the % operator returns a pointer to a single child, not an array or list of multiple children. We use the % operator to traverse through a tree in the depth- FirstSearch function. operator allows us to access data within a tree node. We can combine the % operators to access the data within a child tree. With the functionality of these operators in mind, let s take one last look at the main loop within the depthfirstsearch function. 1 for ( c h i l d = 0 ; t r e e % c h i l d!= n u l l ; c h i l d += 1) { / c h e c k i f we have v i s i t e d t h i s c h i l d / 3 i f ( ( t r e e % c h i l d 1 == 0) { / e x t r a c t t h e i n t e g e r d a t a from t h e c h i l d t r e e and c a l l DFS r e c u r s i v e l y / 5 depthfirstsearch ( t r e e % c h i l d ) ; } 7 } Above, child = 0 is defining a tree whose data is a tuple containing a single integer 0. This initialization syntax is creating a childless tree, and is syntactic sugar in some regards. It is the shortened form of declaring child = 0[]. The condition and afterthought of the for loop, tree % child!= null and child += 1 respectively, are also syntactic sugar. In both of these expressions child is short for 0. This shortened form makes it easy for the programmer to iterate through all the children of a given tree. 6
Introduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationLanguage Authors. Doug Bienstock (dmb2168) Chris D Angelo (cd2665) Zhaarn Maheswaran (zsm2103) Tim Paine (tkp2108) Kira Whitehouse (kbw2116)
Language Authors Doug Bienstock (dmb2168) Chris D Angelo (cd2665) Zhaarn Maheswaran (zsm2103) Tim Paine (tkp2108) Kira Whitehouse (kbw2116) December 19, 2013 Developed for Columbia University s Fall 2013
More informationData Abstractions. National Chiao Tung University Chun-Jen Tsai 05/23/2012
Data Abstractions National Chiao Tung University Chun-Jen Tsai 05/23/2012 Concept of Data Structures How do we store some conceptual structure in a linear memory? For example, an organization chart: 2/32
More informationIntermediate Code Generation
Intermediate Code Generation In the analysis-synthesis model of a compiler, the front end analyzes a source program and creates an intermediate representation, from which the back end generates target
More informationJME Language Reference Manual
JME Language Reference Manual 1 Introduction JME (pronounced jay+me) is a lightweight language that allows programmers to easily perform statistic computations on tabular data as part of data analysis.
More informationDATA STRUCTURES CHAPTER 1
DATA STRUCTURES CHAPTER 1 FOUNDATIONAL OF DATA STRUCTURES This unit introduces some basic concepts that the student needs to be familiar with before attempting to develop any software. It describes data
More informationSection 4 SOLUTION: AVL Trees & B-Trees
Section 4 SOLUTION: AVL Trees & B-Trees 1. What 3 properties must an AVL tree have? a. Be a binary tree b. Have Binary Search Tree ordering property (left children < parent, right children > parent) c.
More informationC# and Java. C# and Java are both modern object-oriented languages
C# and Java C# and Java are both modern object-oriented languages C# came after Java and so it is more advanced in some ways C# has more functional characteristics (e.g., anonymous functions, closure,
More informationExpressions and Casting. Data Manipulation. Simple Program 11/5/2013
Expressions and Casting C# Programming Rob Miles Data Manipulation We know that programs use data storage (variables) to hold values and statements to process the data The statements are obeyed in sequence
More informationChapter 2: Using Data
Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that
More informationObject oriented programming. Instructor: Masoud Asghari Web page: Ch: 3
Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning
More informationExpressions and Casting
Expressions and Casting C# Programming Rob Miles Data Manipulation We know that programs use data storage (variables) to hold values and statements to process the data The statements are obeyed in sequence
More informationCS 231 Data Structures and Algorithms, Fall 2016
CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard
More information1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8
Epic Test Review 1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4 Write a line of code that outputs the phase Hello World to the console without creating a new line character. System.out.print(
More informationChapter 2 Working with Data Types and Operators
JavaScript, Fourth Edition 2-1 Chapter 2 Working with Data Types and Operators At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics
More informationCS301 - Data Structures Glossary By
CS301 - Data Structures Glossary By Abstract Data Type : A set of data values and associated operations that are precisely specified independent of any particular implementation. Also known as ADT Algorithm
More informationSEMANTIC ANALYSIS TYPES AND DECLARATIONS
SEMANTIC ANALYSIS CS 403: Type Checking Stefan D. Bruda Winter 2015 Parsing only verifies that the program consists of tokens arranged in a syntactically valid combination now we move to check whether
More informationJava Primer 1: Types, Classes and Operators
Java Primer 1 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Java Primer 1: Types,
More informationThink of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern
Think of drawing/diagramming editors ECE450 Software Engineering II Drawing/diagramming editors let users build complex diagrams out of simple components The user can group components to form larger components......which
More informationChapter 11. Categories of languages that support OOP: 1. OOP support is added to an existing language
Categories of languages that support OOP: 1. OOP support is added to an existing language - C++ (also supports procedural and dataoriented programming) - Ada 95 (also supports procedural and dataoriented
More informationCE221 Programming in C++ Part 2 References and Pointers, Arrays and Strings
CE221 Programming in C++ Part 2 References and Pointers, Arrays and Strings 19/10/2017 CE221 Part 2 1 Variables and References 1 In Java a variable of primitive type is associated with a memory location
More informationChapter 8: Data Abstractions
Chapter 8: Data Abstractions Computer Science: An Overview Eleventh Edition by J. Glenn Brookshear Copyright 2012 Pearson Education, Inc. Chapter 8: Data Abstractions 8.1 Data Structure Fundamentals 8.2
More informationComputer Science 210 Data Structures Siena College Fall Topic Notes: Trees
Computer Science 0 Data Structures Siena College Fall 08 Topic Notes: Trees We ve spent a lot of time looking at a variety of structures where there is a natural linear ordering of the elements in arrays,
More informationMotivation was to facilitate development of systems software, especially OS development.
A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationfor (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; }
Ex: The difference between Compiler and Interpreter The interpreter actually carries out the computations specified in the source program. In other words, the output of a compiler is a program, whereas
More informationLanguage Reference Manual simplicity
Language Reference Manual simplicity Course: COMS S4115 Professor: Dr. Stephen Edwards TA: Graham Gobieski Date: July 20, 2016 Group members Rui Gu rg2970 Adam Hadar anh2130 Zachary Moffitt znm2104 Suzanna
More informationSECTION II: LANGUAGE BASICS
Chapter 5 SECTION II: LANGUAGE BASICS Operators Chapter 04: Basic Fundamentals demonstrated declaring and initializing variables. This chapter depicts how to do something with them, using operators. Operators
More informationWhat are the characteristics of Object Oriented programming language?
What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationIndex. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309
A Arithmetic operation floating-point arithmetic, 11 12 integer numbers, 9 11 Arrays, 97 copying, 59 60 creation, 48 elements, 48 empty arrays and vectors, 57 58 executable program, 49 expressions, 48
More informationGraphiti A Simple Graph Language. Language Reference Manual
Graphiti A Simple Graph Language Language Reference Manual Alice Thum, System Architect, at3160@barnard.edu Sydney Lee, System Architect, stl2121@barnard.edu Michal Porubcin, Language Guru, mp3242@columbia.edu
More informationA short, pragmatic and INCOMPLETE intro to C++/ROOT programming. Mikołaj Krzewicki Nikhef/UU
A short, pragmatic and INCOMPLETE intro to C++/ROOT programming. Mikołaj Krzewicki Nikhef/UU C++ Middle-level, statically typed, free-form, multiparadigm, compiled language(wikipedia.org). Development
More informationMIDTERM EXAMINATION Spring 2010 CS301- Data Structures
MIDTERM EXAMINATION Spring 2010 CS301- Data Structures Question No: 1 Which one of the following statement is NOT correct. In linked list the elements are necessarily to be contiguous In linked list the
More informationMULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR
STUDENT IDENTIFICATION NO MULTIMEDIA COLLEGE JALAN GURNEY KIRI 54100 KUALA LUMPUR FIFTH SEMESTER FINAL EXAMINATION, 2014/2015 SESSION PSD2023 ALGORITHM & DATA STRUCTURE DSEW-E-F-2/13 25 MAY 2015 9.00 AM
More informationSummer Final Exam Review Session August 5, 2009
15-111 Summer 2 2009 Final Exam Review Session August 5, 2009 Exam Notes The exam is from 10:30 to 1:30 PM in Wean Hall 5419A. The exam will be primarily conceptual. The major emphasis is on understanding
More informationOutline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring
Java Outline Java Models for variables Types and type checking, type safety Interpretation vs. compilation Reasoning about code CSCI 2600 Spring 2017 2 Java Java is a successor to a number of languages,
More informationMID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct.
MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct. In linked list the elements are necessarily to be contiguous In linked list the elements may locate at far positions
More informationChapter 8: Data Abstractions
Chapter 8: Data Abstractions Computer Science: An Overview Tenth Edition by J. Glenn Brookshear Presentation files modified by Farn Wang Copyright 28 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
More information2.2 Syntax Definition
42 CHAPTER 2. A SIMPLE SYNTAX-DIRECTED TRANSLATOR sequence of "three-address" instructions; a more complete example appears in Fig. 2.2. This form of intermediate code takes its name from instructions
More informationChapter 20: Binary Trees
Chapter 20: Binary Trees 20.1 Definition and Application of Binary Trees Definition and Application of Binary Trees Binary tree: a nonlinear linked list in which each node may point to 0, 1, or two other
More informationeasel LANGUAGE REFERENCE MANUAL
easel LANGUAGE REFERENCE MANUAL Manager Danielle Crosswell dac2182 Language Guru Tyrus Cukavac thc2125 System Architect Yuan-Chao Chou yc3211 Tester Xiaofei Chen xc2364 Table of Contents 1. Introduction...
More informationProgramming for the Web with PHP
Aptech Ltd Version 1.0 Page 1 of 11 Table of Contents Aptech Ltd Version 1.0 Page 2 of 11 Abstraction Anonymous Class Apache Arithmetic Operators Array Array Identifier arsort Function Assignment Operators
More informationScala : an LLVM-targeted Scala compiler
Scala : an LLVM-targeted Scala compiler Da Liu, UNI: dl2997 Contents 1 Background 1 2 Introduction 1 3 Project Design 1 4 Language Prototype Features 2 4.1 Language Features........................................
More informationCSE 12 Abstract Syntax Trees
CSE 12 Abstract Syntax Trees Compilers and Interpreters Parse Trees and Abstract Syntax Trees (AST's) Creating and Evaluating AST's The Table ADT and Symbol Tables 16 Using Algorithms and Data Structures
More informationProject Proposal. Programming Languages and Translators - Fall Team
JO Project Proposal Programming Languages and Translators - Fall 2014 [ ] Team "Name" : "Abhinav Bajaj", "UNI" : "ab3900", "Role" : "System Architect", "Name" : "Arpit Gupta", "UNI" : "ag3418", "Role"
More informationJava Overview An introduction to the Java Programming Language
Java Overview An introduction to the Java Programming Language Produced by: Eamonn de Leastar (edeleastar@wit.ie) Dr. Siobhan Drohan (sdrohan@wit.ie) Department of Computing and Mathematics http://www.wit.ie/
More informationCSE 431S Type Checking. Washington University Spring 2013
CSE 431S Type Checking Washington University Spring 2013 Type Checking When are types checked? Statically at compile time Compiler does type checking during compilation Ideally eliminate runtime checks
More informationC++ (Non for C Programmer) (BT307) 40 Hours
C++ (Non for C Programmer) (BT307) 40 Hours Overview C++ is undoubtedly one of the most widely used programming language for implementing object-oriented systems. The C++ language is based on the popular
More informationCSCI 171 Chapter Outlines
Contents CSCI 171 Chapter 1 Overview... 2 CSCI 171 Chapter 2 Programming Components... 3 CSCI 171 Chapter 3 (Sections 1 4) Selection Structures... 5 CSCI 171 Chapter 3 (Sections 5 & 6) Iteration Structures
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationFinal exam. Final exam will be 12 problems, drop any 2. Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers)
Review Final exam Final exam will be 12 problems, drop any 2 Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers) 2 hours exam time, so 12 min per problem (midterm 2 had
More informationCS 270 Algorithms. Oliver Kullmann. Binary search. Lists. Background: Pointers. Trees. Implementing rooted trees. Tutorial
Week 7 General remarks Arrays, lists, pointers and 1 2 3 We conclude elementary data structures by discussing and implementing arrays, lists, and trees. Background information on pointers is provided (for
More informationCONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17
List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code
More informationOverview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017
Overview of OOP Dr. Zhang COSC 1436 Summer, 2017 7/18/2017 Review Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in square brackets: l = [1, 2, "a"] (access by index, is mutable
More informationCS260 Intro to Java & Android 03.Java Language Basics
03.Java Language Basics http://www.tutorialspoint.com/java/index.htm CS260 - Intro to Java & Android 1 What is the distinction between fields and variables? Java has the following kinds of variables: Instance
More informationMultiple choice questions. Answer on Scantron Form. 4 points each (100 points) Which is NOT a reasonable conclusion to this sentence:
Multiple choice questions Answer on Scantron Form 4 points each (100 points) 1. Which is NOT a reasonable conclusion to this sentence: Multiple constructors for a class... A. are distinguished by the number
More informationCS 330 Lecture 18. Symbol table. C scope rules. Declarations. Chapter 5 Louden Outline
CS 0 Lecture 8 Chapter 5 Louden Outline The symbol table Static scoping vs dynamic scoping Symbol table Dictionary associates names to attributes In general: hash tables, tree and lists (assignment ) can
More informationBuilding Java Programs
Building Java Programs Binary Trees reading: 17.1 17.3 2 Trees in computer science TreeMap and TreeSet implementations folders/files on a computer family genealogy; organizational charts AI: decision trees
More informationCHAD Language Reference Manual
CHAD Language Reference Manual INTRODUCTION The CHAD programming language is a limited purpose programming language designed to allow teachers and students to quickly code algorithms involving arrays,
More informationTaking Stock. IE170: Algorithms in Systems Engineering: Lecture 7. (A subset of) the Collections Interface. The Java Collections Interfaces
Taking Stock IE170: Algorithms in Systems Engineering: Lecture 7 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University January 29, 2007 Last Time Practice Some Sorting Algs
More informationfor (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; }
Ex: The difference between Compiler and Interpreter The interpreter actually carries out the computations specified in the source program. In other words, the output of a compiler is a program, whereas
More informationPace University. Fundamental Concepts of CS121 1
Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction
More informationCS102 Binary Search Trees
CS102 Binary Search Trees Prof Tejada 1 To speed up insertion, removal and search, modify the idea of a Binary Tree to create a Binary Search Tree (BST) Binary Search Trees Binary Search Trees have one
More informationSPARK-PL: Introduction
Alexey Solovyev Abstract All basic elements of SPARK-PL are introduced. Table of Contents 1. Introduction to SPARK-PL... 1 2. Alphabet of SPARK-PL... 3 3. Types and variables... 3 4. SPARK-PL basic commands...
More informationCPS122 Lecture: From Python to Java last revised January 4, Objectives:
Objectives: CPS122 Lecture: From Python to Java last revised January 4, 2017 1. To introduce the notion of a compiled language 2. To introduce the notions of data type and a statically typed language 3.
More informationTopics. Java arrays. Definition. Data Structures and Information Systems Part 1: Data Structures. Lecture 3: Arrays (1)
Topics Data Structures and Information Systems Part 1: Data Structures Michele Zito Lecture 3: Arrays (1) Data structure definition: arrays. Java arrays creation access Primitive types and reference types
More informationCS 231 Data Structures and Algorithms Fall Recursion and Binary Trees Lecture 21 October 24, Prof. Zadia Codabux
CS 231 Data Structures and Algorithms Fall 2018 Recursion and Binary Trees Lecture 21 October 24, 2018 Prof. Zadia Codabux 1 Agenda ArrayQueue.java Recursion Binary Tree Terminologies Traversal 2 Administrative
More informationLesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014
Lesson 10A OOP Fundamentals By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Definition Pointers vs containers Object vs primitives Constructors Methods Object class
More informationCSE 12 Week Eight, Lecture One
CSE 12 Week Eight, Lecture One Heap: (The data structure, not the memory area) - A binary tree with properties: - 1. Parent s are greater than s. o the heap order - 2. Nodes are inserted so that tree is
More informationCS61B Lecture #20: Trees. Last modified: Mon Oct 8 21:21: CS61B: Lecture #20 1
CS61B Lecture #20: Trees Last modified: Mon Oct 8 21:21:22 2018 CS61B: Lecture #20 1 A Recursive Structure Trees naturally represent recursively defined, hierarchical objects with more than one recursive
More informationExam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming
Exam 1 Prep Dr. Demetrios Glinos University of Central Florida COP3330 Object Oriented Programming Progress Exam 1 is a Timed Webcourses Quiz You can find it from the "Assignments" link on Webcourses choose
More informationA brief introduction to C programming for Java programmers
A brief introduction to C programming for Java programmers Sven Gestegård Robertz September 2017 There are many similarities between Java and C. The syntax in Java is basically
More informationCSI33 Data Structures
Outline Department of Mathematics and Computer Science Bronx Community College November 13, 2017 Outline Outline 1 C++ Supplement.1: Trees Outline C++ Supplement.1: Trees 1 C++ Supplement.1: Trees Uses
More informationTypes and Type Inference
CS 242 2012 Types and Type Inference Notes modified from John Mitchell and Kathleen Fisher Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on Web!! Outline General discussion of
More informationn2n A Relational Graphing Language
n2n A Relational Graphing Language Project Manager: Elisheva Aeder (ea2621) Language Guru: Nicholas Ray Falba (nrf2118) System Architect: Johan M. Mena (jmm2371) Verification & Validation: Jialun Liu (jl4347)
More informationSpoke. Language Reference Manual* CS4118 PROGRAMMING LANGUAGES AND TRANSLATORS. William Yang Wang, Chia-che Tsai, Zhou Yu, Xin Chen 2010/11/03
CS4118 PROGRAMMING LANGUAGES AND TRANSLATORS Spoke Language Reference Manual* William Yang Wang, Chia-che Tsai, Zhou Yu, Xin Chen 2010/11/03 (yw2347, ct2459, zy2147, xc2180)@columbia.edu Columbia University,
More informationObjectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program
Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More information12 Abstract Data Types
12 Abstract Data Types 12.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT). Define
More informationValues and Variables 1 / 30
Values and Variables 1 / 30 Values 2 / 30 Computing Computing is any purposeful activity that marries the representation of some dynamic domain with the representation of some dynamic machine that provides
More informationChapter 2: Basic Elements of C++
Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationChapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction
Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers
More informationData Structures (list, dictionary, tuples, sets, strings)
Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 11: Binary Search Trees MOUNA KACEM mouna@cs.wisc.edu Fall 2018 General Overview of Data Structures 2 Introduction to trees 3 Tree: Important non-linear data structure
More informationCIS265/ Trees Red-Black Trees. Some of the following material is from:
CIS265/506 2-3-4 Trees Red-Black Trees Some of the following material is from: Data Structures for Java William H. Ford William R. Topp ISBN 0-13-047724-9 Chapter 27 Balanced Search Trees Bret Ford 2005,
More informationOperators and Expressions
Operators and Expressions Conversions. Widening and Narrowing Primitive Conversions Widening and Narrowing Reference Conversions Conversions up the type hierarchy are called widening reference conversions
More informationSymbol Tables Symbol Table: In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier in a program's source code is
More informationChapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.
Chapter 1 GETTING STARTED SYS-ED/ Computer Education Techniques, Inc. Objectives You will learn: Java platform. Applets and applications. Java programming language: facilities and foundation. Memory management
More informationChapter 1 INTRODUCTION SYS-ED/ COMPUTER EDUCATION TECHNIQUES, INC.
hapter 1 INTRODUTION SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Objectives You will learn: Java features. Java and its associated components. Features of a Java application and applet. Java data types. Java
More informationCSE373: Data Structures & Algorithms Lecture 5: Dictionaries; Binary Search Trees. Aaron Bauer Winter 2014
CSE373: Data Structures & lgorithms Lecture 5: Dictionaries; Binary Search Trees aron Bauer Winter 2014 Where we are Studying the absolutely essential DTs of computer science and classic data structures
More informationC++ for Python Programmers
C++ for Python Programmers Adapted from a document by Rich Enbody & Bill Punch of Michigan State University Purpose of this document This document is a brief introduction to C++ for Python programmers
More informationProgram Abstractions, Language Paradigms. CS152. Chris Pollett. Aug. 27, 2008.
Program Abstractions, Language Paradigms. CS152. Chris Pollett. Aug. 27, 2008. Outline. Abstractions for telling a computer how to do things. Computational Paradigms. Language Definition, Translation.
More informationLanguage Proposal: tail
Language Proposal: tail A tail recursion optimization language Some Wise Gal Team Roles Team Members UNIs Roles Sandra Shaefer Jennifer Lam Serena Shah Simpson Fiona Rowan sns2153 jl3953 ss4354 fmr2112
More informationChapter 1 Getting Started
Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different
More informationCSCI-401 Examlet #5. Name: Class: Date: True/False Indicate whether the sentence or statement is true or false.
Name: Class: Date: CSCI-401 Examlet #5 True/False Indicate whether the sentence or statement is true or false. 1. The root node of the standard binary tree can be drawn anywhere in the tree diagram. 2.
More informationMARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012
MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012 Instructor: K. S. Booth Time: 70 minutes (one hour ten minutes)
More informationA Small Permutation Group Engine by: Gregory Kip. COMS W4115 Programming Languages and Translators Prof. Stephen Edwards
µperm A Small Permutation Group Engine by: Gregory Kip COMS W4115 Programming Languages and Translators Prof. Stephen Edwards Abstract Given the abstract character of much of modern physics and mathematics,
More informationOperational Semantics. One-Slide Summary. Lecture Outline
Operational Semantics #1 One-Slide Summary Operational semantics are a precise way of specifying how to evaluate a program. A formal semantics tells you what each expression means. Meaning depends on context:
More informationPLT: Inception (cuz there are so many layers)
PLT: Inception (cuz there are so many layers) By: Andrew Aday, (aza2112) Amol Kapoor (ajk2227), Jonathan Zhang (jz2814) Proposal Abstract Overview of domain Purpose Language Outline Types Operators Syntax
More information