Intermediate Programming String-Interpretation and Graph-Algorithms Exercise Sheet 4

Size: px
Start display at page:

Download "Intermediate Programming String-Interpretation and Graph-Algorithms Exercise Sheet 4"

Transcription

1 Institute of Scientific Computing Technische Universität Braunschweig Prof. Hermann G. Matthies, Ph. D. Dr. Elmar Zander Winter Term 2013/14 November 14, 2014 Intermediate Programming String-Interpretation and Graph-Algorithms Exercise Sheet 4 Interpretation of Expressions In the development of computational or interactive software, it is often nescessary to interprete complex user input and to transform this input into a system response of the software system. Typing in commands to the command-line of UNIX is an example of such interaction between a user and an interactive language interpreter. Examples as reading of complex data sets from a file into a program or the development of applications for the Internet require the manipulation and interpretation of strings. In this exercise the manipulation and interpretation of strings is focused. Implementing interpreters for simple expressions is not hard, compared to writing interpreters for complex languages as programming languages. For such a task professional tools like JavaCC or ANTLR should be used, which provide code generators for such interpreters. For simple expressions as we will have to handle here, Java provides integrated support. For describing formal languages, the Backus-Naur-Form (BNF) is an established tool ( Language to Describe Formal Languages In the meta-language BNF (Meta-language means something like Language for describing Languge ) so-called productions can be used to define which form a class of expressions can take. Example: <digit without Null> ::= A digit without Null is a 1, or a 2, or a 3,... This production rule describes, what digit without Null is. Rules can also define sequences, in which certain symbols occur in predefined order: <digit> ::= 0 <digit without Null> <two-digit number> ::= <digit without Null> <digit> <ten to nineteen> ::= 1 <digit> <fourtytwo> ::= 42 A digit is therefore defines as a 0 or a digit without Null. A two-digit number is defined as a digit without Null followed by a digit. Fourtytwo id defined as a 4 followed by a 2. Repitations of symbols can be defined in BNF also, therefore recursions of production-rules have to be used. A production rule with the left-hand symbol on the right-hand side is such a recursion: <digit string> ::= <digit> <digit> <digit string>

2 Reading: A digit string is a digit or a digit followed by a digit string. With the help of such productions we can easily define arbitrary complex expressions. We want to use the BNF on this exercise sheet to describe a very simple language for defining graphs. Therefore we at first present you the basics os graph theory. Graphs for modelling Routes A Graph in the sense of mathematical graph theory consists of a set (the so-called nodes or vertices of the graph) and of direct connections between the them (the so-called edges of the graph). Mathematically speaking, a graph G is a tupel (V, E), where V is a set of nodes and E is a set of edges. An example which fulfulls this definition is given by: G 1 = ({1, 2, 3}, {(1, 2), (3, 1), (3, 2)}) This graph G 1 has three nodes, the digits 1, 2 and 3; and it has three nodes from the digit 1 to 2 and from digit 3 to both 1 and 2. It is also possible to illustrate graphs graphically, the graph G 1 is for example visualised in 3 figure 1. Graphs like these have applications in many domains of science and are of great importance. They are used in electrotechnology e.g. in circuit engineering to modell circuits, in computer-science to model processes and data-structures and in mathematics to model descrete topologies; the list of 1 2 applications can be made arbitrary long. Pracicle relevance in every-day life can be found e.g. in stree-navigation, where places are represented by nodes Figure 1: Graphic representation of Graph G 1 and connection-ways between the nodes are modelled represented by edges. The graph in figure 2 shows a modell of the connection-ways between the traffic-nodes Braunschweig, Hannover and Hamburg. The connections between the nodes are annotated with the name of the autobahn connecting the cities. With the help of this graph you can already calculate a route to get from Braunschweig to Hamburg. If all cities of Germany with all streets where present in the graph, we would be able to find a path between arbitrary nodes in the graph. A2 Braunschweig Hannover A2 A7 A7 Hamburg Braunschweig A2 dist=62.32 A2 dist=61.31 A7 dist=148.2 Hannover Hamburg A7 dist=149.3 Figure 2: A simplified graph of the connections between Hamburg, Hannover and Braunschweig. Figure 3: A simplified graph of the connections between Hamburg, Hannover and Braunschweig with annotated distances. It is obvious that any route we find in the graph does not have to be nescessarily the shortest, because in the graph are no informations present for the distances between the nodes, which are nescessary for

3 finding a route with minimal distance. This function is known from every modern navigation system. For increasing the information content of the graph more data can be added to nodes and/or edges. Such additional information may be the distances (or in other words the cost) of an edge, the traffic jam likelihood, the coordinates of the nodes,... This is exemplary done in figure 3. If the data represent the real situation you can realy use the graph for finding the shortest path between traffic nodes in the real world. By enriching the graph with further information, many other things can be computed easily; the application is only bounded by fantasy. A Language for describing Graphs In the last paragraph we gave a mathematical definition of graphs; formaly a graph consists of a set of nodes and a set of edges. G = (V, E) For developing a language for the description of these entities, we need in our new language expressions to define them. An example for such language in BNF is: <NAME> <REAL> ::= <STRING a-z 0-9 _ > ::= <FLOAT> <NODEDEFINITION> ::= NODE ( <NAME> ) <EDGEDEFINITION> ::= EDGE ( <NAME>, <NAME>, <REAL> ) <HELPCALL> ::= HELP <QUITCALL> ::= QUIT As you can see we neglected many details in the first two definitions, we did not give a precise formal definition of the productions. The language defined here is called regular. That is, the language is simple compared to other languages which can also be specified in BNF. Therefore we can evaluate strings containing this language by using so-called regular expressions in Java (class java.util.regex.pattern). Those expressions can immediately be derived from the BNF definition, and using placeholders we are able to extract particular values like node names and edge weights from strings that comply with the language definition. Exercise 1: Shortest Path Algoritms Floyd-Warshall At first you should read and understand the source code given at ADV/files/exercise4/graph.zip. If you have understood the structure you will realize that the presented program is easy to extend. Therefore do not get put off if you do not understand it immediately. Programs which evaluate formally defined languages are called parsers. Thus the program provided by us contains a parser as well, which is implemented in the file Parser.java. Please have a look at this file first. In the method parsecommmand(string command) the parser attempts to identify one of our BNF-defined language elements (NODE( ), HELP etc.) in the given string command and on success extracts the particular parameters. The identified elements are then interpreted as instructions to construct a graph. Elements that do not contain any parameters can be parsed using simple string comparisons (e.g. command.equalsignorecase("quit")), for all other elements we use the abovementioned regular expressions to identify the structure of the given command (NODE( ) or EDGE(,, ). For this purpose a Matcher object is constructed from each regular expression in conjunction with the input string. The Matcher checks if the input string matches the regular expression it was constructed from. If it does, the parameter values are extracted from the input. In a regular expression, extractable parameters

4 are marked with parentheses. Those special placeholders are called groups. Groups are indexed from left to right starting from 1 and their values can be retrieved using the method Matcher.group(int position). 1 else if(command.equalsignorecase("quit")) { 2 interpreter.quit(); 3 } 4 else if(edge_regex.matcher(command).matches()) { 5 // regex matches, extract given values 6 Matcher matcher = EDGE_REGEX.matcher(command); 7 8 // must be called again to make group access available 9 matcher.matches(); // extract values 12 String sourcename = matcher.group(1); 13 String targetname = matcher.group(2); 14 // convert to double value 15 double weight = Double.parseDouble(matcher.group(3)); // invoke corresponding interpreter method 18 interpreter.addedge(sourcename, targetname, weight); 19 } Listing 1: Excerpt from method Parser.parseCommand The development of regular expressions would require in-depth explanation of the complex syntax and therefore is not covered in this exercise. We will provide regular expressions in the following tasks as needed. See for detailed information. When the parser recognizes a command it invokes the corresponding method of the interpreter object that was specified in the parser constructor. The intepreter performs the actual construction of the graph and controls the remainder of the program. We could have constructed the graph directly within the parser, however this functional separation has some advantages and is done in complex software systems. This way we can for instance simply exchange the current parser with a different one without having to reimplement the construction of the graph. If the parser cannot identify any valid command, it throws a ParseException, which is caught in the main class of the program (Main.java). The main class just reads entire lines from the console and hands them over to the parser. The interpreter (file Interpreter.java) gradually adds nodes and edges to the graph object. The graph is implemented using the classes Graph, Node and Edge. Please read the source code comments of these classes carefully, as you will need them later in this exercise to implement some algorithms. The presented program allows to read in graphs from files and can perform arbitrary algorithms on them. An important problem concerning complex graphs is the search for the shortest path from one node to another, minimising the cost. In the example given in figure 3 it was almost trivial to find the shortest path, because there was no alternative path available. If the considered graph is larger than this one, and

5 1 void addedge(string sourcename, String targetname, double weight) { 2 graph.addedge(sourcename, targetname, weight); 3 } 4 5 void addnode(string nodename) { 6 graph.addnode(nodename); 7 } Listing 2: Excerpt from file Interpreter.java alternative routes are possible, the solution of the shortest path problem gets much harder. In the worst case even every possible route has to be systematically explored. This proceeding implements the so-called Floyd-Warshall algorithm, which you will have to implement in this task. The algorithm would not be used in modern navigation-systems, but it is easy to understand and implement, so it is good enough for us. A big problem of the Floyd-Warshall proceeding is its high (cubic) computational complexity in the number of nodes. Additionally the memory complexity of this proceeding is squared in the number of nodes, which means that a small graph with just nodes requires already memory fields and (with a size of double of 8 Bytes) 8MB are required for this small problem. If the problem-size is increased to , the required memory is already 800 MB. A modern navigation-system has to solve the problem with many more nodes and many less hardware, which makes the Floyd-Warshall algorithm not applicable in this domain. But neglecting this problem, we implement this algorithm for our purpose of learning. Note: The Floyd-Warshall algorithm is presented here as pseudocode. It determines the shortest distance between node source and node target in graph. FLOYDWARSHALL(source, target, graph) 1 n = number of nodes in graph //diagonal entries initially zero, all other entries infinity (Double.MAX VALUE) 2 costs = n n matrix 3 for each edge in graph 4 do costs[edge.source.id][edge.target.id] = edge.weight //floyd-warshall phase 5 for k 1 to n 6 do for i 1 to n 7 do for j 1 to n 8 do costs[i][j] = MIN(costs[i][j], costs[i][k] + costs[k][j]) 9 return costs[source.id][target.id] Note: When implementing the given pseudocode, please bear in mind that java array indices start at 0.

6 Task a) Implement the Floyd-Warshall algorithm in the file Graph.java, which you can find at The method header public double getshortestdistance(string sourcename, String targetname) is provided already, you just have to implement the body of the method. Also utilize the provided objects and methods of the graph data structure. Task b) Integrate and implement a new command SHORTESTDISTANCE(Source,Target) into the interpreter, which calculates and displays the shortest distance between the two nodes Source and Target. Employ the algorithm implemented in the previous task. The BNF of the new command is: <SHORTESTDISTANCECALL> ::= SHORTESTDISTANCE ( <NAME>, <NAME> ) Use the following regular expression: shortestdistance\\(([\\w]+),([\\w]+)\\) In order to parse the command and extract its parameters, use the already implemented commands NODE and EDGE as examples. The name of the source node resides in group 1, the target node name in group 2. Task c) Start the program with java Main and use file graph.in as its input (for example via input redirection). In this file we have defined a simple test graph and compute three sample routes. Verify your implementation using the following results: hamburg ---(210,52)---> braunschweig hamburg ---(328,30)---> muenster muenster ---(494,52)---> berlin Test your program with further input. Task d) Add new nodes and edges to the file graph.in and test your algorithm further. By now we considered how to save and restore complex data structures from a file. In the practice of software engineering, this is a common task. Another important technique is dynamic data structures, because without them programs would be less flexible and certain algorithms cannot be implemented. On a prior exercise sheet we considered already sorting and searching procedures, which used an array as basis data type. Many algorithms require structures as list in which new entries can also be efficiently added in the middle (this is not possible with an array) or trees allowing search queries, which require less than log 2 n steps. Since dynamic data structures play an important role, we are going to demonstrate this technique by implementing a so-called doubly linked list in the following task. The list concept depicted in figure 4 consists of two classes:

