Page of CS106B Instructor Cynthia Lee Solutions

Page Of Cs106b Instructor Cynthia Lee Solutions-Free PDF

  • Date:08 Jan 2021
  • Views:4
  • Downloads:0
  • Pages:6
  • Size:518.17 KB

Share Pdf : Page Of Cs106b Instructor Cynthia Lee Solutions

Download and Preview : Page Of Cs106b Instructor Cynthia Lee Solutions


Report CopyRight/DMCA Form For : Page Of Cs106b Instructor Cynthia Lee Solutions


Transcription:

Page 2 of 6,2 Pointers and Linked Lists,struct listnode. listnode next,bool contains listnode list listnode sub. if sub NULL,return true,else if list NULL,return false. if list val sub val,return contains list next sub next. return contains list next sub,3 Recursion,Set int maxSumSubset treenode root.
if root NULL return Set int,Set int childSet maxSumSubset root left. maxSumSubset root middle,maxSumSubset root right,int childSum 0. for int i childSet,childSum i,if childSum root key. return childSet,Set int us,us root key,Page 3 of 6. 4 BSTs and Heaps, Diagram after inserting 25 2 Diagram after inserting 17 1.
This one is completed for you 17 1, Diagram after inserting 29 0 Diagram after inserting 55 1. 17 1 29 0 29 0, Diagram after inserting 45 7 Diagram after inserting 29 3. 17 1 29 0 17 1 29 3,Page 4 of 6, Diagram after inserting 25 Diagram after inserting 37. This one is completed for you, Diagram after inserting 28 Diagram after inserting 12. Diagram after inserting 30 Diagram after inserting 3. 25 28 25 12,Page 5 of 6,5 Inheritance, class Byron In the table below indicate in the right hand column the output.
virtual void m3 produced by the statement in the left hand column If the statement. cout B 3 endl produces more than one line of output indicate the line breaks with. m1 slashes as in x y z to indicate three lines of output with x followed. by y followed by z,virtual void m1, cout B 1 endl If the statement does not compile write compiler error If a. statement would crash at runtime or cause unpredictable behavior. write crash,class Yeats public Byron,virtual void m3 Statement Output. cout Y 3 endl,var4 m3 B 3 B 1 Y 3,virtual void m4 var4 m1 B 1. cout Y 4 endl,var4 m4 COMPILER ERROR,var2 m3 A 3,class Plath public Yeats. public var2 m1 P 1 B 1,virtual void m1,cout P 1 endl var2 m4 A 4 A 3.
var1 m4 COMPILER ERROR,void m3 var1 m3 P 3,cout P 3 endl. var1 m1 P 1 B 1,var5 m1 P 1 B 1,class Angelou public Plath. public var5 m4 Y 4,virtual void m4,cout A 4 endl var5 m3 P 3. Statement Output,cout A 3 endl,Yeats var4 m3 B 3 B 1 Y 3. Yeats var4 m4 Y 4,Now assume that the following,variables are defined Angelou var3 m4 CRASH.
Byron var5 m4 COMPILER ERROR,Byron var1 new Plath,Yeats var2 new Angelou Plath var2 m3 A 3. Byron var3 new Byron,Byron var4 new Yeats Angelou var2 m3 A 3. Yeats var5 new Plath,Page 6 of 6,6 Algorithms, If n is even we divide by two otherwise we add one to n Clearly Binky cannot add one to n twice. in a row There must therefore be at least as many steps where we divide n by 2 as there can be. steps where we add one to n As n gets large the number of times we have to divide n by two will. be the factor that determines how quickly we approach zero or one There can be at most log n of. those steps so the running time is therefore O log n. Does this strategy work YES NO circle Briefly explain why or why not. If we are deleting the last cell in the list ptr next is NULL When try to access assign to. ptr in the next line the right hand side will dereference NULL and crash. Page 1 of 6 CS106B Spring 2016 Instructor Cynthia Lee Solutions PRACTICE FINAL EXAM 1 SOLUTIONS 1 Graphs Vertex findLargestTree BasicGraph amp graph int largestTreeSize 0 Vertex largestTreeRoot NULL for Vertex v graph getVertexSet

Related Books