List: a sequence of cells in which each cell contains a data item of type Object a reference to the next cell in the sequence (null if this
|
|
- Bruce Preston
- 6 years ago
- Views:
Transcription
1 Lists 1 Overview Arrays Random access:! Fixed size: cannot grow on demand after creation: " Characteristics of some alications: do not need random access require a data structure that can grow and shrink dynamically to accommodate different amounts of data! (Linked) Lists satisfy this requirement. We study list creation accessing elements in a list inserting elements into a list deleting elements from a list 2 List: a sequence of cells in which each cell contains a data item of tye Object a reference to the next cell in the sequence (null if this is last cell in the sequence) emty list: null List is a sequential-access data structure to access data in osition n of sequence, we must access cells 0..n-1 We will define a class ListCell from which we will build lists. a our symbol for null 1 a -7 a8 a0 lc a8 2 Array: List a2 a /** An instance is a cell of a list, with a value and a name of another cell */ ublic class ListCell { rotected Object datum; // value of cell rotected ListCell next; // name of next cell //(null if none) /** Constructor: cell with value ob and next cell n */ ublic ListCell(Object ob, ListCell n){ /** = the value in this cell */ ublic Object getdatum() {//sometimes called car /** = name of next cell (none if none)*/ ublic ListCell getnext() {// called cdr /** Set value to ob */ ublic void setdatum(object ob) {// called rlaca Class ListCell 24 /** Set next cell to n ublic void setnext(listcell n) {// called rlacd This is how we draw ListCells datum 24 next ListCell ListCell(Object, ListCell) getdatum() getnext() setdatum(object) setnext(listcell) 4 /** Instance: a cell of list, with a value and a name of a cell */ ublic class ListCell { rivate Object datum; // value of cell rivate ListCell next; // name of next cell (null if none) /** Constructor: cell with value ob and next cell n */ ublic ListCell(Object ob, ListCell n) { datum= ob; next= n; /** = the value in this cell */ ublic Object getdatum() { return datum; /** = name of next cell (none if none)*/ ublic ListCell getnext() { return next; /** Set value to ob */ ublic void setdatum(object ob) { datum= ob; /** Set next cell to n ublic void setnext(listcell n) { next= n; Class ListCell 5 // Store in a list 24, -7, Integer t= new Integer(24); Integer s= new Integer(-7); Integer e= new Integer(); ListCell = new ListCell(e,null); = new ListCell(s,); = new ListCell(t,); 24 Building a list Note: assignment of form = new ListCell(s,); does not create a circular list. 6
2 Integer t = new Integer(24); Integer s = new Integer(-7); Integer e = new Integer(); // Store in a list of 24, -7, Building a list Another way: ListCell = new ListCell(t, new ListCell(s, new ListCell(e,null))); 24-7 Accessing list elements Lists are sequential-access data structures. to access the contents of cell n in sequence, you must access cells 0..n-1 Accessing data in first cell:.getdatum() Accessing data in second cell:.getnext().getdatum() Accessing next field in second cell:.getnext().getnext() getDatum().getNext() 8 Accessing list elements Writing to fields in cells can be done the same way //udate data field of first cell.setdatum(new Integer(53)); )); //udate field of second cell.getnext().setdatum(new Integer(53)); //cho off third cell.getnext().setnext(null); 24-7 Access examle: linear search // = ob is in list ublic static boolean search(object ob, ListCell ) { // invariant: c is the name of a cell in list (or null) // ob does not occur before cell c in list for (ListCell c= ; ci!= null; c= c.getnext()) if (c.getdatum().equals(ob)) return true; // { ob is not in the list return false; Recursion on lists Recursion can be done on lists in a manner similar to recursion on integers. Almost always base case: emty list recursive case: assuming you can solve roblem on (smaller) list obtained by eliminating first cell, write down solution for list Many list roblems can be solved very simly by using this idea. Some roblems, though, are easier to solve iteratively. Recursion examle: linear search Base case: emty list return false Recursive case: non-emty list if data in first cell equals object ob, return true else return result of doing linear search on rest of list // = ob occurs in list */ ublic static boolean recsearch(object ob, ListCell ) { if ( == null) return false; return.getdatum().equals(ob) recsearch(ob,.getnext()); 11 12
3 Some refer to use a class List that is distinct from class ListCell. A List object is like a element that always exists even if list itself is emty. /** An instance is a list with a er */ class List { rivate ListCell ; /** Constructor: an instance is a list List with er ublic List (ListCell ) {= ; /** = the first value of list (0 if none) ublic ListCell gethead() { /** Set list to */ ublic void sethead(listcell ) { Variations of list with er Header can kee other info, e.g. reference to last cell of list number of elements in list search/insertion/ deletion as instance methods 2 b2 b2 tail 3 c3 c3 size 3 What you ut in a er deends on the alication. search(ob) Examle of use of class List We write code to insert object into unsorted list delete the first occurrence of an object in an unsorted list. We use the class List to show how to use this class. It is just as easy to write code without the er element. Methods for insertion/deletion will be instance methods in class List. // insert ob into front of this list ublic void inserthead(object ob); // insert ob into front of this list ublic void inserttail(object ob); // delete ob from this list (if it is there) ublic void delete(object ob); 15 Insertion into tail of list ublic class List{ rivate ListCell ; ublic void inserthead(object ob) { = new ListCell(ob,).insertHead(new Integer(6)); a8 a Insertion into Tail of list ublic class List{.insertTail(new Integer(6)); rivate ListCell ; ublic void inserttail(object ob) { if ( == null) = new ListCell(ob, null) else { // Store in c the name of the tail of the list ListCell= ; while (c.getnext()!= null) a9 c= c.getnext(); 6 c.setnext(new ListCell(ob, null)); 24-7 a9 17 List = new List(null); Examle of use of insert methods //List is emty.inserthead(new Integer(-7)); // contains -7.insertHead(new Integer(24)); // contains 24, -7.insertTail(new Integer()); // contains 24, -7,
4 Remove first item from list /** remove and return the first element of this list. Throw RuntimeExcetion if this list is emty. */ ublic Object deletefirst(){ if ( == null) { throw new RuntimeExcetion( List is emty ); Object t=.getdatum(); =.getnext(); return t; Cases: list is emty: throw an excetion Remove and return last item from list list contains one element: change list contains >2 elements: change next-to-last element null /** List size >= 2. Return name of enultimate element */ rivate Object getpenultimate() { ListCell c= ; ListCell scout=.getnext(); /** invariant: c is name of a cell of the list, c.getnext() is not null, scout is the next cell following c */ while (scout.getnext()!= null){ c= scout; scout= scout.getnext(); return c; 24-7 Finding enultimate element of list enultimate means next to last Remove and return last item from list /** remove and return last element of list. Throw RuntimeExcetion if list is emty */ ublic Object deletelast(){ if ( == null) throw new RuntimeExcetion( list is emty ); if (.getnext() == null) { Object t=.getdatum(); = null; return t; // { list contains at least two elements ListCell enultimate= getpenultimate; ListCell last= enultimate.getnext(); enultimate.setnext(null); return last.getdatum(); Delete object from list Delete first occurrence of an object ob from a list. Idea of recursive code: If list is emty, return null. If first element of is ob, return rest of list. Otherwise, return list consisting of first element of, and the list that results from deleting from the rest of list ublic class List{ Recursive code for delete rivate ListCell ; // Delete first occur. of ob from list (if it is there) ublic void delete(object ob) { = deleterec(ob, ); // = list lc but with first occur. of ob deleted (if there) rivate static ListCell deleterec(object ob, ListCell lc) { if (lc == null) return null; // handle emty list // { list lc is not emty if (l.getdatum().equals(ob)) return lc.getnext(); // { first element of lc is not ob lc.setnext(deleterec(ob, lc.getnext())); return l; 24
5 /** First element of list c is not ob. Return name of element that recedes ob (or null if none) */ rivate Object getob(listcell c, Object ob) { ListCell scout=.getnext(); /** invariant: c is name of a cell of the list, c.getdatum() is not ob. Finding elem element of list scout is name of next element (null if none) */ while (scout!= null &&!scout.getdatum().equals(ob)){ c= scout; scout= scout.getnext(); if (scout == null) return null; return c; 24-7 // Delete ob from list, if there ublic void delete(object ob) { if ( == null) return; // If first element is ob, remove it and return if (.getdatum().equals(o)) { =.getnext(); return; // { First element of list is not ob ListCell receding= getob(, ob); if (receding == null) return; //slice out cell containing ob receding.setnext(receding.getnext()); Iterative code for delete Insertion and deletion with sorted lists Assume that we have a list of Comarables sorted in increasing order. We want to slice a new Comarable into this list, keeing new list in sorted order as shown in figure. Code shows recursive code for insertion and deletion. We show code that uses class ListCell directly Use notation [f,n] to denote ListCell whose datum is f next is n Recursive insertion Pseudo-code: insert (Comarable c, ListCell l): if l is null return new ListCell(c,null); else suose l is [f,n] if (c < f) return new ListCell(c,l); else return new ListCell(f, insert(c,n)); Comactly: insert(c,null) = [c,null] insert(c,[f,n]) = [c,[f,n]] if c < f [f, insert(c,n)] if c >= f /** lc is a sorted list. Insert c into it */ ublic static ListCell insert(comarable c, ListCell lc) { if (lc == null) return new ListCell(c, lc); // { list has at least one element if (c.comareto(lc.getdatum()) < 0) return new ListCell(c, lc); // { first element of list is > c lc.setnext(insert(c,lc.getnext())); return lc; /** List lc is sorted. Delete first occ. of c from it (if there) */ ublic static ListCell delete(comarable c, ListCell lc) { if ((l == null) return null; if (c.comareto(lc.getdatum()) < 0) return lc; if (c.comareto(lc.getdatum()) == 0) return lc.getnext(); lc.setnext(delete(c,lc.getnext())); return lc; 29 30
6 Exercises 1. Write insert into a sorted list without recursion. 2. Write delete from a sorted list without recursion. Doubly-linked lists In some alications, it is convenient to have a ListCell that references both its redecessor and its successor in the list. ublic class DLLCell { rivate Object datum; rivate DLLCell next; rivate DLLCell revious; In general, it is easier to work with doubly-linked lists than with lists. For examle, reversing a DLL can be done simly by swaing the revious and next fields of each cell. Trade-off: DLLs require more sace than singly-linked lists. 33 Summary Lists are sequences of ListCell elements recursive data structure grow and shrink on demand not random-access but sequential access data structures List oerations: create a list access a list and udate data change structure of list by inserting/deleting cells cursors Recursion makes erfect sense on lists. Usually base case: emty list, erhas one-element list also recursive case: non-emty list Sub-secies of lists list with er doubly-linked lists 34
2/22/2013 LISTS & TREES
LISTS & TREES Lecture 9 CS2110 Spring 2013 1 List Overview 2 Purpose Maintain an ordered collection of elements (with possible duplication) Common operations Create a list Access elements of a list sequentially
More information1 (5pts) 2 (20 pts) 3 (20 pts) 4 (10 pts) 5 (15 pts) 6 (30 pts) Total NAME: CU ID: Recitation instructor/time
CS 211 Computers and Programming Fall 2003 Prelim II 11/18/2003 NAME: CU ID: Recitation instructor/time You have one and a half hours to do this exam All programs in this exam must be written in Java Excessively
More information! A data structure representing a list. ! A series of nodes chained together in sequence. ! A separate pointer (the head) points to the first
Ch. 17: Linked Lists 17.1 Introduction to Linked Lists! A data structure reresenting a list! A series of nodes chained together in sequence CS 2308 Sring 2015 Jill Seaman - Each node oints to one other
More informationLinear Data Structure Linked List
. Definition. Reresenting List in C. Imlementing the oerations a. Inserting a node b. Deleting a node c. List Traversal. Linked imlementation of Stack 5. Linked imlementation of Queue 6. Circular List
More informationOptimizing Dynamic Memory Management!
Otimizing Dynamic Memory Management! 1 Goals of this Lecture! Hel you learn about:" Details of K&R hea mgr" Hea mgr otimizations related to Assignment #6" Faster free() via doubly-linked list, redundant
More informationRecursion examples: Problem 2. (More) Recursion and Lists. Tail recursion. Recursion examples: Problem 2. Recursion examples: Problem 3
Reursion eamples: Problem 2 (More) Reursion and s Reursive funtion to reverse a string publi String revstring(string str) { if(str.equals( )) return str; return revstring(str.substring(1, str.length()))
More informationOperations on Singly (Simply) Linked Lists
LEC. 4 College of Information Technology / Software Deartment.. Data Structures / Second Class / 2016-2017 InsertFirst Oerations on Singly (Simly) Linked Lists The insertfirst() method of LinkList inserts
More informationImplementation. 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 informationSummer Session 2004 Prelim I July 12, CUID: NetID:
COM S / ENGRD 211 Computers and Programming Summer Session 2004 Prelim I July 12, 2004 Name: CUID: NetID: You have one hour and fifteen minutes to do this exam. All programs must be written in Java. Where
More informationAshish 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 informationAnnouncements. Prelude (2) Prelude (1) Data Structures and Information Systems Part 1: Data Structures. Lecture 6: Lists.
Announcements MODULE WEB-SITE: http://www.csc.liv.ac.uk/ michele/teaching/comp102/comp102.html FIRST ASSIGNMENT DEADLINE: Wednesday, February 1st, 14.30, LAB 7 Boxes (late submissions to be left in the
More informationCIS Fall Data Structures Midterm exam 10/16/2012
CIS 2168 2012 Fall Data Structures Midterm exam 10/16/2012 Name: Problem 1 (30 points) 1. Suppose we have an array implementation of the stack class, with ten items in the stack stored at data[0] through
More informationDATA STRUCTURES AND ALGORITHMS
LECTURE 5 Babeş - Bolyai University Computer Science and Mathematics Faculty 2017-2018 In Lecture 4... Linked Lists Singly Linked Lists Doubly Linked Lists Today Algorithmic problems using Linked Lists
More informationData Structures. Alice E. Fischer. Lecture 4, Fall Alice E. Fischer Data Structures L4... 1/19 Lecture 4, Fall / 19
Data Structures Alice E. Fischer Lecture 4, Fall 2018 Alice E. Fischer Data Structures L4... 1/19 Lecture 4, Fall 2018 1 / 19 Outline 1 Ordered Lists 2 Sorted Lists Tail Pointers 3 Doubly Linked Lists
More informationMULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR
STUDENT IDENTIFICATION NO MULTIMEDIA COLLEGE JALAN GURNEY KIRI 54100 KUALA LUMPUR FIFTH SEMESTER FINAL EXAMINATION, 2014/2015 SESSION PSD2023 ALGORITHM & DATA STRUCTURE DSEW-E-F-2/13 25 MAY 2015 9.00 AM
More informationLecture Notes CPSC 122 (Fall 2014) Today Quiz 7 Doubly Linked Lists (Unsorted) List ADT Assignments Program 8 and Reading 6 out S.
Today Quiz 7 Doubly Linked Lists (Unsorted) List ADT Assignments Program 8 and Reading 6 out S. Bowers 1 of 11 Doubly Linked Lists Each node has both a next and a prev pointer head \ v1 v2 v3 \ tail struct
More informationStorage Allocation CSE 143. Pointers, Arrays, and Dynamic Storage Allocation. Pointer Variables. Pointers: Review. Pointers and Types
CSE 143 Pointers, Arrays, and Dynamic Storage Allocation [Chater 4,. 148-157, 172-177] Storage Allocation Storage (memory) is a linear array of cells (bytes) Objects of different tyes often reuire differing
More informationLinked 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 informationLinked Lists. Linked list: a collection of items (nodes) containing two components: Data Address (link) of the next node in the list
Linked Lists Introduction : Data can be organized and processed sequentially using an array, called a sequential list Problems with an array Array size is fixed Unsorted array: searching for an item is
More informationLinked Lists. Linked list: a collection of items (nodes) containing two components: Data Address (link) of the next node in the list
Linked Lists Introduction : Data can be organized and processed sequentially using an array, called a sequential list Problems with an array Array size is fixed Unsorted array: searching for an item is
More informationEC8393FUNDAMENTALS 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 informationExample: Runtime Memory Allocation: Example: Dynamical Memory Allocation: Some Comments: Allocate and free dynamic memory
Runtime Memory Allocation: Examle: All external and static variables Global systemcontrol Suose we want to design a rogram for handling student information: tyedef struct { All dynamically allocated variables
More informationITI 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 informationBasic Types and Arrays. Pointers. Records and Pointers. Record Definition. Creating a Record. Pointer. Basic Types. Arrays
Basic Tyes and Arrays ointers SE 6 Data Structures Lecture Basic Tyes integer, real (floating oint), boolean (0,), character Arrays A[099] : integer array A 0 6 7 99 A[] /9/0 ointers and Lists- Lecture
More informationUNIVERSITY OF WATERLOO DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING E&CE 250 ALGORITHMS AND DATA STRUCTURES
UNIVERSITY OF WATERLOO DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING E&CE 250 ALGORITHMS AND DATA STRUCTURES Midterm Examination Douglas Wilhelm Harder 1.5 hrs, 2005/02/17 11 pages Name (last, first):
More informationFunctional Programming. Pure Functional Programming
Functional Programming Pure Functional Programming Computation is largely performed by applying functions to values. The value of an expression depends only on the values of its sub-expressions (if any).
More information1.5 Case Study. dynamic connectivity quick find quick union improvements applications
. Case Study dynamic connectivity quick find quick union imrovements alications Subtext of today s lecture (and this course) Stes to develoing a usable algorithm. Model the roblem. Find an algorithm to
More informationCE204 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 informationCE204 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 informationUNIVERSITY OF WATERLOO DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING E&CE 250 ALGORITHMS AND DATA STRUCTURES
UNIVERSITY OF WATERLOO DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING E&CE 250 ALGORITHMS AND DATA STRUCTURES Midterm Examination Douglas Wilhelm Harder 1.5 hrs, 2005/02/17 11 pages Name (last, first):
More informationLinked List Implementation of Queues
Outline queue implementation: linked queue application of queues and stacks: data structure traversal double-ended queues application of queues: simulation of an airline counter random numbers recursion
More informationMID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct.
MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct. In linked list the elements are necessarily to be contiguous In linked list the elements may locate at far positions
More informationCS32 Discussion Week 3
CS32 Discussion Week 3 Muhao Chen muhaochen@ucla.edu http://yellowstone.cs.ucla.edu/~muhao/ 1 Outline Doubly Linked List Sorted Linked List Reverse a Linked List 2 Doubly Linked List A linked list where
More informationSource Coding and express these numbers in a binary system using M log
Source Coding 30.1 Source Coding Introduction We have studied how to transmit digital bits over a radio channel. We also saw ways that we could code those bits to achieve error correction. Bandwidth is
More informationIntroduction to Computer Science II CS S-18 Linked Lists
Introduction to Computer Science II CS112-2012S-18 Linked Lists David Galles Department of Computer Science University of San Francisco 18-0: Linked Lists Linked List node Data Pointer to the next element
More informationInsertions 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 informationArrays & Linked Lists
Arrays & Linked Lists Part 1: Arrays Array Definition An array is a sequenced collection of variables all of the same type. Each variable, or cell, in an array has an index, which uniquely refers to the
More informationLecture 18. Today, we will discuss developing algorithms for a basic model for parallel computing the Parallel Random Access Machine (PRAM) model.
U.C. Berkeley CS273: Parallel and Distributed Theory Lecture 18 Professor Satish Rao Lecturer: Satish Rao Last revised Scribe so far: Satish Rao (following revious lecture notes quite closely. Lecture
More informationAlgorithms, Data Structures, and Problem Solving
Algorithms, Data Structures, and Problem Solving Masoumeh Taromirad Hamlstad University DT4002, Fall 2016 Container Concepts containers store data container operations: insertion retrieval removal iteration
More informationTutorial 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 informationCSED233: Data Structures (2018F) Lecture3: Arrays and Linked Lists
(2018F) Lecture3: Arrays and Linked Lists Daijin Kim CSE, POSTECH dkim@postech.ac.kr Array Definition An array is a sequenced collection of variables all of the same type. Each variable, or cell, in an
More informationCSCE 110 PROGRAMMING FUNDAMENTALS
CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 16. Linked Lists Prof. amr Goneid, AUC 1 Linked Lists Prof. amr Goneid, AUC 2 Linked Lists The Linked List Structure Some Linked List
More informationLinked 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 informationDNHI Homework 3 Solutions List, Stacs and Queues
Solutions List, Stacs and Queues Problem 1 Given the IntegerQueue ADT below state the return value and show the content of the, initially empty, queue of Integer objects after each of the following operations.
More informationCOL106: Data Structures and Algorithms. Ragesh Jaiswal, IIT Delhi
Stack and Queue How do we implement a Queue using Array? : A collection of nodes with linear ordering defined on them. Each node holds an element and points to the next node in the order. The first node
More informationCSC 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 informationShuigeng Zhou. May 18, 2016 School of Computer Science Fudan University
Query Processing Shuigeng Zhou May 18, 2016 School of Comuter Science Fudan University Overview Outline Measures of Query Cost Selection Oeration Sorting Join Oeration Other Oerations Evaluation of Exressions
More informationStacks (5.1) Abstract Data Types (ADTs) CSE 2011 Winter 2011
Stacks (5.1) CSE 2011 Winter 2011 26 January 2011 1 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An ADT specifies: Data stored Operations on the data Error
More information! A data structure representing a list. ! A series of dynamically allocated nodes. ! A separate pointer (the head) points to the first
Linked Lists Introduction to Linked Lists A data structure representing a Week 8 Gaddis: Chapter 17 CS 5301 Spring 2014 Jill Seaman A series of dynamically allocated nodes chained together in sequence
More informationAn Indexing Framework for Structured P2P Systems
An Indexing Framework for Structured P2P Systems Adina Crainiceanu Prakash Linga Ashwin Machanavajjhala Johannes Gehrke Carl Lagoze Jayavel Shanmugasundaram Deartment of Comuter Science, Cornell University
More informationA Brief Introduction to Scheme (II)
A Brief Introduction to Scheme (II) Philip W. L. Fong pwlfong@cs.uregina.ca Department of Computer Science University of Regina Regina, Saskatchewan, Canada Lists Scheme II p.1/29 Lists Aggregate data
More informationCSE 373 Spring Midterm. Friday April 21st
CSE 373 Spring 2006 Data Structures and Algorithms Midterm Friday April 21st NAME : Do all your work on these pages. Do not add any pages. Use back pages if necessary. Show your work to get partial credit.
More informationI ACCEPT NO RESPONSIBILITY FOR ERRORS ON THIS SHEET. I assume that E = (V ).
1 I ACCEPT NO RESPONSIBILITY FOR ERRORS ON THIS SHEET. I assume that E = (V ). Data structures Sorting Binary heas are imlemented using a hea-ordered balanced binary tree. Binomial heas use a collection
More informationData 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 informationConvex Hulls. Helen Cameron. Helen Cameron Convex Hulls 1/101
Convex Hulls Helen Cameron Helen Cameron Convex Hulls 1/101 What Is a Convex Hull? Starting Point: Points in 2D y x Helen Cameron Convex Hulls 3/101 Convex Hull: Informally Imagine that the x, y-lane is
More informationLaboratorio di Algoritmi e Strutture Dati
Laboratorio di Algoritmi e Strutture Dati Guido Fiorino guido.fiorino@unimib.it aa 2013-2014 2 Linked lists (of int) We focus on linked lists for integers; let us start with a class that defines a node
More informationDynamic 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 informationIntroduction to Computing II (ITI 1121) Final Examination
Introduction to Computing II (ITI 1121) Final Examination Instructor: Marcel Turcotte April 2010, duration: 3 hours Identification Student name: Student number: Signature: Instructions 1. 2. 3. 4. 5. 6.
More informationBasic Data Structures (Version 7) Name:
Prerequisite Concepts for Analysis of Algorithms Basic Data Structures (Version 7) Name: Email: Concept: mathematics notation 1. log 2 n is: Code: 21481 (A) o(log 10 n) (B) ω(log 10 n) (C) Θ(log 10 n)
More informationLecture 8: Orthogonal Range Searching
CPS234 Comutational Geometry Setember 22nd, 2005 Lecture 8: Orthogonal Range Searching Lecturer: Pankaj K. Agarwal Scribe: Mason F. Matthews 8.1 Range Searching The general roblem of range searching is
More informationCS171 Midterm Exam. October 29, Name:
CS171 Midterm Exam October 29, 2012 Name: You are to honor the Emory Honor Code. This is a closed-book and closed-notes exam. You have 50 minutes to complete this exam. Read each problem carefully, and
More informationCMSC 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 informationComputer 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 informationDOWNLOAD 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 informationArrays. https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
1 Arrays Arrays in Java an array is a container object that holds a fixed number of values of a single type the length of an array is established when the array is created 2 https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
More informationCMPT 225. Lecture 6 linked list
CMPT 225 Lecture 6 linked list 1 Last Lecture Class documentation Linked lists and its operations 2 Learning Outcomes At the end of this lecture, a student will be able to: define one of the concrete data
More informationLinked Lists. Linked List Nodes. Walls and Mirrors Chapter 5 10/25/12. A linked list is a collection of Nodes: item next -3.
Linked Lists Walls and Mirrors Chapter 5 Linked List Nodes public class Node { private int item; private Node next; public Node(int item) { this(item,null); public Node(int item, Node next) { setitem(item);
More informationThe time and space are the two measure for efficiency of an algorithm.
There are basically six operations: 5. Sorting: Arranging the elements of list in an order (either ascending or descending). 6. Merging: combining the two list into one list. Algorithm: The time and space
More informationAdvanced 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 informationLinear Data Structures
Linear Data Structures Arrays Arrays are stored in contiguous memory locations and contain similar data An element can be accessed, inserted or removed by specifying its position (number of elements preceding
More informationMSO Exam January , 17:00 20:00
MSO 2014 2015 Exam January 26 2015, 17:00 20:00 Name: Student number: Please read the following instructions carefully: Fill in your name and student number above. Be reared to identify yourself with your
More informationLinked List. April 2, 2007 Programming and Data Structure 1
Linked List April 2, 2007 Programming and Data Structure 1 Introduction head A linked list is a data structure which can change during execution. Successive elements are connected by pointers. Last element
More informationCS 1110 Final, December 7th, 2017
CS 1110 Final, December 7th, 2017 This 150-minute exam has 8 questions worth a total of 100 oints. Scan the whole test before starting. Budget your time wisely. Use the back of the ages if you need more
More informationUNIT-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 information1 Deletion in singly linked lists (cont d) 1 Other Functions. 1 Doubly Linked Lists. 1 Circular lists. 1 Linked lists vs. arrays
Unit 3: Linked Lists Part 2: More on Linked Lists 1 Deletion in singly linked lists (cont d) 1 Other Functions Engineering 4892: Data Structures 1 Doubly Linked Lists Faculty of Engineering & Applied Science
More informationcsci 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 informationName: UTLN: CS login: Comp 15 Data Structures Midterm 2018 Summer
[Closed book exam] There are 7 questions leading up to 100 points. Max alloted time: 1 hour Problem 1 (2x10=20 points). Fill in the blanks in terms of the big-theta (Θ) notation to show the asymptotic
More informationAlgorithm Efficiency & Sorting. Algorithm efficiency Big-O notation Searching algorithms Sorting algorithms
Algorithm Efficiency & Sorting Algorithm efficiency Big-O notation Searching algorithms Sorting algorithms Overview Writing programs to solve problem consists of a large number of decisions how to represent
More informationLecture 7: Objects (Chapter 15) CS 1110 Introduction to Computing Using Python
htt://www.cs.cornell.edu/courses/cs1110/2018s Lecture 7: Objects (Chater 15) CS 1110 Introduction to Comuting Using Python [E. Andersen, A. Bracy, D. Gries, L. Lee, S. Marschner, C. Van Loan, W. White]
More informationinfix 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 informationInstructions. Definitions. Name: CMSC 341 Fall Question Points I. /12 II. /30 III. /10 IV. /12 V. /12 VI. /12 VII.
CMSC 341 Fall 2013 Data Structures Final Exam B Name: Question Points I. /12 II. /30 III. /10 IV. /12 V. /12 VI. /12 VII. /12 TOTAL: /100 Instructions 1. This is a closed-book, closed-notes exam. 2. You
More informationArrays. 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 informationDefinition. Pointers. Outline. Why pointers? Definition. Memory Organization Overview. by Ziad Kobti. Definition. Pointers enable programmers to:
Pointers by Ziad Kobti Deinition When you declare a variable o any tye, say: int = ; The system will automatically allocated the required memory sace in a seciic location (tained by the system) to store
More information17 February Given an algorithm, compute its running time in terms of O, Ω, and Θ (if any). Usually the big-oh running time is enough.
Midterm Review CSE 2011 Winter 2011 17 February 2011 1 Algorithm Analysis Given an algorithm, compute its running time in terms of O, Ω, and Θ (if any). Usually the big-oh running time is enough. Given
More informationCSE 230 Intermediate Programming in C and C++
CSE 230 Intermediate Programming in C and C++ Structures and List Processing Fall 2017 Stony Brook University Instructor: Shebuti Rayana http://www3.cs.stonybrook.edu/~cse230/ Self-referential Structure
More informationR10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May
www.jwjobs.net R10 SET - 1 II B. Tech I Semester, Supplementary Examinations, May - 2012 (Com. to CSE, IT, ECC ) Time: 3 hours Max Marks: 75 *******-****** 1. a) Which of the given options provides the
More information1B1b Implementing Data Structures Lists, Hash Tables and Trees
1B1b Implementing Data Structures Lists, Hash Tables and Trees Agenda Classes and abstract data types. Containers. Iteration. Lists Hash Tables Trees Note here we only deal with the implementation of data
More informationLecture 3: Geometric Algorithms(Convex sets, Divide & Conquer Algo.)
Advanced Algorithms Fall 2015 Lecture 3: Geometric Algorithms(Convex sets, Divide & Conuer Algo.) Faculty: K.R. Chowdhary : Professor of CS Disclaimer: These notes have not been subjected to the usual
More informationDepartment of Computer Science and Technology
UNIT : Stack & Queue Short Questions 1 1 1 1 1 1 1 1 20) 2 What is the difference between Data and Information? Define Data, Information, and Data Structure. List the primitive data structure. List the
More information10/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 informationFun 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 informationUMBC CMSC 331 Final Exam
UMBC CMSC 331 Final Exam Name: UMBC Username: You have two hours to complete this closed book exam. We reserve the right to assign partial credit, and to deduct points for answers that are needlessly wordy
More informationComputer Science E-119 Fall Problem Set 1. Due before lecture on Wednesday, September 26
Due before lecture on Wednesday, September 26 Getting Started Before starting this assignment, make sure that you have completed Problem Set 0, which can be found on the assignments page of the course
More informationLinear 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 informationINSTITUTE OF AERONAUTICAL ENGINEERING
INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad - 500 043 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name Course Code Class Branch DATA STRUCTURES ACS002 B. Tech
More informationLecture 4: Elementary Data Structures Steven Skiena
Lecture 4: Elementary Data Structures Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.stonybrook.edu/ skiena Problem of the Day Find two
More informationDistributed Estimation from Relative Measurements in Sensor Networks
Distributed Estimation from Relative Measurements in Sensor Networks #Prabir Barooah and João P. Hesanha Abstract We consider the roblem of estimating vectorvalued variables from noisy relative measurements.
More informationAlgorithms and Data Structures
Algorithms and Data Structures PD Dr. rer. nat. habil. Ralf Peter Mundani Computation in Engineering / BGU Scientific Computing in Computer Science / INF Summer Term 2018 Part 2: Data Structures PD Dr.
More informationA linked list. Subtopic: Linked lists. List-node structure type. Array implementation of a linked list. Inserting into a sorted collection
Subtopic: Linked lists A linear structure, like an array Composed of self-referential nodes Operations: insert, delete, traverse Array implementation Dynamic-allocation implementation David Keil 1/03 1
More informationTREES Lecture 10 CS2110 Spring2014
TREES Lecture 10 CS2110 Spring2014 Readings and Homework 2 Textbook, Chapter 23, 24 Homework: A thought problem (draw pictures!) Suppose you use trees to represent student schedules. For each student there
More information