7 Class CircularList The main class CircularList in the upper left provides operations for manipulating the list (add, remove, determine its size). For that purpose the class maintains a reference to the first entry of the list (its head). 1 public class CircularList<T> implements Iterable<T> { 2 3 private static class Entry<T> { 4 Entry<T> next; 5 Entry<T> prev; 6 T value; 7 } 8 9 // first element 10 private Entry<T> head; 11 public int size(); 12 public void append(t value); Figure 4: Concept of a doubly linked list, which can be implemented in Java 13 //... etc 14 } Listing 3: Implementation of the list depicted in figure 4 Class Entry The actual list consists of objects of the class Entry. For each stored value there is an Entry object. These entries have references to their particular successor (next) and predecessor (prev) in addition to the actual value (field value). Therefore this concept is called a doubly linked list. For instance, in order to access the second entry of such a list, one could use the expression list.head.next.value. In fact single chaining using successor references only would be sufficient to store a list structure. However, the additional predecessor references simplify some list operations that would otherwise have to determine the predecessor of an entry using linear search. Furthermore doubly linked lists can easily be traversed in reverse order. Since the last entry of the list is linked to the head again, the depicted list is also circular. This for instance simplifies the special cases of inserting an element at the head or the tail of a list. In particular there are no nullpointers as each entry always has a successor and a predecessor. Also the last element of the list can be accessed quickly, since it is just the predecessor of the head. In listing 3 we show a part of the implementation of the discussed list concept in Java. The listing contains all the data fields, which are directly named after the fields in figure 4. Furthermore, with the type parameter T the list implementation is generic (as already introduced in Exercise Sheet 3), allowing values of arbitrary types to be stored.

8 Note: Class Entry is defined within class CircularList and is therefore called an inner class. Inner classes are used to express a tight coupling to the defining class. This applies to our Entry class: the list entries are used solely to organize the payload data within the CircularList class and are of no direct importance to other classes. Therefore the Entry class is also marked as private so that classes other than CircularList cannot even access it. The usage of static inner classes does not differ from the usage of regular classes, yet there is one exception: In order to use an inner class from another class, the name of the inner class must be preceded with the name of its enclosing (i.e. defining) class. For example, our entry class would be called CircularList.Entry rather than just Entry. Iterators Iterators are used to traverse a data structure one element after the other, for instance to print each value at the terminal or to evaluate a certain property of each element. Conceptionally, an iterator is a pointer to one element of the data structure, with operations to advance it to the next unvisited element and to check if there are still remaining unvisited elements. The third, right upper component of figure 4 illustrates this: If the list is to be traversed using the iterator, the dashed arrow successively points to each entry of the list. Code using this iterator therefore gradually gains access to each value. In Java, iterators are usually implemented as objects that are created by the particular data structure (list etc.). For iterators Java provides a standardized interface called java.util.iterator, which specifies the elementary iterator operations as next() and hasnext() (see com/javase/7/docs/api/java/util/iterator.html for full description). In one of the following tasks you are to develop a particular implementation for this interface. For further information on iterators, see section and of Textbook Introduction to Programming Using Java [Eck: Sixth Edition]. The java.lang.iterable interface ( java/lang/iterable.html) is closely related to the Iterator interface. It specifies a single parameterless method iterator() that returns an iterator. It is advisable to have every class which provides an iterator implement this interface. Objects of those classes may then be used in the enhanced for loop (sometimes called foreach). Therefore we have already added the interface to our implementation in listing 3. In listing 4 we show an example of the relationship between iterators, Iterable and the enhanced for loop. Revisit section of Textbook Introduction to Programming Using Java [Eck: Sixth Edition] for a detailed explanation. The Principle of separating data-structure from algorithms Writing a program using a list, two different approaches are possible: Embedded the operations to manipulate a list can be written directly into the code a new list entry then requires explicit code inside the algorithm to add the entry to the list, meaning to change the references next and prev of the respective entries locally in the algorithmic code. Encapsulated the operations to manipulate a list can be written separately in form of classes and methods. Methods like insert,append,... which manipulate a list have to be provided. Embedding of manipulation operations results in a strong interweaving of technical code for datastructures and algorithmic code of the application. This interweaving makes it harder to modify the

9 1 class List1 { 2 Iterator iterator(); 3 //... 4 } 5 6 List1 list1 = new List1(); 7 8 // Iterable not implemented, enhanced for loop cannot be used to traverse list1 9 for(iterator it = list1.iterator(); it.hasnext();) { 10 Object next = it.next(); 11 // } class List2 implements Iterable { 15 Iterator iterator(); 16 // } List2 list2 = new List2(); // enhanced for loop simplifies list traversal by hiding the iterator and is otherwise equivalent to the for loop in line 9 22 for(object next : list2) { 23 // } Listing 4: Interface Iterable and enhanced for loop resulting program. Pretend a situation where the list implementation of program is to be changed, e.g. the process of integrating a new entry into the list is to be changed. In the embedded variant the complete application code has to be browsed to find places where the list is manipulated. Therefore interweaving through embedding code obviously has serious disadvantages. In this exercise the advantageous separation of algorithms and data structures is to be trained by implementing a list. Therefore we provide a skeleton implementation for the already discussed linked list concept in file CircularList.java. In a later task, the list is to be used to store routes between cities. Since all needed methods of the class CircularList are already declared, we are able to provide you with a test program which verifies the correct function of your implementation. You can find the test program in the file CircularListTest.java. Exercise 2: List Implementation Task a) Download the template files from list.zip.

10 Task b) Complete the circular list implementation by implementing the methods declared in CircularList.java. Adhere precisely to the specification of each method (documented in the source code). Note: In order to implement the method iterator() you have to define another inner class which implements the Iterator. Afterwards test your implementation with java CircularListTest. Make sure all tests pass without any errors since the following tasks depend on the list being implemented correctly. Task c) Configure Ant to create a dedicated Jar library from your list implementation, which you will use in the following tasks. Application of the CircularList on evaluating routes In the last exercise the Floyd-Warschall Algorithm has been employed to find the shortest distance between two nodes in a graph. Here we will use the algorithm to also calculate the shortest route to take. In this application the Floyd-Warschall algorithm computes a A N n n matrix (where n is the number of nodes in the graph). The algorithm computes for each two nodes i and j an entry A i,j = k which gives the identification number of a node on the shortest route. Because nodes are identified in the program by integer numbers (int), we need an additional integer matrix for this task, which you can create with int[n][n] similarly to double matrices.

