2 Pages

skiplistimplhints

Course: CS 514, Fall 2009
School: Washington University...
Rating:
 
 
 
 
 

Word Count: 971

Document Preview

Skip CS514: List Implementation (updated!) March 12, 2002 Tower Nodes are Critical Your implementation of a skip list will rely heavily on a tower node. A tower node is, rather than a single next pointer and key and data variables (if you are programming in Java, replace pointer with reference in this and following discussions) as in a singly linked list, but an array of next pointers along with single key and...

Register Now

Unformatted Document Excerpt

Coursehero >> Missouri >> Washington University in St. Louis >> CS 514

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Skip CS514: List Implementation (updated!) March 12, 2002 Tower Nodes are Critical Your implementation of a skip list will rely heavily on a tower node. A tower node is, rather than a single next pointer and key and data variables (if you are programming in Java, replace pointer with reference in this and following discussions) as in a singly linked list, but an array of next pointers along with single key and data variables. You need to be able to do the following to a tower node (these operations form the public interface of the class): * Get/set the tower height. You will not be shrinking nodes, so in setting the height, you need only support making the tower taller (i.e. making the next array longer). * Get/set what the next pointer at a particular height is. * Get/set the data in the node. * Get the key of the node. (You can set the key on object construction the key in the node should never need to change.) IMPLEMENT THE TOWER NODE FIRST, BEFORE YOU DO ANYTHING ELSE! Create a test skip list by artificially setting all the pointers yourself. It is CRITICAL that you test that this class works properly, even though it is not conceptually complicated. I repeat: be sure you get the expected results. One helpful way to test your tower node class is to write a debugging method that prints out each node in the list and the nodes to which each of the next pointers of that node points. This can be implemented either as a recursive method in the tower node class, or as an iterative method which takes in the first node in a list and walks down the nodes by following the next[0] pointers. To print out the nodes, you could print out the keys of the nodes to which each pointer points, but the nodes are not guaranteed to be unique. In a C/C++ implementation, a node is uniquely identified by its memory address; in Java, you could try using the hashCode( ) method (inherited from java.lang.Object) of the tower node to get a unique integer corresponding to the tower node. To The Skip List Class Let study the skip list now in detail. In class and in the paper, we had two conceptual s sentinels. A sentinel can be loosely defined as a structure that participates in the list and has meaning, but is not a data-bearing sentinel. One of these sentinels is the first item in the list, and it is as tall as any item in the list. The other is the last item, which represents a collection of null pointers. We will create a physical representation for the first sentinel only. So, as far as instance-level variables in the class, all we need to do is keep an instance-level pointer to this header sentinel. In the constructor for the class, we set this pointer equal to a new tower node. This node will never be examined in the search, so it doesn matter what t key we assign it; for error-checking purposes, it might be good to assign it a very large negative number, such as -231, so as to distinguish it from a real key. As far as Dictionary ADT operations go, since search, insert, and delete all have the same fundamental activity, which I will call skip searching, it would be wise to factor it out into a separate method for maintainability and reusability. The skip search boils down to finding the spot before the expected location of the element in question, sort of like in a linked list and in a binary search tree, except you need to find this spot for many levels/paths, not just one. Let look at some code for skip searching that we use to service the other major s ll Dictionary operations. (NOTE: The code below is provided for illustration only and has not been tested. For accuracy sake, I would like to hear of bugs arising from use of this code, s but if such bugs cause your lab not to work, it is your responsibility, NOT mine.) // In the skip list class constructor, initialize sentinel to be a new // TowerNode with dummy key. Ill refer to it as _listHeader below. /* C++-style skip search algorithm (private method inside skip list) * Java programmers: use . instead of ->, use TowerNode as the return ty pe, and use TowerNode[] as the type for the updatePtrs parameter. - the return value from this method is a reference to the first tower node in the list containing the key, if any - the updatePtrs parameter is an ARRAY of TowerNode pointers for which updatePtrs[maxUpdLvl] down to updatePtrs[0] are the nodes immediately preceding the returned node OR the spot where it should b...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Final Exam: December 18, 2000Your name:_Instructions: Do not begin until you are told to do so. Any printed reference material is allowed, but you may not collaborate with your classmates or us
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Spring 2001 Second Midterm: March 26, 2000Your name:_Instructions: Do not begin until you are told to do so. Any printed reference material is allowed, but you may not collaborate with your classmates or
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Second Midterm: November 20, 2000Your name:_Instructions: Do not begin until you are told to do so. Any printed reference material is allowed, but you may not collaborate with your classmates o
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Spring 2002 Homework Assignment 1 Assigned: January 10 Due: January 24Administrivia: All homework assignments are due at the start of class on the due date. Homework assignments must be in hardcopy form; no e
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Spring 2002 Detailed Reading Syllabus as of 1/23/02To assist you with planning, I have assembled a detailed syllabus of the intended course lectures and material, paired with detailed relevant reading for you
Washington University in St. Louis - CS - 514
January 31, 2002-Performance- Performance = 1 / execution time- Relative performance of computing environment x vs. environment yequal to ratio of performance of x to performance of yHardware-Dependent Metrics- Clock rate of processor = # o
Washington University in St. Louis - CS - 514
January 22, 2002-(45 min) Translation of Machine Instructions- In MIPS architecture, instruction encoding based on physical wiring- During instruction decode, specific regions of the bit pattern transmitted to the register file- Encoding m
Washington University in St. Louis - CS - 514
February 5, 2002-Asymptotic Analysis- Study behavior of algorithms as the input size gets larger- Hardware-independent under the assumption that architectures experience constant-ratio performance differences on program runtimes; we will exp
Washington University in St. Louis - CS - 514
January 15, 2002-X = complement of x(10 min) Review / QuestionsEXAMPLE: SP expansion for xyZ + xY- F(x,y,z) = xyZ + xY SP exp. = xyZ + xYz + xYZEXAMPLE: Build logic circuits for (simple) representation of F(20 min) Karnaugh maps- SP exp
Washington University in St. Louis - CS - 514
January 29, 2002-Cache Organization- Small amount of memory, close to processor- On reads, when a block is requested from memory, cache is first searched - on a miss, the block is written into cache and then sent on to the datapath- Usuall
Washington University in St. Louis - CS - 514
February 12, 2002-Real Meanings of Bounds- Asymptotic bound behavior rather than strict bound behavior- The Big-O, Big-Omega, and Big-Theta designations indicate equivalence classes of functions- 3n + 1, 66n + 24000, 5700n are all Big-Theta(
Washington University in St. Louis - CS - 514
January 24, 2002-Quick Pipelining Overview- Generalize the multi-cycle datapath to five stages- Instruction Fetch (IF)- Instruction Decode (ID)- Execute (EX)- Memory Access (MEM)- Write Back (WB)- Convert each new state register to a p
Washington University in St. Louis - CS - 514
February 7, 2002-In Reality.- We don't need to always check statement counts- Since all statement costs are constant, they may as well all be 1- Can process statement counts by inspectionInsertion Sort- Similar to sorting a hand of cards-
Washington University in St. Louis - CS - 514
January 10, 2002- _Note: For boolean variable x, in these notes X = x (complement of x)Why study logic?- Precision to mathematical statements- Bridge to mathematics on 0 - 1- Simulation of mathematics on 0 - 1 via electrical signals (e.g
Washington University in St. Louis - CS - 514
January 8, 2002-Before we begin- Who should be here?- MS SNCD students who have taken 504 or received permission for 514 due to preexisting Java/C+ experience- Students from other disciplines with Java/C+ computing experience (such as 50
Washington University in St. Louis - CS - 514
January 17, 2002-(5 min) History- ENIAC (Army, WWII) - compute projectile trajectories (Eckert/Mauchly)- Electronic Numerical Integrator and Computer- Only made public in 1946- Von Neumann machine concept (1944) - believed by some to be most
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Spring 2001 Quiz 1: February 5, 2001You have 20 minutes to complete this quiz. You may not use any books or notes. You must show your work to receive any credit, even if your answer is correct. You may leave
Washington University in St. Louis - CS - 514
Course Information HandoutInstructor: Teaching Assistants: Class Meetings: Lecture: Laboratory: Bob Amar, raa4@cs.wustl.edu John Kramer, jlk4@cec.wustl.edu James Ma, jinma6@hotmail.com MW M 5:30p 7p, McDonnell 362 7:30p 9p, Lopata 400Computer Sc
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Homework Assignment 4 Assigned: September 25 Due: October 4Administrivia: All homework assignments are due at the start of class on the due date. After that, they will not be accepted for credit. Ho
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Homework Assignment 2 Assigned: September 11 Due: September 18 WARNING: START THIS HOMEWORK EARLY!Administrivia: All homework assignments are due at the start of class on the due date. After that, t
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Homework Assignment 3 Assigned: September 18 Due: September 25Administrivia: All homework assignments are due at the start of class on the due date. After that, they will not be accepted for credit.
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Homework Assignment 9 Assigned: December 4 Due: December 11Administrivia: All homework assignments are due at the start of class on the due date. After that, they will not be accepted for credit. Ho
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Homework Assignment 1 - SolutionsProblem 1 (20 points total) (a) (15 points) Assume a problem involving n data points exists for which there are three well-known algorithms that solve the problem.
Washington University in St. Louis - CS - 11
CS514: We've Only Just BegunOctober 25, 2000Get Ready I am issuing this handout because I want to warn you of something extremely important about the rest of this course. In case you couldn't tell from looking at the course calendar: This course is
Washington University in St. Louis - CS - 514
CS514: We've Only Just BegunOctober 25, 2000Get Ready I am issuing this handout because I want to warn you of something extremely important about the rest of this course. In case you couldn't tell from looking at the course calendar: This course is
Washington University in St. Louis - CS - 514
CS514: Integer Division and Booth RecodingSeptember 27, 2000The Unsigned Integer Division Algorithm Recall the unsigned integer division algorithm from lecture, in which P is an initially zero extra register and the left operand is in register A an
Washington University in St. Louis - CS - 514
CS514: Reductions and the Propositional CalculusSeptember 11, 2000In the last lecture, I described the propositional calculus in gory detail. In this handout, I want to baseline what I expect each of you to know about what I covered in the last lec
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Homework Assignment 7 Assigned: November 8 Due: November 15Administrivia: All homework assignments are due at the start of class on the due date. After that, they will not be accepted for credit. Ho
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Homework Assignment 6 Assigned: October 30 Due: November 8Administrivia: All homework assignments are due at the start of class on the due date. After that, they will not be accepted for credit. Hom
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Homework Assignment 0 Assigned: August 30 Due: September 6The purpose of this homework assignment is twofold: To get to know you a little bit better in writing, and associate a face with this info.
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Homework Assignment 8 Assigned: November 27 Due: December 4Administrivia: All homework assignments are due at the start of class on the due date. After that, they will not be accepted for credit. Ho
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Solutions Homework Assignment 8Problem 1 (50 points total) (a) (40 points) An alignment of two DNA strings M and N (recall that DNA strings are made up of the characters A, C, G, and T) is an arran
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Homework Assignment 6 SolutionsProblem 1 (60 points total) Assume that you have a worst-case linear time median selection algorithm (i.e. the algorithm finds the median of an array of numbers of le
Washington University in St. Louis - CS - 514
Formal Foundations I: All About Logic and StuffHelpful Reading: Rosen 1.1-1.3Why study logic?sIn order to make assertions about, well, anything, we need to be precise The system of typographic logic we will study at the beginning of this cours
Washington University in St. Louis - CS - 514
Performance Measurements: The Practical Side.as opposed to the theoretical side, which is where we are headed next.Various Measurements of CPU PerformanceCPI (Cycles Per Instruction) The number of clock cycles required on average to execute an
Washington University in St. Louis - CS - 514
More Formal Foundations: Proof PowerHelpful Reading: Rosen 3.1 3.2 When we last left our heroes: Groundwork for the propositional calculus Demonstrating logical equivalence Turning predicates into propositions Specifying a value for an
Washington University in St. Louis - CS - 514
Son of Formal Foundations: Numbers and StuffHelpful Reading: Rosen 4.1-4.5 (has some extra set notation we have not covered yet)Discrete MathematicsDiscrete mathematics involves principles for discretized (noncontinuous) spaces Important such sp
Washington University in St. Louis - CS - 11
More Heaps of Hash, PleaseHelpful Reading: CLR Ch. 7, 12 Helpful Reading on Elementary Data Structures: CLR Ch 11All Data Structures are Not Created EqualsConsider a database program with fixed-size records, but an arbitrary, fluctuating numbe
Washington University in St. Louis - CS - 514
More Heaps of Hash, PleaseHelpful Reading: CLR Ch. 7, 12 Helpful Reading on Elementary Data Structures: CLR Ch 11All Data Structures are Not Created EqualsConsider a database program with fixed-size records, but an arbitrary, fluctuating numbe
Washington University in St. Louis - CS - 12
Monkey Business: In The TreesHelpful Reading: CLR Ch. 13, 14, 19 (MUCH more detail than this lecture will contain)Why Trees? We're Not MonkeysIf a tree of n elements is balanced and complete, then we can expect its height to be O(log n) - this o
Washington University in St. Louis - CS - 514
Monkey Business: In The TreesHelpful Reading: CLR Ch. 13, 14, 19 (MUCH more detail than this lecture will contain)Why Trees? We're Not MonkeysIf a tree of n elements is balanced and complete, then we can expect its height to be O(log n) - this o
Washington University in St. Louis - CS - 514
Computer Memory OrganizationElephants don't forget. but do computers?Memory Design GOAL: to best supply programmers with (almost) infinitely extensible memory that is as fast as possible to use The general design is a hierarchy The most expe
Washington University in St. Louis - CS - 15
ObjectOriented Design PatternsHip or Hype? Design Patterns DefinedA design pattern solves an OO architecture design problem in a specific context Four components A short pattern name A problem and its context A solution template Cons
Washington University in St. Louis - CS - 514
ObjectOriented Design PatternsHip or Hype? Design Patterns DefinedA design pattern solves an OO architecture design problem in a specific context Four components A short pattern name A problem and its context A solution template Cons
Washington University in St. Louis - CS - 514
Intro to Practical FoundationsComputer Organization Computer ArithmeticObjectives for Todays LecturesUnderstand the basic architecture of a computer and how it does its work Major architecture types Processing: The fetch-execute cycle The n
Washington University in St. Louis - CS - 14
Graph Algorithms (or, The End Is Near)Helpful Reading: CLR Ch. 23-25GraphsA graph is a collection of vertices and edges Vertices are fixed points Edges join two different vertices (no self-loops) In a directed graph, edges are one-way (there i
Washington University in St. Louis - CS - 514
Graph Algorithms (or, The End Is Near)Helpful Reading: CLR Ch. 23-25GraphsA graph is a collection of vertices and edges Vertices are fixed points Edges join two different vertices (no self-loops) In a directed graph, edges are one-way (there i
Washington University in St. Louis - CS - 13
A Story of Greed and PowerThe heavy stuff: Greedy Algorithms. Dynamic Programming. CLR Ch. 16 & 17Example: Huffman Codes Textcompression is extremely common Character type is usually at least 8 bitsASCII codes 0-255 Basedon a frequency ta
Washington University in St. Louis - CS - 514
A Story of Greed and PowerThe heavy stuff: Greedy Algorithms. Dynamic Programming. CLR Ch. 16 & 17Example: Huffman Codes Textcompression is extremely common Character type is usually at least 8 bitsASCII codes 0-255 Basedon a frequency ta
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Solutions Homework Assignment 7Problem 1 (60 points total) The following recursive algorithm on a binary tree T is called an inorder walk. Assume that T is not initially empty. INORDER-WALK(T) If (
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Solutions Homework Assignment 9Problem 1 (40 points total) Consider the following adjacency list representation of a directed graph: A: B: C: D: E: F: B C A A C C D F E F B E F D(a) (10 points) D
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Homework Assignment 3 Assigned: September 18 Due: September 25Administrivia: All homework assignments are due at the start of class on the due date. After that, they will not be accepted for credit.
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Homework Assignment 4 Assigned: September 25 Due: October 4Administrivia: All homework assignments are due at the start of class on the due date. After that, they will not be accepted for credit. Ho
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Quiz 1 SolutionsYou have 20 minutes to complete this quiz. You may not use any books or notes. You must show your work to receive any credit, even if your answer is correct. You may leave once you
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Solutions Quiz 4Problem 1 (9 points) Fill in the expected worst-case time complexities for the following operations for each of the indicated data structures. Let n be the number of keys in the dat
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Quiz 5: December 4, 2000You have 10 minutes to complete this quiz. You may not use any books or notes. You must show your work to receive any credit, even if your answer is correct. You may leave on
Washington University in St. Louis - CS - 514
CS514: Integer Division and Booth RecodingSeptember 27, 2000The Unsigned Integer Division Algorithm Recall the unsigned integer division algorithm from lecture, in which P is an initially zero extra register and the left operand is in register A an
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Quiz 4: November 8, 2000You have 20 minutes to complete this quiz. You may not use any books or notes. You must show your work to receive any credit, even if your answer is correct. You may leave on
Washington University in St. Louis - CS - 514
CS514 Fundamentals of Computer Science, Fall 2000 Solutions Quiz 5Problem 1 (9 points total) Circle the correct answer. The pairwise string alignment problem has optimal substructure. TRUE FALSE Because it can be solved by dynamic programming, it
Washington University in St. Louis - CS - 514
CS514: Reductions and the Propositional CalculusSeptember 11, 2000In the last lecture, I described the propositional calculus in gory detail. In this handout, I want to baseline what I expect each of you to know about what I covered in the last lec
Washington University in St. Louis - CS - 11
CS514: We've Only Just BegunOctober 25, 2000Get Ready I am issuing this handout because I want to warn you of something extremely important about the rest of this course. In case you couldn't tell from looking at the course calendar: This course