Announcements. Prelude (2) Prelude (1) Data Structures and Information Systems Part 1: Data Structures. Lecture 6: Lists.

Size: px
Start display at page:

Download "Announcements. Prelude (2) Prelude (1) Data Structures and Information Systems Part 1: Data Structures. Lecture 6: Lists."

Transcription

1 Announcements MODULE WEB-SITE: michele/teaching/comp102/comp102.html FIRST ASSIGNMENT DEADLINE: Wednesday, February 1st, 14.30, LAB 7 Boxes (late submissions to be left in the wooden box to my office door). SIGN the PLAGIARISM DECLARATION!! Data Structures and Information Systems Part 1: Data Structures Michele Zito Lecture 6: Lists. p.1/74. p.2/74 Prelude (1) Prelude (2) Before we start this part it is important to make few things clear: You will notice that the lecture material related to lists is quite extensive. Such material is meant to help you understand this rather difficult topic. What is the best approach to the study of lists? 1. Come to the lecture and, having your notes handy, highlight the slides that we will look at in the lecture. These are the core slides. You will NOT understand lists unless you go through these slides very carefully. 2. Some slides will be missed out. These additional slide contain either additional examples or algorithms that are very similar to the ones we will see in the lecture. This is particularly true for lists but it also applies to ALL forthcoming topics.. p.3/74 Before we start this part it is important to make few things clear: The understanding is that these additional slides can be studied without me going through them during a lecture. Remember that you are expected to put about 9-10 hours of your time per week on each of the modules you are attending. As to COMP102, excluding lectures and tutorials, you are expected to work about 5 more hours per week on this module. Of course if you experience any difficulty in understanding this additional material do not hesitate to contact me (or one of the tutors). (VERY IMPORTANT!!!) Assessed exercises and exam may contain questions related to ANY of the slides that are being made available.. p.4/74

2 Topics Lists: Motivations (1) Lists Motivation Arrays versus Lists Singly linked lists We have started to look at the ways in which can be organised in the computer memory. The simplest way in which can be organised is as a sequence of boxes arranged in contiguous memory locations. Structures of this kind are called array (the multidimensional case being essentially just a variation on the same theme). a T[] n class tag length 0 1 n 2 n 1 Fast access time and staticity are, in a sense, direct consequences of the way in which arrays are defined.. p.5/74. p.6/74 Lists: Motivation Suppose we really want to define a dynamic structure, how can we do that?? Lists: Motivation Suppose we really want to define a dynamic structure, how can we do that?? One option is, perhaps, to allocate new contiguous memory blocks as we need them. p.7/74. p.7/74

3 Lists: Motivation Lists: Motivation Suppose we really want to define a dynamic structure, how can we do that?? One option is, perhaps, to allocate new contiguous memory blocks as we need them... but then we need to keep track of where they are! Suppose we really want to define a dynamic structure, how can we do that?? One option is, perhaps, to allocate new contiguous memory blocks as we need them... but then we need to keep track of where they are! Maybe we can associate this information with the individual blocks!. p.7/74. p.7/74 Lists: Motivation More precise definition Suppose we really want to define a dynamic structure, how can we do that?? One option is, perhaps, to allocate new contiguous memory blocks as we need them... but then we need to keep track of where they are! Maybe we can associate this information with the individual blocks! Lists provide a simple and general way to solve this problem! A list is defined as a sequence of components (of the same type) with the following properties the length of the list equals the number of its components (a list of length zero if often called empty list). the components of the list are ordered so that it is defined the notion of first element, second element,...ith element of the list. Operations are defined to allow: Inserting an element at a specified position into a list Locating the position of a specified element Retrieving an element from a specified position in a list Deleting an element at a specified position in a list Printing all elements in a list. p.7/74. p.8/74