11 Note: The Floyd-Warshall algorithm to calculate the shortest path between source and target and its length is presented here as pseudocode: FLOYDWARSHALLROUTE(source, target, graph) 1 n = number of nodes in graph //diagonal entries initially zero, all other entries infinity (Double.MAX VALUE) 2 costs = n n matrix //all entries initially -1 3 route = n n matrix 4 for each edge in graph 5 do costs[edge.source.id][edge.target.id] = edge.weight 6 route[edge.source.id][edge.target.id] = edge.target.id //floyd-warshall phase 7 for k 1 to n 8 do for i 1 to n 9 do for j 1 to n 10 do if (costs[i][j] > costs[i][k] + costs[k][j]) 11 do costs[i][j] = costs[i][k] + costs[k][j] 12 route[i][j] = k 13 waypoints EVALUATEOPTIMALROUTE(route, source.id, target.id) 14 return costs[source.id][target.id] The lines 13 and 14 are both meant to be results of this algorithm. Note: This is the pseudocode for the function EVALUATEOPTIMALROUTE. EVALUATEOPTIMALROUTE(route, source id, target id) 1 result = list of integers 2 waypoint = route[source id][target id] 3 if (source id!= target id and target id waypoint) 4 do subroute1 = EVALUATEOPTIMALROUTE(route, source id, waypoint) 5 result.appendlist(subroute1) 6 subroute2 = EVALUATEOPTIMALROUTE(route, waypoint, target id) 7 result.appendlist(subroute2) 8 else 9 result.append(waypoint) 10 return result

