- About Abstract Data Types (ADT):
- Name an example of a ADT and name the operations that characterize this ADT. No need to explain if you know the right terminology.
- How is the concept of an ADT expressed in Java?

- Consider the pseudo code:

What is its running time in big-Oh notation?`X = 0;`

for i = 1 to N do- for j = i to N do
- for k = j to N do
- X++;

- for k = j to N do

- for j = i to N do
- Give the big-Oh value of the following geometric sums:
- S
_{1}= 1 + 3 + 9 + 27 + ... + 3^{n-1}(sum to n terms). - S
_{2}= 1 + (1/3) + (1/3^{2}) + (1/3^{3}) + ... + (1/3^{i}) + ... (infinite sum).

- S
- Write a complete Java program which simply
prints the string "Hello World!" on the screen.

NOTE: "complete" means this program would compile and run. Make as short a program as possible, without any comments. It is possible to only use 3 lines of code. - Assume you have a reference H to the first node (or "head")
in a singly linked list:
H --> (a) --> (b) --> (c) --> (d) --> (e) --> null.

Write a Java method called LastButOne to return a reference to the last but one node (this is node (d) in the figure above). In case the list has only one node, then return H itself. Here is the header for your method:

Note: the class Node has a public method called getNode() that returns a reference to the next node in the list.`public Node LastButOne(Node H);`

- Here is the pre- and post-order traveral listing of nodes
in a binary tree:
pre: (e, c, a, b, d)

Draw the binary tree. HINT: looking at the pre-order list, you know where to place node e and node c. But node a has two possible places.

post: (a, b, c, d, e)

- ADT:
- ADT Stack. Characteristic operations are Push and Pop.
- In Java, ADT's are represented by interfaces.

- Each iteration does at most n operations. Hence, the
running time is O(n
^{3}) - Sums:
- The infinite sum (1+x+x
^{2}+x^{3}+...) has value 1/(1-x) provided |x|<1. Hence answer is O(1). - The second sum is O(3
^{n}).

- The infinite sum (1+x+x
- Hello Java Program:
class Hello { public static void main(String[] args){ System.out.println("Hello World!"); } }

- List Java Program:
public Node LastButOne(Node H){ Node Prev = H; H = H.getNext(); if (H == null) { return Prev; }; while (H.getNext() != null){ Prev = H; H = H.getNext(); } }

- Tree Traversal:
The tree is e(c(a,b),a).

NOTATION: x(E1,E2) where E1,E2 are recursively expressions for the left and right subtrees rooted at x. A singleton tree with node x is simply denoted "x".