/* 1. Add a constructor to the classes AList, that
creates a list from a given array of objects.*/
public AList(T givenArray)
length = givenArray.length;
list = (T) new Object[length];
for (int index = 0; index < length; index+)cfw_
/Part I: Page 175 #3 - 6 and Page 197 #1, 3 6
/3.Suppose that you want an operation for the ADT list that adds an array of items
/to the end of the list. Write an implementation of this method for the class LList.
public void addAll(T items)cfw_
/*Page 601 #1 - 9, 13
For #2: assume that items are added to front of deque.
For #5, assume that priority is interpreted as coming first in a lexicographical ordering
For #8 and #9, assume that a customer is considered "
1) a. I need to shake hands with everybody - I need a loop
b. Each person shake hands with everybody else nested loop
c. Assuming that I dont stand on each step, I get a loop where is number of steps
d. I am sliding down no loops e. I am in the elevator
Week 10: Stacks
Some of the chapters in the text come in pairs: one is conceptual, the other
These chapters will be combined and treated together with the focus on the
Def: A stack is a list that can grow and shrink at the head
Week 9: Hashing
Chapters 17 and 18 on dictionaries will not be covered, however a few definitions are
needed before discussing hashing.
A dictionary contains entries with a key and other data that is associated with the key.
Also a map or tab
Week 7: Sorting
This section includes 3 chapters.
Chapter 11 reviews the simpler sorting methods excluding the bubble sort since it has
already been covered by most students.
These sorting methods (selection, insertion, recursive insertion, and Shell) are
Week 11: Queues
Def: A queue is a list that can grow at the tail and shrink at the head
A waiting list
FIFO first-in, first-out (same as last-in, last-out)
Restrict add and remove to
Removing all entries p
Week 12: Trees
Trees are useful Structures for hierarchies: directory structures, organization charts,
family trees, etc.
Note: The last few chapters in the text are organized into four modules on trees and
one module on graphs.
The four modules on trees
Week 13: Binary Search Trees
Some of the material covered is contained in Chapter 25 (about bst)
and the rest is in Chapter 27 about bst implementations.
Definitions: A binary search tree is an ordered binary tree such that for every node
all data is less
Week 14: Heaps
Some of the material covered is contained in Chapter 25 (about heaps page 661 ff)
and the rest is in Chapter 28 about heap implementations.
A tree is complete is all children exist except on the lowest level where all children
Week 15: Balanced Trees
Some of the material covered is contained in Chapter 25
and the rest is in Chapter 29.
Shape effects the efficiency of searching a bst:
best case: O(log n)
worst case: O(n)
This chapter addresses this issue with two major strategie
Week 16: Graphs
Chapters 30 and 31.
We have already studies special cases of graphs: linked lists and trees
Definitions: A graph is a collection of vertices and edges that connect the vertices in
Edges with direction are directed; graphs with direc
Week 6: Recursion
There are two methods for repetition: iteration and recursion.
Recursion may be more efficient and clearer than some iterative versions.
Recursion is a form of iteration, so any iterative version would have one extra loop than its
Week 5: Timing
The Efficiency of Algorithms
This may be the most important chapter in the course.
The mathematical abilities of students who take this class at the University level
differs from a typical Community College student.
The material in the chap
Week 4: Iterators
Chapter 8 is about iterators in Java.
This material is not on any test but some concepts are useful to better understand
Since the material is not covered in depth, this affords a perfect opportunity as an
option for ext
public void displayRowOfCharacters(char givenSymbol, int Number)cfw_
if (Number > 1)cfw_
displayRowOfCharacters(givenSymbol, Number - 1);
public void DrawCircle(int diameter, somePoint)cfw_
if (diameter > 1)cfw_
DrawCircle(0.75 * diameter, some
/#1. Sort by hand the array of integers 5 7 4 9 8 5 6 3 into ascending order
/by using a selection sort. show the contents of the array each time the sort changes it.
/Page 177 #9
/a. First in the chain
public void addToFront(T newEntry)cfw_
DNode newNode = new DNode(null, newEntry, firstNode);
lastNode = newNode;
firstNode = newNode;
/ end addToFront
/b. Last in
/* -HW11 CS111C
-Page 816-7 #1 - 7 and page 839 # 2 - 7 */
(b) All aquaintances of x
(c) The connections between people
(d) To be friend with somebody(the other
public class pascalTriangle cfw_
public static long pascal (int numberOfLines, int top, long
if (top <= numberOfLines) cfw_
long num = factorial(top) * factorial (numberOfLines - top);
someArray[top] = factorial(numberOfLines) / (num);
public class Palindrome cfw_
public static boolean checkPalindrome (String str) cfw_
String s = ignore(str);
Stack <Character> myPalindrome = new Stack <Character>();
for(int i = 0; i < s.length()/2 ; i+) cfw_