12 Exercise 3: The Shortest Path Finally we have all tools ready to calculate the shortest path between two nodes in a graph. Task a) Implement the above algorithm in the file Graph.java. For the FLOYDWARSHALLROUTE function implement the body of the method public double getshortestpath(string sourcename, String targetname, CircularList<Node> path), and for EVALUATEOPTIMALROUTE use private CircularList<Integer> evaluateoptimalroute(int[][] route, int sourceid, int targetid) accordingly. Employ the CircularList class you have developed on this exercise sheet for the implementation of these methods. Note: The path parameter of the getshortestpath(...) method is to contain an empty list at first, which will be filled with the intermediate nodes of the calculated path (waypoints variable) by the algorithm. Thereby the method can return both the path and the distance. Please note that this list contains full Node objects, whereas the algorithm internally uses node ids only. Therefore you have to eventually convert the list of node ids into a node object list. We provide the method getnode(int id) to assist with this conversion. Task b) Similarly to task 1b), integrate and implement a new command SHORTESTPATH(Source,Target) into the interpreter. The BNF of the new command is: <SHORTESTPATHCALL> ::= SHORTESTPATH ( <NAME>, <NAME> ) Use the following regular expression, again with group numbers 1 and 2. shortestpath\\(([\\w]+),([\\w]+)\\) Have the command display the complete route between the two given nodes. The example output depicted in listing 5 was calculated using the test graph again, therefore you may use it as a reference to verify your implementation.

13 1 hamburg ---(210,52)---> braunschweig 2 via: 3 hannover 4 hamburg ---(328,30)---> muenster 5 via: 6 hannover 7 muenster ---(494,52)---> berlin 8 via: 9 hannover 10 braunschweig 11 magdeburg Listing 5: Example output of SHORTESTPATH

Intermediate Programming String-Interpretation and Graph-Algorithms Exercise Sheet 4

Intermediate Programming String-Interpretation and Graph-Algorithms Exercise Sheet 4 Institute of Scientific Computing Technische Universität Braunschweig Prof. Hermann G. Matthies, Ph. D. Dr. Elmar Zander Summer Term 2010 November 14, 2014 Intermediate Programming String-Interpretation

More information

Linked List Nodes (reminder)

Linked List Nodes (reminder) Outline linked lists reminders: nodes, implementation, invariants circular linked list doubly-linked lists iterators the Java foreach statement iterator implementation the ListIterator interface Linked

More information

About this exam review

About this exam review Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review

More information

Introduction to Programming Using Java (98-388)

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 information

Intermediate Programming Programming-Tools and Sorting-Algorithms Exercise Sheet Deadline on 13th of November 2009

Intermediate Programming Programming-Tools and Sorting-Algorithms Exercise Sheet Deadline on 13th of November 2009 Institute of Scientific Computing Technische Universität Braunschweig Prof. Hermann G. Matthies, Ph. D. Dominik Jürgens Winter Term 2009 August 11, 2009 Intermediate Programming Programming-Tools and Sorting-Algorithms

More information

Java Review: Objects

Java Review: Objects Outline Java review Abstract Data Types (ADTs) Interfaces Class Hierarchy, Abstract Classes, Inheritance Invariants Lists ArrayList LinkedList runtime analysis Iterators Java references 1 Exam Preparation

More information

An Activation Record for Simple Subprograms. Activation Record for a Language with Stack-Dynamic Local Variables

An Activation Record for Simple Subprograms. Activation Record for a Language with Stack-Dynamic Local Variables Activation Records The storage (for formals, local variables, function results etc.) needed for execution of a subprogram is organized as an activation record. An Activation Record for Simple Subprograms.

