CSE 116 - Fall 2006 - Banner
   CSE 116 - Fall 2006 - Introduction to Computer Science for Majors II
CSE 116 - Fall 2006 - Left Navigation CSE 116 - Fall 2006 - Lab 1 Contents

Exam 2 Sample Questions

 

Write Visitors on the LRStruct for each of the operations described

(Note: I may or may not post the answers to these problems. However, if you want to check your solutions, you can code them up and write a testing program to ensure their accuracy.)


toString

Returns the string representation of the list (covered in class and recitation)


Length

Returns the length of the list (covered in recitation)


nth Element

Return the nth element of a list (covered in recitation)


Delete First Occurrence of x

Find the first occurrence of x in the list and delete it (covered in recitation)


Delete All Occurrences of x

Similar to the one above, but deletes all occurrences of x in the list.


Sum

Works only on lists of numbers and returns the sum of all of the elements in the list.


Find smallest

Works only on lists of elements that can be compared (see java.lang.Comparable interface) and returns the smallest of those elements.


Return list of all elements smaller than x.

Works only on lists of elements that can be compared and returns a new list of all elements from the original list smaller than x.

Even numbers only

Works only on lists of Integers and returns a new list of all elements from the original list that are even.


Reverse

Returns a new list that has all of the elements of the original list, but in reverse order.


Other things to know for the test:

  • Stacks
  • Queues
  • When you would use stacks, queues, and lists (be able to give examples in either programs or real world)
  • Why shouldn't a Stack or Queue extend List
  • By creating Visitors, you should better familiarize yourself with the structure of the code for LRStruct and you should be comfortable with that structure.
CSE 116 - Fall 2006 - Footer

 

 
Last modified: Wed Nov 1 09:20:47 2006