


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
Material Type: Exam; Class: ALGS/DATA STRUCTURES; Subject: COMPUTER SCIENCE; University: Clemson University; Term: Summer 2 2004;
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!



i: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 a[i]: __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ Tree: root: I children of I: C J children of F: E G children of C: B F children of L: K M children of J: _ L children of E: D _ children of B: A _ children of G: _ H
Tree: root: L children of L: H N children of G: B _ children of H: G I children of I: J K children of N: M Q children of Q: _ R
x = a >= 0 || y != z && w > 1 || z <= x + y ;
public int countLeaves (BinaryNode t) {
= a 0 t != y z t w 1 t && t1 t2 t || t0 t3 t
public int countLeaves (BinaryNode t) { if (t == null) return 0; if (t.left == null && t.right == null) return 1; return countLeaves(t.left) + countLeaves(t.right); } // countLeaves