More information

Compiler Theory. (Semantic Analysis and Run-Time Environments)

Compiler Theory. (Semantic Analysis and Run-Time Environments) Compiler Theory (Semantic Analysis and Run-Time Environments) 005 Semantic Actions A compiler must do more than recognise whether a sentence belongs to the language of a grammar it must do something useful

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

Graphs. The ultimate data structure. graphs 1

Graphs. The ultimate data structure. graphs 1 Graphs The ultimate data structure graphs 1 Definition of graph Non-linear data structure consisting of nodes & links between them (like trees in this sense) Unlike trees, graph nodes may be completely

More information

DDS Dynamic Search Trees

DDS Dynamic Search Trees DDS Dynamic Search Trees 1 Data structures l A data structure models some abstract object. It implements a number of operations on this object, which usually can be classified into l creation and deletion

More information

Graphs. The ultimate data structure. graphs 1

Graphs. The ultimate data structure. graphs 1 Graphs The ultimate data structure graphs 1 Definition of graph Non-linear data structure consisting of nodes & links between them (like trees in this sense) Unlike trees, graph nodes may be completely

More information

UNIT-1. Chapter 1(Introduction and overview) 1. Asymptotic Notations 2. One Dimensional array 3. Multi Dimensional array 4. Pointer arrays.

UNIT-1. Chapter 1(Introduction and overview) 1. Asymptotic Notations 2. One Dimensional array 3. Multi Dimensional array 4. Pointer arrays. UNIT-1 Chapter 1(Introduction and overview) 1. Asymptotic Notations 2. One Dimensional array 3. Multi Dimensional array 4. Pointer arrays. Chapter 2 (Linked lists) 1. Definition 2. Single linked list 3.

More information

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

MULTIMEDIA 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 information

Title Description Participants Textbook

Title Description Participants Textbook Podcast Ch18d Title: Binary Search Tree Iterator Description: Additional operations first and last; the BST iterator Participants: Barry Kurtz (instructor); John Helfert and Tobie Williams (students) Textbook:

More information

CSE 12 Abstract Syntax Trees

CSE 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 information

Computer Science 62. Midterm Examination

Computer Science 62. Midterm Examination Computer Science 62 Bruce/Mawhorter Fall 16 Midterm Examination October 5, 2016 Question Points Score 1 15 2 10 3 10 4 8 5 9 TOTAL 52 Your name (Please print) 1. Suppose you are given a singly-linked list

More information

2IP15 Programming Methods

2IP15 Programming Methods Lecture 5: Iteration Abstraction 2IP15 Programming Methods From Small to Large Programs Tom Verhoeff Eindhoven University of Technology Department of Mathematics & Computer Science Software Engineering

More information

Object-oriented Compiler Construction

Object-oriented Compiler Construction 1 Object-oriented Compiler Construction Extended Abstract Axel-Tobias Schreiner, Bernd Kühl University of Osnabrück, Germany {axel,bekuehl}@uos.de, http://www.inf.uos.de/talks/hc2 A compiler takes a program

More information

Data Structures and Algorithms (DSA) Course 9 Lists / Graphs / Trees. Iulian Năstac

Data Structures and Algorithms (DSA) Course 9 Lists / Graphs / Trees. Iulian Năstac Data Structures and Algorithms (DSA) Course 9 Lists / Graphs / Trees Iulian Năstac Recapitulation It is considered the following type: typedef struct nod { ; struct nod *next; } NOD; 2 Circular

More information

DOWNLOAD PDF LINKED LIST PROGRAMS IN DATA STRUCTURE

DOWNLOAD PDF LINKED LIST PROGRAMS IN DATA STRUCTURE Chapter 1 : What is an application of linear linked list data structures? - Quora A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. The elements

More information

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 04 Programs with IO and Loop We will now discuss the module 2,

More information

1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers?

1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers? Review for Final (Chapter 6 13, 15) 6. Template functions & classes 1) What is the primary purpose of template functions? A. To allow a single function to be used with varying types of arguments B. To

More information

CMPS 240 Data Structures and Algorithms Test #2 Fall 2017 November 15

CMPS 240 Data Structures and Algorithms Test #2 Fall 2017 November 15 CMPS 240 Data Structures and Algorithms Test #2 Fall 2017 November 15 Name The test has six problems. You ll be graded on your best four answers. 1. Suppose that we wanted to modify the Java class NodeOutDeg1

More information

Arrays. Array Definition

Arrays. Array Definition Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Arrays Arrays 1 Array Definition An array

More information

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE TED (10)-3071 Reg. No.. (REVISION-2010) Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours (Maximum marks: 100)

More information

Dynamic Data Structures

Dynamic Data Structures Dynamic Data Structures We have seen that the STL containers vector, deque, list, set and map can grow and shrink dynamically. We now examine how some of these containers can be implemented in C++. To

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

CONTENTS. 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 information

Implementation. Learn how to implement the List interface Understand the efficiency trade-offs between the ArrayList and LinkedList implementations

Implementation. Learn how to implement the List interface Understand the efficiency trade-offs between the ArrayList and LinkedList implementations Readings List Implementations Chapter 20.2 Objectives Learn how to implement the List interface Understand the efficiency trade-offs between the ArrayList and LinkedList implementations Additional references:

More information

Pace University. Fundamental Concepts of CS121 1

Pace 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 information

Ashish Gupta, Data JUET, Guna

Ashish Gupta, Data JUET, Guna Categories of data structures Data structures are categories in two classes 1. Linear data structure: - organized into sequential fashion - elements are attached one after another - easy to implement because

More information

Summer Final Exam Review Session August 5, 2009

Summer 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 information

CS112 Lecture: Primitive Types, Operators, Strings

CS112 Lecture: Primitive Types, Operators, Strings CS112 Lecture: Primitive Types, Operators, Strings Last revised 1/24/06 Objectives: 1. To explain the fundamental distinction between primitive types and reference types, and to introduce the Java primitive

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Iterator 1 (part I) Marcel Turcotte School of Electrical Engineering and Computer Science Version of March 24, 2013 Abstract These lecture notes are meant to be looked