4 Arrays versus Lists Implementation The number of components of an array is fixed when the array is created In contrast, the number of elements in a list can be varied by adding or removing elements All components of an array can be accessed in constant time through their index, but the same needn t be true for the elements of a list. To keep the structure dynamical, a list is usually constructed by allocating space for the list components and then use a (language-dependent) mechanism for linking together different components. Since the list components are stored in completely unrelated parts of the computer memory, the list can be easily expanded (or contracted) by handling individual components and the way they are linked together. In the forthcoming slides we will make these concepts more precise.. p.9/74. p.10/74 Self-referential classes To join list elements together, each element must be an object of a self-referential class A self-referential class is one that contains a reference member that refers to an object of the same class class Node { protected Object ; / / Any type of here protected Node ; / / Another o b j e c t of the same typ / / Constructor and methods go here Here we have used the access level specifier protected, which allows the class itself, subclasses, and all classes in the same package to access the members.. p.11/74 Linking objects An object of a self-referential class can be seen as having two parts: the part, containing the used by an application, in our case stored in the field of a Node object the link part which is a reference to another object of the same class, in our case stored in the field of a Node object Later, we will see that we can have more than one link to other objects so that we can create more complex structures. p.12/74

5 (Singly) Linked lists The life of a (singly) linked list We can know bring all of this together! A (singly) linked list is a linear collection (sequence) of self-referential objects, called nodes, connected by references. A (singly) linked list has a (a reference to the first element) from which we can access the first element of the list. We indicate that there is no object with a reference to A (singly) linked list starts off empty (i.e. refers to ) Elements can be inserted at the front ( will then refer to new element) at the end (new element will then refer to ) at any place between elements (references must be adjusted so that the chain does not break) Elements can be deleted (adjusting references). p.13/74. p.14/74 Node implementation (1) Let us flesh out the implementation of the Node class by adding constructor, accessor, and mutator methods: class Node { p rotected Object ; / / Data stored i n node p rotected Node ; / / Link to node Our first constructor takes (a reference to) an arbitrary object and (a reference to) the item in the list and constructs a new Node object out of this information p u b l i c Node ( Object o, Node item ) { = o ; / / Set = item ; / / Set reference to item Node implementation (2) If we want to store elements of a primitive type in a Node we would have to make use of a wrapper class It might be more convenient to have additional constructors which do this job for us: p u b l i c Node ( i n t number, Node item ) { = new I n t e g e r ( number ) ; = item ; We could systematically add similar constructors for all other primitive types like char, float, etc.. p.15/74. p.16/74

6 Node implementation (3) Next, we add some accessors to the Node class We provide accessors for both attributes of an instance of the Node class: p u b l i c Object getdata ( ) { r e t u r n ( ) ; p u b l i c Node getnext ( ) { r e t u r n ( ) ; As we have provided a special constructor for nodes storing values of type int, we may also add a special accessor in case the attribute stores a value of type int: p u b l i c i n t g e tintdata ( ) { r e t u r n ( ( ( I n t e g e r ) ). i n t V a l u e ( ) ) ; Note all these methods are public Node implementation (4) Finally, we also add some mutators (i.e. methods that change the value of some attribute in the given class) to the Node class. Again, we provide mutators for both attributes of an instance of the Node class, as well as a special mutator in the case we want to an integer value in a node: p u b l i c void setdata ( Object o ) { = o ; p u b l i c void setnext ( Node item ) { = item ; p u b l i c void s e t I n t D a t a ( i n t number ) { = new I n t e g e r ( number ) ; / / End of Node class. p.17/74. p.18/74 Linked list implementation (1) Linked list implementation (2) Next we implement (singly) linked lists using the following LinkedList class By definition, a linked list has a (a reference to the first element) from which we can access the first element of the list p u b l i c class L i n k e d L i s t { p rotected Node ; / / Reference to f i r s t eleme / / Constructor creates an empty l i s t p u b l i c L i n k e d L i s t ( ) { = n u l l ; Note that we have made a design choice here by the way an empty list is constructed Again we can add additional constructors, for example, a constructor that initialises a new instance of LinkedList with an already existing instance of Node: p u b l i c L i n k e d L i s t ( Node o ) { = o ; It might also be useful to have a method that can remove all the elements from a list p u b l i c void c l e a r ( ) { = n u l l ;. p.19/74. p.20/74

7 Linked list implementation (3) Since the attribute is protected, a user of class LinkedList is not able to inspect the value of So, it makes sense to have an accessor for it p u b l i c Node gethead ( ) { r e t u r n ( ) ; An important operation is to check whether a list is empty We could do so using gethead and a comparison operation, but this operation is performed often enough to grant a special method Obviously, a list is empty if is equal to / / Test i f the l i s t i s empty p u b l i c boolean isempty ( ) { r e t u r n ( = = n u l l ) ; To do We still need to implement all operations we have defined on lists: Inserting an element at a specified position into a list Locating the position of a specified element Retrieving an element from a specified position in a list Deleting an element at a specified position in a list Printing all elements in a list. p.21/74. p.22/74 Inserting at the front of a linked list (1) Data Structures and Information Systems Part 1: Data Structures Michele Zito We want to insert an object o at the front of a linked list First, we deal with the case that the list is empty 1. Create a new node storing object o 2. Make the list refer to the new node Lecture 7: List operations. p.23/74. p.24/74

8 Inserting at the front of a linked list (1) We want to insert an object o at the front of a linked list First, we deal with the case that the list is empty 1. Create a new node storing object o 2. Make the list refer to the new node Inserting at the front of a linked list (1) We want to insert an object o at the front of a linked list First, we deal with the case that the list is empty 1. Create a new node storing object o 2. Make the list refer to the new node o o. p.24/74. p.24/74 Inserting at the front of a linked list (2) We want to insert an object o at the front of a linked list We now deal with the case that the list already contains at least one node 1. Create a new node storing object o 2. Make the link part of the new node refer to what the of the list is referring to 3. Make the list refer to the new node Inserting at the front of a linked list (2) We want to insert an object o at the front of a linked list We now deal with the case that the list already contains at least one node 1. Create a new node storing object o 2. Make the link part of the new node refer to what the of the list is referring to 3. Make the list refer to the new node o. p.25/74. p.25/74

9 Inserting at the front of a linked list (2) We want to insert an object o at the front of a linked list We now deal with the case that the list already contains at least one node 1. Create a new node storing object o 2. Make the link part of the new node refer to what the of the list is referring to 3. Make the list refer to the new node Inserting at the front of a linked list (2) We want to insert an object o at the front of a linked list We now deal with the case that the list already contains at least one node 1. Create a new node storing object o 2. Make the link part of the new node refer to what the of the list is referring to 3. Make the list refer to the new node o o. p.25/74. p.25/74 Inserting at the front of a linked list (3) The algorithm for inserting an object at the front of a non-empty list also works for an empty list Also, we can merge the first two steps of the algorithm into one Then the following method implements our algorithm: / / I n s e r t an o b j e c t at the f r o n t of a l i n k e d l i s t p u b l i c void a d d F i r s t ( Object o ) { = new Node ( o, ) ; The expression new ListItem(o, ) creates a new node and makes sure that its link part refers to what the of the list is referring to Then, we make the of the list refer to the new node by an assignment Deleting at the front of a linked list (1) We want to delete the first node at the front of a linked list 1. Check whether the linked list is empty; if so, we cannot proceed further and have to give notification that the 2. Since we can now assume that the linked list is non-empty, there is a first element in the linked list; Make the of the list refer to what the link part of this element is referring to. p.26/74. p.27/74

10 Deleting at the front of a linked list (1) Deleting at the front of a linked list (1) We want to delete the first node at the front of a linked list 1. Check whether the linked list is empty; if so, we cannot proceed further and have to give notification that the 2. Since we can now assume that the linked list is non-empty, there is a first element in the linked list; Make the of the list refer to what the link part of this element is referring to We want to delete the first node at the front of a linked list 1. Check whether the linked list is empty; if so, we cannot proceed further and have to give notification that the 2. Since we can now assume that the linked list is non-empty, there is a first element in the linked list; Make the of the list refer to what the link part of this element is referring to. p.27/74. p.27/74 Deleting at the front of a linked list (2) Traversing a linked list (1) The algorithm for deleting the first node at the front of a linked list also works in the case that the list contains exactly one node Since this operation can fail, we should throw an exception if that happens; instead we give our method a boolean return value, and return false if it fails Then the following method implements our algorithm: So far, all our operations were taking place at the front of a linked list For all other operations we need to be able to traverse a linked list To locate a specified element (retrieval or deletion) To insert an element at a specific position To print out all the elements p u b l i c boolean removefirst ( ) { i f ( isempty ( ) ) / / Empty l i s t nothing to delete r e t u r n f a l s e ; =. getnext ( ) ; r e t u r n t r u e ;. p.28/74. p.29/74

11 Traversing a linked list (2) As we have no method so far to find out the number of nodes in a linked list, we cannot use a for-loop Also, we do not have a method that, given a number i can give us the ith node of a linked list To traverse a linked list we start from the of the linked list and move on to the item along until is encountered (the end of the list) using a temporary reference Traversing a linked list (2) As we have no method so far to find out the number of nodes in a linked list, we cannot use a for-loop Also, we do not have a method that, given a number i can give us the ith node of a linked list To traverse a linked list we start from the of the linked list and move on to the item along until is encountered (the end of the list) using a temporary reference temp. p.30/74. p.30/74 Traversing a linked list (2) As we have no method so far to find out the number of nodes in a linked list, we cannot use a for-loop Also, we do not have a method that, given a number i can give us the ith node of a linked list To traverse a linked list we start from the of the linked list and move on to the item along until is encountered (the end of the list) using a temporary reference temp Traversing a linked list (2) As we have no method so far to find out the number of nodes in a linked list, we cannot use a for-loop Also, we do not have a method that, given a number i can give us the ith node of a linked list To traverse a linked list we start from the of the linked list and move on to the item along until is encountered (the end of the list) using a temporary reference temp. p.30/74. p.30/74

12 Traversing a linked list (2) As we have no method so far to find out the number of nodes in a linked list, we cannot use a for-loop Also, we do not have a method that, given a number i can give us the ith node of a linked list To traverse a linked list we start from the of the linked list and move on to the item along until is encountered (the end of the list) using a temporary reference temp String representation of a linked list The application of this algorithm for traversing a linked list will be to construct a string representation of a linked list p u b l i c S t r i n g t o S t r i n g ( ) { / / Declare temporary node and i n i t i a l i s e i t with Node temp = ; / / Declare s t r i n g v a r i a b l e stringrep and / / i n i t i a l i s e i t to the empty s t r i n g S t r i n g stringrep = new S t r i n g ( ) ; while ( temp! = n u l l ) { stringrep + = " " + temp. getdata ( ) ; temp = temp. getnext ( ) ; r e t u r n ( stringrep ) ;. p.30/74. p.31/74 Inserting at the end of a linked list (1) We want to insert an object o at the end of a linked list 1. Create a new node storing object o 2. We use a temporary reference to traverse the linked list until we reach the last node (Keep in mind that the of the linked list might already be the last node ) 3. Make the link part of this current last node refer to the new node Inserting at the end of a linked list (1) We want to insert an object o at the end of a linked list 1. Create a new node storing object o 2. We use a temporary reference to traverse the linked list until we reach the last node (Keep in mind that the of the linked list might already be the last node ) 3. Make the link part of this current last node refer to the new node. p.32/74. p.32/74

13 Inserting at the end of a linked list (1) We want to insert an object o at the end of a linked list 1. Create a new node storing object o 2. We use a temporary reference to traverse the linked list until we reach the last node (Keep in mind that the of the linked list might already be the last node ) 3. Make the link part of this current last node refer to the new node temp Inserting at the end of a linked list (1) We want to insert an object o at the end of a linked list 1. Create a new node storing object o 2. We use a temporary reference to traverse the linked list until we reach the last node (Keep in mind that the of the linked list might already be the last node ) 3. Make the link part of this current last node refer to the new node temp. p.32/74. p.32/74 Inserting at the end of a linked list (1) We want to insert an object o at the end of a linked list 1. Create a new node storing object o 2. We use a temporary reference to traverse the linked list until we reach the last node (Keep in mind that the of the linked list might already be the last node ) 3. Make the link part of this current last node refer to the new node temp Inserting at the end of a linked list (1) We want to insert an object o at the end of a linked list 1. Create a new node storing object o 2. We use a temporary reference to traverse the linked list until we reach the last node (Keep in mind that the of the linked list might already be the last node ) 3. Make the link part of this current last node refer to the new node temp. p.32/74. p.32/74

14 Inserting at the end of a linked list (2) The following method addlast implements the algorithm for inserting an object at the end of a linked list Note how it takes care of the special case that is already referring to p u b l i c void addlast ( Object o ) { Node temp = ; Node newnode = new Node ( o, n u l l ) ; i f ( = = n u l l ) = newnode ; else { while ( temp. getnext ( )! = n u l l ) temp = temp. getnext ( ) ; temp. setnext ( newnode ) ;. p.33/74 Inserting in a linked list (3) Since the argument of both addfirst and addlast are of type Object, to insert elements of a primitive type in a linked list we would have to make use of a wrapper class We can again provide special insertion methods for each primitive type, e.g. p u b l i c void a d d F i r s t ( i n t ) { = new Node (new I n t e g e r ( ), ) ; p u b l i c void addlast ( i n t ) { t h i s. addlast (new I n t e g e r ( ) ) ;. p.34/74 Deleting at the end of a linked list (1) We want to delete the last node in a linked list 1. Check whether the linked list is empty; if so, we cannot proceed further and have to give notification that the 2. Traverse the linked list until you reach the last but one node of the list; Make the link part of this node refer to Deleting at the end of a linked list (1) We want to delete the last node in a linked list 1. Check whether the linked list is empty; if so, we cannot proceed further and have to give notification that the 2. Traverse the linked list until you reach the last but one node of the list; Make the link part of this node refer to del temp. p.35/74. p.35/74

15 Deleting at the end of a linked list (1) We want to delete the last node in a linked list 1. Check whether the linked list is empty; if so, we cannot proceed further and have to give notification that the 2. Traverse the linked list until you reach the last but one node of the list; Make the link part of this node refer to del Deleting at the end of a linked list (1) We want to delete the last node in a linked list 1. Check whether the linked list is empty; if so, we cannot proceed further and have to give notification that the 2. Traverse the linked list until you reach the last but one node of the list; Make the link part of this node refer to del temp temp. p.35/74. p.35/74 Deleting at the end of a linked list (1) We want to delete the last node in a linked list 1. Check whether the linked list is empty; if so, we cannot proceed further and have to give notification that the 2. Traverse the linked list until you reach the last but one node of the list; Make the link part of this node refer to del temp Deleting at the end of a linked list (2) There are two special cases we have to deal with: 1. The linked list is empty: Then we could throw an exception; instead we return the boolean value false 2. The linked list contains exactly one node: Then we make the field of the linked list refer to (and return the boolean value true p u b l i c boolean removelast ( ) { i f ( isempty ( ) ) / / Empty l i s t r e t u r n f a l s e ; else { / / Non empty l i s t Node temp = ; Node del =. getnext ( ) ; i f ( del = = n u l l ) / / Single node l i s t = n u l l ; else {.... p.35/74. p.36/74

16 Deleting at the end of a linked list (3) The complete code of removelast is as follows: p u b l i c boolean removelast ( ) { i f ( isempty ( ) ) / / Empty l i s t r e t u r n f a l s e ; else { / / Non empty l i s t Node temp = ; Node del =. getnext ( ) ; i f ( del = = n u l l ) / / Single node l i s t = n u l l ; else { / / More than one node while ( del. getnext ( )! = n u l l ) { temp = del ; del = del. getnext ( ) ; temp. setnext ( n u l l ) ; ; r e t u r n t r u e ; / / Successful d e l e t i o n Deleting a given object (1) We can use a similar algorithms if we want to delete a node in a linked list storing a given object o 1. Check whether the linked list is empty; if so, we will not find o in our linked list and have to give notification that the operation has failed 2. Traverse the linked list until you reach the node N storing o, keeping track of the previous node using a temporary reference variable; Make the link part of the previous node refer to the node after N. p.37/74. p.38/74 Deleting a given object (2) Deleting a given object (2) Traverse the linked list until you reach the node N storing o, keeping track of the previous node using a temporary reference variable; Make the link part of the previous node refer to the node after N Traverse the linked list until you reach the node N storing o, keeping track of the previous node using a temporary reference variable; Make the link part of the previous node refer to the node after N del o node D prev o node D. p.39/74. p.39/74

17 Deleting a given object (2) Deleting a given object (2) Traverse the linked list until you reach the node N storing o, keeping track of the previous node using a temporary reference variable; Make the link part of the previous node refer to the node after N del Traverse the linked list until you reach the node N storing o, keeping track of the previous node using a temporary reference variable; Make the link part of the previous node refer to the node after N del prev o node D prev o node D. p.39/74. p.39/74 Deleting a given object (2) Deleting a given object (2) Traverse the linked list until you reach the node N storing o, keeping track of the previous node using a temporary reference variable; Make the link part of the previous node refer to the node after N del Traverse the linked list until you reach the node N storing o, keeping track of the previous node using a temporary reference variable; Make the link part of the previous node refer to the node after N del prev o node D prev o node D. p.39/74. p.39/74

18 Deleting a given object (3) Deleting a given object (4) There are two special cases we have to deal with: 1. The linked list is empty: Then we could throw an exception; instead we return the boolean value false 2. The node to delete is the first node of the list: Then we make the field of the linked list refer to second node of the linked list (which may be ) and return the boolean value true p u b l i c boolean remove ( Object o ) { i f ( isempty ( ) ) / / Empty l i s t r e t u r n f a l s e ; else { / / Non empty l i s t Node del = ; Node prev = n u l l ; while (! o. equals ( del. getdata ( ) ) ) { prev = del ; i f ( del. getnext ( ) = = n u l l ) r e t u r n f a l s e ; else del = del. getnext ( ) ; i f ( del = = ) =. getnext ( ) ; / / Delete f i r s t node else prev. setnext ( del. getnext ( ) ) ; r e t u r n t r u e ;. p.40/74. p.41/74 Locating a given object (1) We can easily convert our algorithm for deleting a given object into an algorithm which determines the position of a given object in a linked list We define that the first node in a linked list has position 0, to be more consistent with the notion of an index in an array If the given object is not stored in the linked list, then we return -1 as result Locating a given object (2) p u b l i c i n t p o s i t i o n O f ( Object o ) { i n t pos = 0 ; Node temp = ; while ( temp! = n u l l ) { i f ( o. equals ( temp. getdata ( ) ) ) r e t u r n pos ; temp = temp. getnext ( ) ; pos ++; r e t u r n 1; Note that remove and positionof are not very robust: We should check whether the argument given to these methods is Finally, here is a specialised version of positionof which locates an integer number: p u b l i c i n t p o s i t i o n O f ( i n t number ) { r e t u r n t h i s. p o s i t i o n O f ( new I n t e g e r ( number ) ) ;. p.42/74. p.43/74

19 Topics Data Structures and Information Systems Part 1: Data Structures Michele Zito Efficiency of Linked Lists Doubly linked lists Deleting at the end of a doubly linked list Lecture 8: Singly and doubly linked lists. p.44/74. p.45/74 Efficiency of (Singly) Linked Lists Space efficiency of (singly) linked lists We know that a well-chosen structure should try to minimise memory usage (avoid the allocation of unnecessary space) a well-chosen structure will include operations that are efficient in terms of speed of execution (based on some well-chosen algorithm) Question: How well does a (Singly) Linked List fare on these criteria, compared to an Array structure storing the same? A linked list stores in nodes where each node has a field storing the a item and a field storing a reference to the node Our operations for inserting and deleting make sure that the number of nodes exactly matches the number of items to be stored So, we never have more nodes than items, but we waste space on the reference stored in each node In comparison, using Arrays, we would simply store the items consecutively starting from position zero. No space is wasted on additional references, but we may have many empty components (at the end) which waste space. p.46/74. p.47/74

20 Time efficiency (1) Time efficiency (2) For our purposes the most important measure for the speed of execution is number of accesses while performing an operation In an Array inserting/deleting at the front requires moving all elements already in the array in the worst-case a number of accesses related to the length of the array. the longer the list the longer it will take to perform such operation! inserting/deleting at the end requires only the manipulation of the first free component in the array we always need just a constant number of accesses: time required does not depend on the length of the list. p.48/74 For our purposes the most important measure for the speed of execution is number of accesses while performing an operation In a (singly) linked list inserting/deleting at the front requires only accessing and accessing the current first node of the list constant number of accesses time required does not depend on the length of the list inserting/deleting at the end requires traversing the list nodes until we reach the last or last but one node in the worst-case a number of accesses related to the length of the array. the longer the list the longer it will take to perform such operation!. p.49/74 Improving our implementation Considerations (1) Question: How can we improve the performances of these structures? Inserting at the end of a linked list can be improved by adding a reference to the last node in a linked list. p.50/74. p.51/74

21 Considerations (1) Considerations (1) Inserting at the end of a linked list can be improved by adding a reference to the last node in a linked list node D o Inserting at the end of a linked list can be improved by adding a reference to the last node in a linked list node D o. p.51/74. p.51/74 Considerations (1) Inserting at the end of a linked list can be improved by adding a reference to the last node in a linked list node D o Considerations (2) However, for deleting at the end of a linked list this does not help, since to do that, we need to manipulate the last but one node of the list (not the last node). p.51/74. p.52/74

22 Doubly linked lists So, to deal with the problem of deleting at the end of a linked list more efficiently, we need to have list nodes that have two references, one to the node and one to the previous node This is advantageous for going forwards and backwards through the list Such a linked list is called a doubly linked list, in contrast to the singly linked list we already know. p.53/74 oubly linked lists: Node implementation ( / / Accessors p u b l i c Object getdata ( ) { r e t u r n ( ) ; p u b l i c i n t g e t I n t D a t a ( ) { r e t u r n ( ( ( I n t e g e r ) ). i n t V a l u e ( ) ) ; p u b l i c DLLNode getnext ( ) { r e t u r n ( ) ; p u b l i c DLLNode getprev ( ) { r e t u r n ( prev ) ; / / Mutators p u b l i c void setdata ( Object o ) { = o ; p u b l i c void s e t I n t D a t a ( i n t number ) { = new I n t e g e r ( number ) ; p u b l i c void setnext ( DLLNode item ) { = item ; p u b l i c void setprev ( DLLNode item ) { prev = item ; Doubly linked lists: Node implementation ( cl a ss DLLNode { protected Object ; / / Data stored i n node protected DLLNode prev ; / / Link to previous node protected DLLNode ; / / Link to node / / Constructors p u b l i c DLLNode ( Object o, DLLNode p, DLLNode n ) { = o ; / / Set prev = p ; / / Set reference t o previous node = n ; / / Set reference t o node p u b l i c DLLNode ( i n t number, DLLNode p, DLLNode n ) { = new I n t e g e r ( number ) ; prev = p ; = n ; / / Accessors and Mutators. p.54/74 Doubly linked lists: Implementation p u b l i c class DLL { protected DLLNode ; / / Reference to f i r s t element protected DLLNode t a i l ; / / Reference to l a s t element / / Constructor creates an empty DLL p u b l i c DLL ( ) { = n u l l ; t a i l = n u l l ; p u b l i c DLLNode gethead ( ) { r e t u r n ( ) ; p u b l i c DLLNode g e t T a i l ( ) { r e t u r n ( t a i l ) ; / / Delete a l l nodes i n a DLL p u b l i c void c l e a r ( ) { = n u l l ; t a i l = n u l l ; / / Check f o r empty DLL p u b l i c boolean isempty ( ) { r e t u r n ( = = n u l l ) ; / / Check f o r DLL with e x a c t l y one node p u b l i c boolean i s S i n g l e t o n ( ) { r e t u r n ( (! = n u l l ) & & ( = = t a i l ) ) ;. p.55/74 / / Other methods. p.56/74

23 Doubly linked lists: Deleting at the end (1) We want to delete the last node in a doubly linked list 1. Check whether the list is empty; if so, give notification that the 2. Check whether there is exactly one node in the list; if so, make both and refer to 3. Otherwise, make refer to the node.prev is referring to, then make. refer to Doubly linked lists: Deleting at the end (1) We want to delete the last node in a doubly linked list 1. Check whether the list is empty; if so, give notification that the 2. Check whether there is exactly one node in the list; if so, make both and refer to 3. Otherwise, make refer to the node.prev is referring to, then make. refer to. p.57/74. p.57/74 Doubly linked lists: Deleting at the end (1) We want to delete the last node in a doubly linked list 1. Check whether the list is empty; if so, give notification that the 2. Check whether there is exactly one node in the list; if so, make both and refer to 3. Otherwise, make refer to the node.prev is referring to, then make. refer to Doubly linked lists: Deleting at the end (1) We want to delete the last node in a doubly linked list 1. Check whether the list is empty; if so, give notification that the 2. Check whether there is exactly one node in the list; if so, make both and refer to 3. Otherwise, make refer to the node.prev is referring to, then make. refer to. p.57/74. p.57/74

24 Doubly linked lists: Deleting at the end (2) The code of removelast for a doubly linked list is as follows: p u b l i c boolean removelast ( ) { i f ( isempty ( ) ) / / Empty l i s t r e t u r n f a l s e ; else { i f ( i s S i n g l e t o n ( ) ) / / Singleton l i s t t h i s. c l e a r ( ) ; else { / / L i s t with at l e a s t two nodes t a i l = t a i l. prev ; t a i l. = n u l l ; r e t u r n t r u e ; Doubly linked lists: Inserting at the end (1 We want to insert an object o at the end of a doubly linked list 1. Create a new node N storing object o 2. Make of N refer to and prev of N refer to 3. If the list is currently empty, make and refer to N 4. Otherwise, make the field in the node is referring to, refer to N; then make refer to N. p.58/74. p.59/74 Doubly linked lists: Inserting at the end (1 We want to insert an object o at the end of a doubly linked list 1. Create a new node N storing object o 2. Make of N refer to and prev of N refer to 3. If the list is currently empty, make and refer to N 4. Otherwise, make the field in the node is referring to, refer to N; then make refer to N node N o Doubly linked lists: Inserting at the end (1 We want to insert an object o at the end of a doubly linked list 1. Create a new node N storing object o 2. Make of N refer to and prev of N refer to 3. If the list is currently empty, make and refer to N 4. Otherwise, make the field in the node is referring to, refer to N; then make refer to N node N o. p.59/74. p.59/74

25 Doubly linked lists: Inserting at the end (1 We want to insert an object o at the end of a doubly linked list 1. Create a new node N storing object o 2. Make of N refer to and prev of N refer to 3. If the list is currently empty, make and refer to N 4. Otherwise, make the field in the node is referring to, refer to N; then make refer to N node N o Doubly linked lists: Inserting at the end (1 We want to insert an object o at the end of a doubly linked list 1. Create a new node N storing object o 2. Make of N refer to and prev of N refer to 3. If the list is currently empty, make and refer to N 4. Otherwise, make the field in the node is referring to, refer to N; then make refer to N node N o. p.59/74. p.59/74 Doubly linked lists: Inserting at the end (2 The code of addlast for a doubly linked list is as follows: p u b l i c void addlast ( Object o ) { DLLNode newnode = new DLLNode ( o, n u l l, n u l l ) ; newnode. setprev ( t a i l ) ; i f ( isempty ( ) ) = newnode ; else t a i l. setnext ( newnode ) ; t a i l = newnode ; Doubly linked lists: Deleting at the front (1 We want to delete the first node in a doubly linked list 1. Check whether the list is empty; if so, give notification that the 2. Check whether there is exactly one node in the list; if so, make both and refer to 3. Otherwise, make refer to the node. is referring to; then make prev in the node is now referring to, refer to. p.60/74. p.61/74

26 Doubly linked lists: Deleting at the front (1 We want to delete the first node in a doubly linked list 1. Check whether the list is empty; if so, give notification that the 2. Check whether there is exactly one node in the list; if so, make both and refer to 3. Otherwise, make refer to the node. is referring to; then make prev in the node is now referring to, refer to Doubly linked lists: Deleting at the front (1 We want to delete the first node in a doubly linked list 1. Check whether the list is empty; if so, give notification that the 2. Check whether there is exactly one node in the list; if so, make both and refer to 3. Otherwise, make refer to the node. is referring to; then make prev in the node is now referring to, refer to. p.61/74. p.61/74 Doubly linked lists: Deleting at the front (1 We want to delete the first node in a doubly linked list 1. Check whether the list is empty; if so, give notification that the 2. Check whether there is exactly one node in the list; if so, make both and refer to 3. Otherwise, make refer to the node. is referring to; then make prev in the node is now referring to, refer to Doubly linked lists: Deleting at the front (2 The code of removefirst for a doubly linked list is as follows: p u b l i c boolean removefirst ( ) { i f ( isempty ( ) ) / / Empty l i s t r e t u r n f a l s e ; else { i f ( i s S i n g l e t o n ( ) ) / / Singleton l i s t t h i s. c l e a r ( ) ; else { / / L i s t with at l e a s t two nodes =. ;. prev = n u l l ; r e t u r n t r u e ; Note that this code can be obtained from removelast by replacing all occurrences of by and vice versa, replacing all occurrences of by prev and vice versa. p.61/74. p.62/74

27 Doubly linked lists: Inserting at the front (1 We want to insert an object o at the front of a doubly linked list 1. Create a new node N storing object o 2. Make prev of N refer to and of N refer to 3. If the list is currently empty, make and refer to N 4. Otherwise, make prev in the node is referring to refer to N; then make refer to N Doubly linked lists: Inserting at the front (1 We want to insert an object o at the front of a doubly linked list 1. Create a new node N storing object o 2. Make prev of N refer to and of N refer to 3. If the list is currently empty, make and refer to N 4. Otherwise, make prev in the node is referring to refer to N; then make refer to N node N o. p.63/74. p.63/74 Doubly linked lists: Inserting at the front (1 We want to insert an object o at the front of a doubly linked list 1. Create a new node N storing object o 2. Make prev of N refer to and of N refer to 3. If the list is currently empty, make and refer to N 4. Otherwise, make prev in the node is referring to refer to N; then make refer to N node N o Doubly linked lists: Inserting at the front (1 We want to insert an object o at the front of a doubly linked list 1. Create a new node N storing object o 2. Make prev of N refer to and of N refer to 3. If the list is currently empty, make and refer to N 4. Otherwise, make prev in the node is referring to refer to N; then make refer to N node N o. p.63/74. p.63/74

28 Doubly linked lists: Inserting at the front (1 We want to insert an object o at the front of a doubly linked list 1. Create a new node N storing object o 2. Make prev of N refer to and of N refer to 3. If the list is currently empty, make and refer to N 4. Otherwise, make prev in the node is referring to refer to N; then make refer to N node N o Doubly linked lists: Inserting at the front (2 We know that the code for addfirst can be obtained from addlast by replacing all occurrences of by and vice versa, replacing all occurrences of by prev and vice versa Then the code of addfirst for a doubly linked list is as follows: p u b l i c void a d d F i r s t ( Object o ) { DLLNode newnode = new DLLNode ( o, n u l l, n u l l ) ; newnode. setnext ( ) ; i f ( isempty ( ) ) t a i l = newnode ; else. setprev ( newnode ) ; = newnode ;. p.63/74. p.64/74 Doubly linked lists: Traversing in reverse A useful side-effect of having references to previous nodes is that we can easily traverse a list starting from its end going to its front Here is a method that constructs a string representation of a doubly linked list enumerating nodes in reverse order: p u b l i c S t r i n g r e v e r s e S t r i n g ( ) { / / Declare temporary node and i n i t i a l i s e i t with t a i l DLLNode temp = t a i l ; / / Declare s t r i n g v a r i a b l e stringrep and / / i n i t i a l i s e i t to the empty s t r i n g S t r i n g stringrep = new S t r i n g ( ) ; while ( temp! = n u l l ) { stringrep + = " " + temp. getdata ( ) ; temp = temp. getprev ( ) ; r e t u r n ( stringrep ) ; Space efficiency A doubly linked list stores in nodes where each node has a field storing the a item and two fields prev and storing a reference to the previous and node, respectively Our operations for inserting and deleting make sure that in our doubly linked list the number of nodes exactly matches the number of items to be stored So, we never have more nodes than items, but we waste space on the prev reference and reference stored in each node. p.65/74. p.66/74

29 In a doubly linked list: Time efficiency inserting/deleting at the front requires only accessing, possibly, and accessing the first (two) nodes of the list constant number of accesses time required does not depend on the length of the list inserting/deleting at the end requires only accessing, possibly, and accessing the last (two) nodes of the list constant number of accesses time required does not depend on the length of the list printing a doubly linked list requires traversing the doubly linked list accessing all list nodes all elements need to be accessed! (cannot be improved, inherent property of this operation) Doubly linked lists and Java Java contains a class java.util.linkedlist that is an implementation of a (circular) doubly linked list structure This class provides methods like LinkedList() Constructs an empty list void addfirst(object o) Inserts the given element at the beginning of this list void addlast(object o) Appends the given element to the end of this list Object getfirst() Returns the first element in this list Object getlast() Returns the last element in this list and many more. p.67/74. p.68/74 Example: Train departure information We want to develop an alternative implementation of our information system for train departure information at Liverpool Lime Street Station The information is given in form of a table Time Destination Track 9:10 Manchester 6 9:15 Leeds 10 9:20 Nottingham 7 The only kind of query we deal with is When and where does the train to X leave? The implementation should use the doubly linked list structure. p.69/74 Train departure information: The code (1 First, we define a class TDInfo whose instances store the departure information for a single train (that is, one row of our table) We include a constructor for objects of this class plus accessors for the fields, but no mutators p u b l i c class TDInfo { protected S t r i n g time ; protected S t r i n g c i t y ; protected i n t t r a c k ; p u b l i c TDInfo ( S t r i n g Ttime, S t r i n g T c i t y, i n t Ttrack ) { time = Ttime ; c i t y = T c i t y ; t r a c k = Ttrack ; p u b l i c S t r i n g gettime ( ) { r e t u r n ( time ) ; p u b l i c S t r i n g g e t C i t y ( ) { r e t u r n ( c i t y ) ; p u b l i c i n t gettrack ( ) { r e t u r n ( t r a c k ) ;. p.70/74

30 Train departure information: The code (2 Train departure information: The code (3 Next we define a class TDIDLL containing all the information in our table Since we only deal with one timetable, we don t need any instances of this class, but use a class variable tdi to store the information We use a static init block to create the TDInfo objects for each train and add them to tdi using the addlast method import java. i o. ; cl a ss TDIDLL { s t a t i c f i n a l DLL t d i = new DLL ( ) ; s t a t i c { t d i. addlast ( new TDInfo ( " 9 : 1 0 ", " Manchester ", 6 ) ) ; t d i. addlast ( new TDInfo ( " 9 : 1 5 ", " Leeds ", 1 0 ) ) ; t d i. addlast ( new TDInfo ( " 9 : 2 0 ", " Nottingham ", 7 ) ) ;. p.71/74 Next we add the searchdest method to TDIDLL As a result this method returns an array with two string components p u b l i c s t a t i c S t r i n g [ ] searchdest ( S t r i n g dest ) { S t r i n g [ ] r e s u l t = n u l l ; DLLNode temp = t d i. gethead ( ) ; while ( temp! = n u l l ) { i f ( ( ( TDInfo ) temp. getdata ( ) ). g e t C i t y ( ). equals ( dest ) ) { r e s u l t = new S t r i n g [ 2 ] ; r e s u l t [ 0 ] = ( ( TDInfo ) temp. getdata ( ) ). gettime ( ) ; r e s u l t [ 1 ] = S t r i n g. valueof ( ( ( TDInfo ) temp. getdata ( ) ). gettrack ( ) ) ; r e t u r n r e s u l t ; else temp = temp. getnext ( ) ; r e t u r n r e s u l t ;. p.72/74 Train departure information: The code (4 Finally, here is our main program that asks the user where he wants to go, uses searchdest to find the required information, and prints it out Note that searchdest is a static class method, so it is not applied to an instance but to TDIDLL (or nothing) instead p u b l i c s t a t i c void main ( S t r i n g args [ ] ) throws IOException { InputStreamReader i n p u t = new InputStreamReader ( System. i n ) ; BufferedReader keyboardinput = new BufferedReader ( i n p u t ) ; System. out. p r i n t l n ( " Where do you want to go? " ) ; S t r i n g [ ] i n f o = TDIDLL. searchdest ( keyboardinput. readline ( ) ) ; i f ( i n f o = = n u l l ) System. out. p r i n t l n ( " Sorry, no t r a i n to t h i s d e s t i n a t i o n " ) ; else System. out. p r i n t l n ( i n f o [ 0 ] + " departing at t r a c k " + i n f o [ 1 ] ) ; Train departure information: Script Here are two runs of the program: Information successfully retrieved Where do you want to go? Leeds 9:15 departing at track 10 No information found Where do you want to go? York Sorry, no train to this destination. p.73/74. p.74/74

Topics. Java arrays. Definition. Data Structures and Information Systems Part 1: Data Structures. Lecture 3: Arrays (1)

Topics. 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 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

COMP 250. Lecture 6. doubly linked lists. Sept. 20/21, 2017

COMP 250. Lecture 6. doubly linked lists. Sept. 20/21, 2017 COMP 250 Lecture 6 doubly linked lists Sept. 20/21, 2017 1 Singly linked list head tail 2 Doubly linked list next prev element Each node has a reference to the next node and to the previous node. head

More information

Assignment 1. Check your mailbox on Thursday! Grade and feedback published by tomorrow.

Assignment 1. Check your mailbox on Thursday! Grade and feedback published by tomorrow. Assignment 1 Check your mailbox on Thursday! Grade and feedback published by tomorrow. COMP250: Queues, deques, and doubly-linked lists Lecture 20 Jérôme Waldispühl School of Computer Science McGill University

More information

CS 151. Linked Lists, Recursively Implemented. Wednesday, October 3, 12

CS 151. Linked Lists, Recursively Implemented. Wednesday, October 3, 12 CS 151 Linked Lists, Recursively Implemented 1 2 Linked Lists, Revisited Recall that a linked list is a structure that represents a sequence of elements that are stored non-contiguously in memory. We can

More information

Abstract Data Types - Lists Arrays implementa4on Linked- lists implementa4on

Abstract Data Types - Lists Arrays implementa4on Linked- lists implementa4on Abstract Data Types - Lists Arrays implementa4on Linked- lists implementa4on Lecture 16 Jérôme Waldispühl School of Computer Science McGill University Slides by Mathieu BlancheIe Recap from last lecture

More information

CS350: Data Structures. Doubly Linked Lists

CS350: Data Structures. Doubly Linked Lists Doubly Linked Lists James Moscola Department of Physical Sciences York College of Pennsylvania James Moscola Doubly Linked Lists Adds an additional pointer to a the list nodes that points to the previous

More information

Data Structure: Lists and Iterators. Instructor: Prof. Young-guk Ha Dept. of Computer Science & Engineering

Data Structure: Lists and Iterators. Instructor: Prof. Young-guk Ha Dept. of Computer Science & Engineering Data Structure: Lists and Iterators 2017 Instructor: Prof. Young-guk Ha Dept. of Computer Science & Engineering Contents Data structures to be covered in this lecture Array lists (aka Vectors) Node lists

More information

Class 26: Linked Lists

Class 26: Linked Lists Introduction to Computation and Problem Solving Class 26: Linked Lists Prof. Steven R. Lerman and Dr. V. Judson Harward 2 The Java Collection Classes The java.util package contains implementations of many

More information

doubly linked lists Java LinkedList

doubly linked lists Java LinkedList COMP 250 Lecture 5 doubly linked lists Java LinkedList Sept. 16, 2016 1 Doubly linked lists next prev element Each node has a reference to the next node and to the previous node. head tail 2 class DNode

More information

CMSC 341 Lecture 7 Lists

CMSC 341 Lecture 7 Lists CMSC 341 Lecture 7 Lists Today s Topics Linked Lists vs Arrays Nodes Using Linked Lists Supporting Actors (member variables) Overview Creation Traversal Deletion UMBC CMSC 341 Lists 2 Linked Lists vs Arrays

More information

Lecture 12: Doubly Linked Lists

Lecture 12: Doubly Linked Lists Lecture 12: Doubly Linked Lists CS 62 Fall 2018 Alexandra Papoutsaki & William Devanny 1 Doubly Linked List A linked list consisting of a sequence of nodes, starting from a head pointer and ending to a

More information

Data Structures (CS301) LAB

Data Structures (CS301) LAB Data Structures (CS301) LAB Objectives The objectives of this LAB are, o Enabling students to implement Doubly Linked List practically using c++ and adding more functionality in it. Introduction to Singly

More information

Spring 2008 Data Structures (CS301) LAB

Spring 2008 Data Structures (CS301) LAB Spring 2008 Data Structures (CS301) LAB Objectives The objectives of this LAB are, o Enabling students to implement Singly Linked List practically using c++ and adding more functionality in it. o Enabling

More information

COMP 250 Winter generic types, doubly linked lists Jan. 28, 2016

COMP 250 Winter generic types, doubly linked lists Jan. 28, 2016 COMP 250 Winter 2016 5 generic types, doubly linked lists Jan. 28, 2016 Java generics In our discussion of linked lists, we concentrated on how to add or remove a node from the front or back of a list.

More information

Insertion Sort: an algorithm for sorting an array

Insertion Sort: an algorithm for sorting an array Insertion Sort: an algorithm for sorting an array Let s use arrays to solve a problem that comes up often in programming, namely sorting. Suppose we have an array of objects that is in no particular order

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 07: Linked Lists MOUNA KACEM mouna@cs.wisc.edu Spring 2019 Linked Lists 2 Introduction Linked List Abstract Data Type SinglyLinkedList ArrayList Keep in Mind Introduction:

More information

Abstract Data Types - Lists Arrays implementation Linked-lists implementation

Abstract Data Types - Lists Arrays implementation Linked-lists implementation Abstract Data Types - Lists Arrays implementation Linked-lists implementation Lecture 17 Jérôme Waldispühl School of Computer Science McGill University From slides by Mathieu Blanchette Abstract data types

More information

Tutorial 2: Linked Lists

Tutorial 2: Linked Lists Tutorial 2: Linked Lists ? 2 Agenda Introduction of Linked List Arrays Vs Linked Lists Types of Linked Lists Singly Linked List Doubly Linked List Circular Linked List Operations Insertion Deletion 3 Data

More information

The Java Collections Framework. Chapters 7.5

The Java Collections Framework. Chapters 7.5 The Java s Framework Chapters 7.5 Outline Introduction to the Java s Framework Iterators Interfaces, Classes and Classes of the Java s Framework Outline Introduction to the Java s Framework Iterators Interfaces,

More information

Introduction to Programming in C Department of Computer Science and Engineering

Introduction to Programming in C Department of Computer Science and Engineering Introduction to Programming in C Department of Computer Science and Engineering In this lecture, we will see slightly more advanced data type, then a singly link list. We will briefly go over one or two

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

Homework 2: Imperative Due: 5:00 PM, Feb 15, 2019

Homework 2: Imperative Due: 5:00 PM, Feb 15, 2019 CS18 Integrated Introduction to Computer Science Fisler Homework 2: Imperative Due: 5:00 PM, Feb 15, 2019 Contents 1 Overview of Generic/Parameterized Types 2 2 Double the Fun with Doubly-Linked Lists

More information

COMP 250. Lecture 8. stack. Sept. 25, 2017

COMP 250. Lecture 8. stack. Sept. 25, 2017 COMP 250 Lecture 8 stack Sept. 25, 2017 1 get(i) set(i,e) add(i,e) remove(i) remove(e) clear() isempty() size() What is a List (abstract)? // Returns the i-th element (but doesn't remove it) // Replaces

More information

CSCI 136 Data Structures & Advanced Programming. Lecture 13 Fall 2018 Instructors: Bill 2

CSCI 136 Data Structures & Advanced Programming. Lecture 13 Fall 2018 Instructors: Bill 2 CSCI 136 Data Structures & Advanced Programming Lecture 13 Fall 2018 Instructors: Bill 2 Announcements Lab today! After mid-term we ll have some non-partner labs It s Lab5 not Lab 4 Mid-term exam is Wednesday,

More information

An Introduction to Data Structures

An Introduction to Data Structures An Introduction to Data Structures Advanced Programming ICOM 4015 Lecture 17 Reading: Java Concepts Chapter 20 Fall 2006 Adapded from Java Concepts Companion Slides 1 Chapter Goals To learn how to use

More information

Lecture 4. The Java Collections Framework

Lecture 4. The Java Collections Framework Lecture 4. The Java s Framework - 1 - Outline Introduction to the Java s Framework Iterators Interfaces, Classes and Classes of the Java s Framework - 2 - Learning Outcomes From this lecture you should

More information

Lecture 7: Implementing Lists, Version 2

Lecture 7: Implementing Lists, Version 2 CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 7: Implementing Lists, Version 2 Contents 1 The Impact of addfirst on Lists 1 2 Mutating List Contents 2 2.1 The Basic List Classes...................................

More information

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

CSC 172 Data Structures and Algorithms. Lecture #8 Spring 2018 CSC 172 Data Structures and Algorithms Lecture #8 Spring 2018 Project 1 due tonight Announcements Project 2 will be out soon Q & A Reminder: For sharing your concern anonymously, you can always go to:

More information

COMP 250 Midterm #2 March 11 th 2013

COMP 250 Midterm #2 March 11 th 2013 NAME: STUDENT ID: COMP 250 Midterm #2 March 11 th 2013 - This exam has 6 pages - This is an open book and open notes exam. No electronic equipment is allowed. 1) Questions with short answers (28 points;

More information

1.00 Introduction to Computers and Engineering Problem Solving. Final Examination - May 19, 2004

1.00 Introduction to Computers and Engineering Problem Solving. Final Examination - May 19, 2004 1.00 Introduction to Computers and Engineering Problem Solving Final Examination - May 19, 2004 Name: E-mail Address: TA: Section: You have 3 hours to complete this exam. For coding questions, you do not

More information

Insertions and removals follow the Fist-In First-Out rule: Insertions: at the rear of the queue Removals: at the front of the queue

Insertions and removals follow the Fist-In First-Out rule: Insertions: at the rear of the queue Removals: at the front of the queue Queues CSE 2011 Fall 2009 9/28/2009 7:56 AM 1 Queues: FIFO Insertions and removals follow the Fist-In First-Out rule: Insertions: at the rear of the queue Removals: at the front of the queue Applications,

More information

CS 270 Algorithms. Oliver Kullmann. Binary search. Lists. Background: Pointers. Trees. Implementing rooted trees. Tutorial

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

CE204 Data Structures and Algorithms Part 2

CE204 Data Structures and Algorithms Part 2 CE204 Data Structures and Algorithms Part 2 14/01/2018 CE204 Part 2 1 Abstract Data Types 1 An abstract data type is a type that may be specified completely without the use of any programming language.

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

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

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #29 Arrays in C

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #29 Arrays in C Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #29 Arrays in C (Refer Slide Time: 00:08) This session will learn about arrays in C. Now, what is the word array

More information

Linked Lists. Chapter 4

Linked Lists. Chapter 4 Linked Lists Chapter 4 1 Linked List : Definition Linked List: A collection of data items of the same type that are stored in separate objects referred to as "nodes". Each node contains, in addition to

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

Computer Science 1 Ah

Computer Science 1 Ah UNIVERSITY OF EDINBURGH course CS0077 COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS Computer Science 1 Ah Resit Examination Specimen Solutions Date: Monday 1st September 2003 Time: 09:30 11:00

More information

Programming 2. Topic 8: Linked Lists, Basic Searching and Sorting

Programming 2. Topic 8: Linked Lists, Basic Searching and Sorting RMIT School of Computer Science and Information Technology Programming 2 Topic 8: Linked Lists, Basic Searching and Sorting Lecture Slides COPYRIGHT 2008 RMIT University. Original content by: Peter Tilmanis,

More information

Lists (Section 5) Lists, linked lists Implementation of lists in C Other list structures List implementation of stacks, queues, priority queues

Lists (Section 5) Lists, linked lists Implementation of lists in C Other list structures List implementation of stacks, queues, priority queues (Section 5) Lists, linked lists Implementation of lists in C Other list structures List implementation of stacks, queues, priority queues By: Pramod Parajuli, Department of Computer Science, St. Xavier

More information

9/26/2018 Data Structure & Algorithm. Assignment04: 3 parts Quiz: recursion, insertionsort, trees Basic concept: Linked-List Priority queues Heaps

9/26/2018 Data Structure & Algorithm. Assignment04: 3 parts Quiz: recursion, insertionsort, trees Basic concept: Linked-List Priority queues Heaps 9/26/2018 Data Structure & Algorithm Assignment04: 3 parts Quiz: recursion, insertionsort, trees Basic concept: Linked-List Priority queues Heaps 1 Quiz 10 points (as stated in the first class meeting)

More information

CS/CE 2336 Computer Science II

CS/CE 2336 Computer Science II CS/CE 2336 Computer Science II UT D Session 11 OO Data Structures Lists, Stacks, Queues Adapted from D. Liang s Introduction to Java Programming, 8 th Ed. 2 What is a Data Structure? A collection of data

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

Data Structures Lecture 5

Data Structures Lecture 5 Fall 2017 Fang Yu Software Security Lab. Dept. Management Information Systems, National Chengchi University Data Structures Lecture 5 Announcement Project Proposal due on Nov. 9 Remember to bring a hardcopy

More information

CS2 Practical 1 CS2A 22/09/2004

CS2 Practical 1 CS2A 22/09/2004 CS2 Practical 1 Basic Java Programming The purpose of this practical is to re-enforce your Java programming abilities. The practical is based on material covered in CS1. It consists of ten simple programming

More information

Notes on access restrictions

Notes on access restrictions Notes on access restrictions A source code file MyClass.java is a compilation unit and can contain at most one public class. Furthermore, if there is a public class in that file, it must be called MyClass.

More information

10/1/2018 Data Structure & Algorithm. Circularly Linked List Doubly Linked List Priority queues Heaps

10/1/2018 Data Structure & Algorithm. Circularly Linked List Doubly Linked List Priority queues Heaps 10/1/2018 Data Structure & Algorithm Circularly Linked List Doubly Linked List Priority queues Heaps 1 Linked list: Head and Tail NULL Element Next 1. Head 2. Tail 3. Size 2 Make SinglyLinkedList implements

More information

Java Collections. Readings and References. Collections Framework. Java 2 Collections. CSE 403, Spring 2004 Software Engineering

Java Collections. Readings and References. Collections Framework. Java 2 Collections. CSE 403, Spring 2004 Software Engineering Readings and References Java Collections "Collections", Java tutorial http://java.sun.com/docs/books/tutorial/collections/index.html CSE 403, Spring 2004 Software Engineering http://www.cs.washington.edu/education/courses/403/04sp/

More information

BBM 201 DATA STRUCTURES

BBM 201 DATA STRUCTURES BBM 201 DATA STRUCTURES Lecture 8: Dynamically Allocated Linked Lists 2017-2018 Fall int x; x = 8; int A[4]; An array is stored as one contiguous block of memory. How can we add a fifth element to the

More information

Linked lists. Insert Delete Lookup Doubly-linked lists. Lecture 6: Linked Lists

Linked lists. Insert Delete Lookup Doubly-linked lists. Lecture 6: Linked Lists Linked lists Insert Delete Lookup Doubly-linked lists Lecture 6: Linked Lists Object References When you declare a variable of a non-primitive type you are really declaring a reference to that object String

More information

csci 210: Data Structures Linked lists Summary Arrays vs. Lists Arrays vs. Linked Lists a[0] a[1] a[2]... null Today READING: Arrays

csci 210: Data Structures Linked lists Summary Arrays vs. Lists Arrays vs. Linked Lists a[0] a[1] a[2]... null Today READING: Arrays Summary Today linked lists csci 210: Data Structures Linked lists single-linked lists double-linked lists circular lists READING: LC chapter 4.1, 4.2, 4.3 Arrays vs. Linked Lists Arrays vs. Lists We!ve

More information

Data structure is an organization of information, usually in memory, for better algorithm efficiency.

Data structure is an organization of information, usually in memory, for better algorithm efficiency. Lecture 01 Introduction Wednesday, 29 July 2015 12:59 pm Data structure is an organization of information, usually in memory, for better algorithm efficiency. Abstract data types (ADTs) are a model for

More information

Data Structures. Lecture 04 Sohail Aslam AL 1

Data Structures. Lecture 04 Sohail Aslam AL 1 Data Structures Lecture 04 Sohail Aslam 1 C++ Code for Linked List // position current before the first // list element void start() { lastcurrentnode = headnode; currentnode = headnode; }; 2 C++ Code

More information

CS2 Practical 2 CS2Ah

CS2 Practical 2 CS2Ah CS2 Practical 2 Finite automata This practical is based on material in the language processing thread. The practical is made up of two parts. Part A consists of four paper and pencil exercises, designed

More information

CS 251 Intermediate Programming Methods and Classes

CS 251 Intermediate Programming Methods and Classes CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

CS 251 Intermediate Programming Methods and More

CS 251 Intermediate Programming Methods and More CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

Generics. IRS W-9 Form

Generics. IRS W-9 Form Generics IRS W-9 Form Generics Generic class and methods. BNF notation Syntax Non-parametrized class: < class declaration > ::= "class" < identifier > ["extends" < type >] ["implements" < type list >]

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

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 07: Linked Lists and Iterators MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Linked Lists 2 Introduction Linked List Abstract Data Type General Implementation of the ListADT

More information

APCS Semester #1 Final Exam Practice Problems

APCS Semester #1 Final Exam Practice Problems Name: Date: Per: AP Computer Science, Mr. Ferraro APCS Semester #1 Final Exam Practice Problems The problems here are to get you thinking about topics we ve visited thus far in preparation for the semester

More information

Computer Science 136. Midterm Examination

Computer Science 136. Midterm Examination Computer Science 136 Bruce - Spring 04 Midterm Examination March 10, 2004 Question Points Score 1 12 2 10 3 11 4 18 5 8 TOTAL 59 Your name (Please print) I have neither given nor received aid on this examination.

More information

Computer Science 210: Data Structures. Linked lists

Computer Science 210: Data Structures. Linked lists Computer Science 210: Data Structures Linked lists Arrays vs. Linked Lists Weʼve seen arrays: int[] a = new int[10]; a is a chunk of memory of size 10 x sizeof(int) a has a fixed size a[0] a[1] a[2]...

More information

DATA STRUCTURES AND ALGORITHMS

DATA STRUCTURES AND ALGORITHMS LECTURE 5 Babeş - Bolyai University Computer Science and Mathematics Faculty 2017-2018 In Lecture 4... Linked Lists Binary Heap Singly Linked List Insert at the beginning Insert after a node Today Linked

More information

Lists using LinkedList

Lists using LinkedList Lists using LinkedList 1 LinkedList Apart from arrays and array lists, Java provides another class for handling lists, namely LinkedList. An instance of LinkedList is called a linked list. The constructors

More information

Lists and Iterators. CSSE 221 Fundamentals of Software Development Honors Rose-Hulman Institute of Technology

Lists and Iterators. CSSE 221 Fundamentals of Software Development Honors Rose-Hulman Institute of Technology Lists and Iterators CSSE 221 Fundamentals of Software Development Honors Rose-Hulman Institute of Technology Announcements Should be making progress on VectorGraphics. Should have turned in CRC cards,

More information

Queues. CITS2200 Data Structures and Algorithms. Topic 5

Queues. CITS2200 Data Structures and Algorithms. Topic 5 CITS2200 Data Structures and Algorithms Topic 5 Queues Implementations of the Queue ADT Queue specification Queue interface Block (array) representations of queues Recursive (linked) representations of

More information

CS 307 Final Spring 2008

CS 307 Final Spring 2008 Points off 1 2 3 4 5 Total off Net Score CS 307 Final Spring 2008 Name UTEID login name Instructions: 1. Please turn off your cell phones. 2. There are 5 questions on this test. 3. You have 3 hours to

More information

Introduction to Data Structures and Algorithms

Introduction to Data Structures and Algorithms Introduction to Data Structures and Algorithms Data Structure is a way of collecting and organising data in such a way that we can perform operations on these data in an effective way. Data Structures

More information

CS1020 Data Structures and Algorithms I Lecture Note #10. List ADT & Linked Lists

CS1020 Data Structures and Algorithms I Lecture Note #10. List ADT & Linked Lists CS1020 Data Structures and Algorithms I Lecture Note #10 List ADT & Linked Lists Objectives 1 2 3 4 Able to define a List ADT Able to implement a List ADT with array Able to implement a List ADT with linked

More information

CS 1316 Exam 2 Summer 2009

CS 1316 Exam 2 Summer 2009 1 / 8 Your Name: I commit to uphold the ideals of honor and integrity by refusing to betray the trust bestowed upon me as a member of the Georgia Tech community. CS 1316 Exam 2 Summer 2009 Section/Problem

More information

Data Structures and Algorithms " Arrays and Linked Lists!

Data Structures and Algorithms  Arrays and Linked Lists! Data Structures and Algorithms " Arrays and Linked Lists! Outline" Arrays! Singly Linked Lists! Doubly Linked Lists! Phạm Bảo Sơn - DSA 2 Arrays" Most commonly used data structure.! Built-in in most programming

More information

Ticket Machine Project(s)

Ticket Machine Project(s) Ticket Machine Project(s) Understanding the basic contents of classes Produced by: Dr. Siobhán Drohan (based on Chapter 2, Objects First with Java - A Practical Introduction using BlueJ, David J. Barnes,

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

CH7. LIST AND ITERATOR ADTS

CH7. LIST AND ITERATOR ADTS CH7. LIST AND ITERATOR ADTS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN JAVA, GOODRICH, TAMASSIA AND GOLDWASSER (WILEY 2016) LIST ADT EXAMPLE A

More information

Linked List Practice Questions

Linked List Practice Questions Linked List Practice Questions 1. The following function reverse() is supposed to reverse a singly linked list. There is one line missing at the end of the function. /* head_ref is a double pointer which

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

Software Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore

Software Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore Software Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore Lecture 04 Software Test Automation: JUnit as an example

More information

Revising CS-M41. Oliver Kullmann Computer Science Department Swansea University. Linux Lab Swansea, December 13, 2011.

Revising CS-M41. Oliver Kullmann Computer Science Department Swansea University. Linux Lab Swansea, December 13, 2011. Computer Science Department Swansea University Linux Lab Swansea, December 13, 2011 How to use the revision lecture The purpose of this lecture (and the slides) is to emphasise the main topics of this

More information

Java Collections. Readings and References. Collections Framework. Java 2 Collections. References. CSE 403, Winter 2003 Software Engineering

Java Collections. Readings and References. Collections Framework. Java 2 Collections. References. CSE 403, Winter 2003 Software Engineering Readings and References Java Collections References» "Collections", Java tutorial» http://java.sun.com/docs/books/tutorial/collections/index.html CSE 403, Winter 2003 Software Engineering http://www.cs.washington.edu/education/courses/403/03wi/

More information

Software Testing Prof. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur. Lecture 13 Path Testing

Software Testing Prof. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur. Lecture 13 Path Testing Software Testing Prof. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 13 Path Testing Welcome to this session and we will discuss about path

More information

4.1 Ordered Lists Revisited

4.1 Ordered Lists Revisited Chapter 4 Linked-lists 4.1 Ordered Lists Revisited Let us revisit our ordered-list. Let us assume that we use it for storing roll numbers of students in a class in ascending order. We can make the assumption

More information

Topic 11 Linked Lists

Topic 11 Linked Lists Topic 11 "All the kids who did great in high school writing pong games in BASIC for their Apple II would get to college, take CompSci 101, a data structures course, and when they hit the pointers business

More information

Advanced Linked Lists. Doubly Linked Lists Circular Linked Lists Multi- Linked Lists

Advanced Linked Lists. Doubly Linked Lists Circular Linked Lists Multi- Linked Lists Advanced Linked Lists Doubly Linked Lists Circular Linked Lists Multi- Linked Lists Review The singly linked list: consists of nodes linked in a single direction. access and traversals begin with the first

More information

Recap. List Types. List Functionality. ListIterator. Adapter Design Pattern. Department of Computer Science 1

Recap. List Types. List Functionality. ListIterator. Adapter Design Pattern. Department of Computer Science 1 COMP209 Object Oriented Programming Container Classes 3 Mark Hall List Functionality Types List Iterator Adapter design pattern Adapting a LinkedList to a Stack/Queue Map Functionality Hashing Performance

More information

CH7. LIST AND ITERATOR ADTS

CH7. LIST AND ITERATOR ADTS CH7. LIST AND ITERATOR ADTS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN JAVA, GOODRICH, TAMASSIA AND GOLDWASSER (WILEY 2016) LISTS LIST ADT A List

More information

Introduction to Programming in C Department of Computer Science and Engineering

Introduction to Programming in C Department of Computer Science and Engineering Introduction to Programming in C Department of Computer Science and Engineering Once we know structures and pointers to structures, we can introduce some very important data structure called link list.

More information

Topic #9: Collections. Readings and References. Collections. Collection Interface. Java Collections CSE142 A-1

Topic #9: Collections. Readings and References. Collections. Collection Interface. Java Collections CSE142 A-1 Topic #9: Collections CSE 413, Autumn 2004 Programming Languages http://www.cs.washington.edu/education/courses/413/04au/ If S is a subtype of T, what is S permitted to do with the methods of T? Typing

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

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

Abstract Data Types. Data Str. Client Prog. Add. Rem. Find. Show. 01/30/03 Lecture 7 1

Abstract Data Types. Data Str. Client Prog. Add. Rem. Find. Show. 01/30/03 Lecture 7 1 Abstract Data Types Add Client Prog Rem Find Data Str. Show 01/30/03 Lecture 7 1 Linear Lists It is an ordered collection of elements. Lists have items, size or length. Elements may have an index. Main

More information

Introduction. Reference

Introduction. Reference Introduction Data Structures - Linked Lists 01 Dr TGI Fernando 1 2 Problems with arrays Unordered array - searching is slow, deletion is slow Ordered array - insertion is slow, deletion is slow Arrays

More information

Object-Oriented Design Lecture 11 CS 3500 Spring 2010 (Pucella) Tuesday, Feb 16, 2010

Object-Oriented Design Lecture 11 CS 3500 Spring 2010 (Pucella) Tuesday, Feb 16, 2010 Object-Oriented Design Lecture 11 CS 3500 Spring 2010 (Pucella) Tuesday, Feb 16, 2010 11 Polymorphism The functional iterator interface we have defined last lecture is nice, but it is not very general.

More information

COMP 103. Data Structures and Algorithms

COMP 103. Data Structures and Algorithms T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I V I C T O R I A UNIVERSITY OF WELLINGTON EXAMINATIONS 2004 END-YEAR COMP 103 Data Structures and Algorithms Time Allowed: 3 Hours Instructions:

More information

LINKED LISTS cs2420 Introduction to Algorithms and Data Structures Spring 2015

LINKED LISTS cs2420 Introduction to Algorithms and Data Structures Spring 2015 LINKED LISTS cs2420 Introduction to Algorithms and Data Structures Spring 2015 1 administrivia 2 -assignment 5 due tonight at midnight -assignment 6 is out -YOU WILL BE SWITCHING PARTNERS! 3 assignment

More information

Introduction to Computer Science II CS S-20 Linked Lists IV

Introduction to Computer Science II CS S-20 Linked Lists IV Introduction to Computer Science II CS112-2012S-20 Linked Lists IV David Galles Department of Computer Science University of San Francisco 20-0: Doubly Linked List Deleting from (and inserting into!) a

More information

CE204 Data Structures and Algorithms Part 1

CE204 Data Structures and Algorithms Part 1 CE204 Data Structures and Algorithms Part 1 11/01/2018 CE204 Part 1 1 Recommended Reading The most useful book for much of the material in this module is Data Structures and Algorithm Analysis in Java

More information

CS 211 Programming Practicum Spring 2018

CS 211 Programming Practicum Spring 2018 Due: Thursday, 4/5/18 at 11:59 pm Infix Expression Evaluator Programming Project 5 For this lab, write a C++ program that will evaluate an infix expression. The algorithm REQUIRED for this program will

More information

Revising CS-M41. Oliver Kullmann Computer Science Department Swansea University. Robert Recorde room Swansea, December 13, 2013.

Revising CS-M41. Oliver Kullmann Computer Science Department Swansea University. Robert Recorde room Swansea, December 13, 2013. Computer Science Department Swansea University Robert Recorde room Swansea, December 13, 2013 How to use the revision lecture The purpose of this lecture (and the slides) is to emphasise the main topics

More information