

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Main points of this past exam are: Recursive Calls, More Efficient, Data Structures, Running Time, Syntax Errors, Binary Tree, Rooted at Node
Typology: Exams
1 / 2
This page cannot be seen from the preview
Don't miss anything!


public LinkList reverse() { Link current = this .first; LinkList rev = new LinkList(); while (current != null ) { Link node = new Link(current.data); node.next = rev.first; rev.first = node; current = current.next; } return rev; }
public static int size(Node x) { if (x == null ) return Stack
Node x) { 0; new Stack
!= null ) { rightChild != null ) { stack.push(x.rightChild leftChild;
rightChild != null ) x = x.rightChild; (!stack.isEmpty()) x = stack.pop();
The running time is O(n).
rightChild); }