More information

Linear Structures. Linear Structure. Implementations. Array details. List details. Operations 2/10/2013

Linear Structures. Linear Structure. Implementations. Array details. List details. Operations 2/10/2013 Linear Structure Linear Structures Chapter 4 CPTR 318 Every non-empty linear structure has A unique element called first A unique element called last Every element except last has a unique successor Every

More information

Outline. iterator review iterator implementation the Java foreach statement testing

Outline. iterator review iterator implementation the Java foreach statement testing Outline iterator review iterator implementation the Java foreach statement testing review: Iterator methods a Java iterator only provides two or three operations: E next(), which returns the next element,

More information

Computer Science E-119 Fall Problem Set 4. Due prior to lecture on Wednesday, November 28

Computer Science E-119 Fall Problem Set 4. Due prior to lecture on Wednesday, November 28 Computer Science E-119 Fall 2012 Due prior to lecture on Wednesday, November 28 Getting Started To get the files that you will need for this problem set, log into nice.harvard.edu and enter the following

More information

WELCOME! (download slides and.py files and follow along!) LECTURE 1

WELCOME! (download slides and.py files and follow along!) LECTURE 1 WELCOME! (download slides and.py files and follow along!) 6.0001 LECTURE 1 6.0001 LECTURE 1 1 TODAY course info what is computation python basics mathematical operations python variables and types NOTE:

More information

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS Objective PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS Explain what is meant by compiler. Explain how the compiler works. Describe various analysis of the source program. Describe the

More information

Assignment 5. Introduction

Assignment 5. Introduction Assignment 5 Introduction The objectives of this assignment are to exercise a few advanced object oriented programming and basic data structures concepts. The first mini-goal is to understand that objects

More information

Stating the obvious, people and computers do not speak the same language.

Stating the obvious, people and computers do not speak the same language. 3.4 SYSTEM SOFTWARE 3.4.3 TRANSLATION SOFTWARE INTRODUCTION Stating the obvious, people and computers do not speak the same language. People have to write programs in order to instruct a computer what

More information

Converting Collections to Arrays. A Bad Approach to Array Conversion. A Better Approach to Array Conversion. public Object[] toarray();

Converting Collections to Arrays. A Bad Approach to Array Conversion. A Better Approach to Array Conversion. public Object[] toarray(); Converting Collections to Arrays Every Java collection can be converted to an array This is part of the basic Collection interface The most elementary form of this method produces an array of base-type

More information

Fun facts about recursion

Fun facts about recursion Outline examples of recursion principles of recursion review: recursive linked list methods binary search more examples of recursion problem solving using recursion 1 Fun facts about recursion every loop

More information

A New Communication Theory on Complex Information and a Groundbreaking New Declarative Method to Update Object Databases

A New Communication Theory on Complex Information and a Groundbreaking New Declarative Method to Update Object Databases A New Communication Theory on Complex Information and a Groundbreaking New Declarative Method to Update Object Databases Heikki Virkkunen, Email: hvirkkun@gmail.com, Date: 5 April 2016 This article as

More information

Trees, Part 1: Unbalanced Trees

Trees, Part 1: Unbalanced Trees Trees, Part 1: Unbalanced Trees The first part of this chapter takes a look at trees in general and unbalanced binary trees. The second part looks at various schemes to balance trees and/or make them more

More information

COP 3330 Final Exam Review

COP 3330 Final Exam Review COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time

More information

Table of Contents. Chapter 1: Introduction to Data Structures... 1

Table of Contents. Chapter 1: Introduction to Data Structures... 1 Table of Contents Chapter 1: Introduction to Data Structures... 1 1.1 Data Types in C++... 2 Integer Types... 2 Character Types... 3 Floating-point Types... 3 Variables Names... 4 1.2 Arrays... 4 Extraction

More information

CSCI-1200 Data Structures Spring 2018 Lecture 7 Order Notation & Basic Recursion

CSCI-1200 Data Structures Spring 2018 Lecture 7 Order Notation & Basic Recursion CSCI-1200 Data Structures Spring 2018 Lecture 7 Order Notation & Basic Recursion Review from Lectures 5 & 6 Arrays and pointers, Pointer arithmetic and dereferencing, Types of memory ( automatic, static,

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Iterator 1 (part I) Marcel Turcotte School of Electrical Engineering and Computer Science Version of March 26, 2013 Abstract These lecture notes are meant to be looked

More information

Project and Production Management Prof. Arun Kanda Department of Mechanical Engineering Indian Institute of Technology, Delhi

Project and Production Management Prof. Arun Kanda Department of Mechanical Engineering Indian Institute of Technology, Delhi Project and Production Management Prof. Arun Kanda Department of Mechanical Engineering Indian Institute of Technology, Delhi Lecture - 8 Consistency and Redundancy in Project networks In today s lecture

More information

This book is licensed under a Creative Commons Attribution 3.0 License

This book is licensed under a Creative Commons Attribution 3.0 License 6. Syntax Learning objectives: syntax and semantics syntax diagrams and EBNF describe context-free grammars terminal and nonterminal symbols productions definition of EBNF by itself parse tree grammars

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Iterator 1 (part I) Marcel Turcotte School of Electrical Engineering and Computer Science Version of March 26, 2013 Abstract These lecture notes are meant to be looked

More information

Lists. CITS2200 Data Structures and Algorithms. Topic 9

Lists. CITS2200 Data Structures and Algorithms. Topic 9 CITS2200 Data Structures and Algorithms Topic 9 Lists Why lists? List windows Specification Block representation Singly linked representation Performance comparisons Reading: Lambert and Osborne, Sections

More information

infix expressions (review)

infix expressions (review) Outline infix, prefix, and postfix expressions queues queue interface queue applications queue implementation: array queue queue implementation: linked queue application of queues and stacks: data structure

More information

CSE 373 Final Exam 3/14/06 Sample Solution

CSE 373 Final Exam 3/14/06 Sample Solution Question 1. (6 points) A priority queue is a data structure that supports storing a set of values, each of which has an associated key. Each key-value pair is an entry in the priority queue. The basic

More information

4 CoffeeStrainer Virtues and Limitations

4 CoffeeStrainer Virtues and Limitations In this chapter, we explain CoffeeStrainer s virtues and limitations and the design decisions that led to them. To illustrate the points we want to make, we contrast CoffeeStrainer with a hypothetical,

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss 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 information

OBJECT ORIENTED DATA STRUCTURE & ALGORITHMS

OBJECT ORIENTED DATA STRUCTURE & ALGORITHMS OBJECT ORIENTED DATA STRUCTURE & ALGORITHMS C++ PROGRAMMING LANGUAGE CONTENT C++ Language Contents: Introduction to C++ Language Difference and Similarities between C and C++ Role Of Compilers and Assemblers

More information

11/2/ Dynamic Data Structures & Generics. Objectives. Array-Based Data Structures: Outline. Harald Gall, Prof. Dr.

11/2/ Dynamic Data Structures & Generics. Objectives. Array-Based Data Structures: Outline. Harald Gall, Prof. Dr. 12. Dynamic Data Structures & Generics Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich http://seal.ifi.uzh.ch Objectives! Define and use an instance of ArrayList! Describe general idea

More information

ITI Introduction to Computing II

ITI Introduction to Computing II index.pdf March 17, 2013 1 ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Version of March 17, 2013 Definitions A List is a linear abstract

More information

Computer Science 62. Bruce/Mawhorter Fall 16. Midterm Examination. October 5, Question Points Score TOTAL 52 SOLUTIONS. Your name (Please print)

Computer Science 62. Bruce/Mawhorter Fall 16. Midterm Examination. October 5, Question Points Score TOTAL 52 SOLUTIONS. Your name (Please print) Computer Science 62 Bruce/Mawhorter Fall 16 Midterm Examination October 5, 2016 Question Points Score 1 15 2 10 3 10 4 8 5 9 TOTAL 52 SOLUTIONS Your name (Please print) 1. Suppose you are given a singly-linked

More information

+ Abstract Data Types

+ Abstract Data Types Linked Lists Abstract Data Types An Abstract Data Type (ADT) is: a set of values a set of operations Sounds familiar, right? I gave a similar definition for a data structure. Abstract Data Types Abstract

More information

CP2 Revision. theme: dynamic datatypes & data structures

CP2 Revision. theme: dynamic datatypes & data structures CP2 Revision theme: dynamic datatypes & data structures structs can hold any combination of datatypes handled as single entity struct { }; ;

More information

CHAPTER 7 OBJECTS AND CLASSES

CHAPTER 7 OBJECTS AND CLASSES CHAPTER 7 OBJECTS AND CLASSES OBJECTIVES After completing Objects and Classes, you will be able to: Explain the use of classes in Java for representing structured data. Distinguish between objects and

More information

EC8393FUNDAMENTALS OF DATA STRUCTURES IN C Unit 3

EC8393FUNDAMENTALS OF DATA STRUCTURES IN C Unit 3 UNIT 3 LINEAR DATA STRUCTURES 1. Define Data Structures Data Structures is defined as the way of organizing all data items that consider not only the elements stored but also stores the relationship between

More information

( ) n 3. n 2 ( ) D. Ο

( ) n 3. n 2 ( ) D. Ο CSE 0 Name Test Summer 0 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to multiply two n n matrices is: A. Θ( n) B. Θ( max( m,n, p) ) C.

More information

12 Abstract Data Types

12 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 information

ENEE 150: Intermediate Programming Concepts for Engineers Spring 2018 Handout #27. Midterm #2 Review

ENEE 150: Intermediate Programming Concepts for Engineers Spring 2018 Handout #27. Midterm #2 Review ENEE 150: Intermediate Programming Concepts for Engineers Spring 2018 Handout #27 Midterm #2 Review 1 Time and Location The midterm will be given in class during normal class hours, 11:00a.m.-12:15p.m.,

More information

Chapter 3. Describing Syntax and Semantics

Chapter 3. Describing Syntax and Semantics Chapter 3 Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings of Programs:

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #34. Function with pointer Argument

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #34. Function with pointer Argument Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #34 Function with pointer Argument (Refer Slide Time: 00:05) So, here is the stuff that we have seen about pointers.

More information

CS 230 Programming Languages

CS 230 Programming Languages CS 230 Programming Languages 09 / 16 / 2013 Instructor: Michael Eckmann Today s Topics Questions/comments? Continue Syntax & Semantics Mini-pascal Attribute Grammars More Perl A more complex grammar Let's

More information

The return Statement

The return Statement The return Statement The return statement is the end point of the method. A callee is a method invoked by a caller. The callee returns to the caller if the callee completes all the statements (w/o a return

More information

Computer Programming: C++

Computer Programming: C++ The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming: C++ Experiment #7 Arrays Part II Passing Array to a Function

More information

Principle of Complier Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore

Principle of Complier Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Principle of Complier Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Lecture - 20 Intermediate code generation Part-4 Run-time environments

More information

Graphs. The ultimate data structure. graphs 1

Graphs. The ultimate data structure. graphs 1 Graphs The ultimate data structure graphs 1 Definition of graph Non-linear data structure consisting of nodes & links between them (like trees in this sense) Unlike trees, graph nodes may be completely

More information

Overview of Data. 1. Array 2. Linked List 3. Stack 4. Queue

Overview of Data. 1. Array 2. Linked List 3. Stack 4. Queue Overview of Data A data structure is a particular way of organizing data in a computer so that it can be used effectively. The idea is to reduce the space and time complexities of different tasks. Below

More information

Linear Structures. Linear Structure. Implementations. Array details. List details. Operations 4/18/2013

Linear Structures. Linear Structure. Implementations. Array details. List details. Operations 4/18/2013 Linear Structure Linear Structures Chapter 4 CPTR 318 Every non-empty linear structure has A unique element called first A unique element called last Every element except last has a unique successor Every

More information

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 The data of the problem is of 2GB and the hard disk is of 1GB capacity, to solve this problem we should Use better data structures

More information

Chapter 3: CONTEXT-FREE GRAMMARS AND PARSING Part 1

Chapter 3: CONTEXT-FREE GRAMMARS AND PARSING Part 1 Chapter 3: CONTEXT-FREE GRAMMARS AND PARSING Part 1 1. Introduction Parsing is the task of Syntax Analysis Determining the syntax, or structure, of a program. The syntax is defined by the grammar rules

More information

CS2110 Assignment 2 Lists, Induction, Recursion and Parsing, Summer

CS2110 Assignment 2 Lists, Induction, Recursion and Parsing, Summer CS2110 Assignment 2 Lists, Induction, Recursion and Parsing, Summer 2008 Due Thursday July 3, 2008, 6:00PM 0 General Instructions 0.1 Purpose This assignment will help you solidify your knowledge of Java

More information

CSC 172 Data Structures and Algorithms. Lecture #9 Spring 2018

CSC 172 Data Structures and Algorithms. Lecture #9 Spring 2018 CSC 172 Data Structures and Algorithms Lecture #9 Spring 2018 SINGLY LINKED LIST 3.1.3 Linked lists We will consider these for Singly linked lists Doubly linked lists Basic Singly Linked List class Node

More information

ADTs, Arrays, Linked Lists

ADTs, Arrays, Linked Lists 1 ADTs, Arrays, Linked Lists Outline and Required Reading: ADTs ( 2.1) Using Arrays ( 3.1) Linked Lists ( 3.2, 3.3, 3.4) CSE 2011, Winter 2017 Instructor: N. Vlajic Data Type 2 A data type is a classification

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming 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 Object-Oriented

More information

Principles of Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore

Principles of Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore (Refer Slide Time: 00:20) Principles of Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Lecture - 4 Lexical Analysis-Part-3 Welcome

More information

Functional Programming Language Haskell

Functional Programming Language Haskell Functional Programming Language Haskell Mohammed Aslam CIS 24 Prof. Kopec Presentation: 03 Date: 05/05/2003 Haskell is a general purpose, purely functional programming language named after the logician

More information

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer)

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer) COSC 2007 Data Structures II Final Exam Thursday, April 13 th, 2006 This is a closed book and closed notes exam. There are total 3 parts. Please answer the questions in the provided space and use back

More information

Question Paper Code : 97044

Question Paper Code : 97044 Reg. No. : Question Paper Code : 97044 B.E./B.Tech. DEGREE EXAMINATION NOVEMBER/DECEMBER 2014 Third Semester Computer Science and Engineering CS 6301 PROGRAMMING AND DATA STRUCTURES-II (Regulation 2013)

More information

Elementary Data Structures: Part 1: Arrays, Lists. CSE 2320 Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington

Elementary Data Structures: Part 1: Arrays, Lists. CSE 2320 Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington Elementary Data Structures: Part 1: Arrays, Lists CSE 2320 Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1 Basic Types Types like integers, real numbers, characters.

More information

CSC Java Programming, Fall Java Data Types and Control Constructs

CSC Java Programming, Fall Java Data Types and Control Constructs CSC 243 - Java Programming, Fall 2016 Java Data Types and Control Constructs Java Types In general, a type is collection of possible values Main categories of Java types: Primitive/built-in Object/Reference

More information

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program

More information

Data Structures Question Bank Multiple Choice

Data Structures Question Bank Multiple Choice Section 1. Fundamentals: Complexity, Algorthm Analysis 1. An algorithm solves A single problem or function Multiple problems or functions Has a single programming language implementation 2. A solution

More information

Computer Science E-119 Fall Problem Set 3. Due before lecture on Wednesday, October 31

Computer Science E-119 Fall Problem Set 3. Due before lecture on Wednesday, October 31 Due before lecture on Wednesday, October 31 Getting Started To get the files that you will need for this problem set, log into nice.harvard.edu and enter the following command: gethw 3 This will create

More information

Assignment 4 Publication date: 27/12/2015 Submission date: 17/01/ :59 People in-charge: R. Mairon and Y. Twitto

Assignment 4 Publication date: 27/12/2015 Submission date: 17/01/ :59 People in-charge: R. Mairon and Y. Twitto Assignment 4 Publication date: 27/12/2015 Submission date: 17/01/2016 23:59 People in-charge: R. Mairon and Y. Twitto Introduction The objectives of this assignment are to exercise a few advanced object

More information

UNIVERSITY OF MALTA THE MATRICULATION CERTIFICATE EXAMINATION ADVANCED LEVEL. COMPUTING May 2011 MARKING SCHEME

UNIVERSITY OF MALTA THE MATRICULATION CERTIFICATE EXAMINATION ADVANCED LEVEL. COMPUTING May 2011 MARKING SCHEME UNIVERSITY OF MALTA THE MATRICULATION CERTIFICATE EXAMINATION ADVANCED LEVEL COMPUTING May 2011 MARKING SCHEME MATRICULATION AND SECONDARY EDUCATION CERTIFICATE EXAMINATIONS BOARD PAPER I 1. XW + XZ =

More information

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) Introduction This semester, through a project split into 3 phases, we are going

More information

Open XML Requirements Specifications, a Xylia based application

Open XML Requirements Specifications, a Xylia based application Open XML Requirements Specifications, a Xylia based application Naeim Semsarilar Dennis K. Peters Theodore S. Norvell Faculty of Engineering and Applied Science Memorial University of Newfoundland November

More information

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully

More information

Arrays. Chapter Arrays What is an Array?

Arrays. Chapter Arrays What is an Array? Chapter 8 Arrays 81 Arrays 811 What is an Array? To motivate why we might be interested in using arrays, let us implement an app that creates a collection of doubles We will keep track of the number of

More information

Lecture 10 Parsing 10.1

Lecture 10 Parsing 10.1 10.1 The next two lectures cover parsing. To parse a sentence in a formal language is to break it down into its syntactic components. Parsing is one of the most basic functions every compiler carries out,

More information