DATA STRS PROG METH
DATA STRS PROG METH COMPSCI 061BL
Popular in Course
Popular in ComputerScienence
This 4 page Class Notes was uploaded by Mr. Hayley Barton on Thursday October 22, 2015. The Class Notes belongs to COMPSCI 061BL at University of California - Berkeley taught by Staff in Fall. Since its upload, it has received 54 views. For similar materials see /class/226663/compsci-061bl-university-of-california-berkeley in ComputerScienence at University of California - Berkeley.
Reviews for DATA STRS PROG METH
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 10/22/15
39 Agenda Static vs Dynamic Box and pointer diagrams Code Questions and examples Bit representation Algorithmic Analysis Access rights Quickie questions 5 CS618 Midterm Review Winston Liaw and Amir Kamil w A m a u Miamiquot Review 2 Static vs Dynamic 39 Static vs Dynamic cont What happens Assume we have What happens Assume the same de ned definitions Homer h new Homer Bart b new BartO Bart bl b b1talk2 Homer h1 b Answer Homer Bart dude h1talk2 rtoon c1 h Answer Homer Bart dude Homerc1mk4 Answer Homer Homer doh m 3 Mew WW 4 Static vs Dynamic cont l Static vs Dynamic cont What happens For calls with an object of interest ie hf static methods are called based Cartoon 2 b on static type nonstatic methods are Bartc2whoa based on dynamic type Answer dude For calls involving this things get a Lumpy I2 b little trickier Static calls stay in the Homenml lmo same class dynamIc calls are based on the dynamIc set Answer Bart dude m 5 Mew WW 5 Box and Pointer diagrams Draw the diagrams that result from this code int x new int3 int y new int0 int z new int32 Midterm Review 7 39 Box and Pointer diagrams Draw the diagrarns that result trorn this code int 1 x new int3 int 1 v new into int 1 z new int32 z llllll x mm vEl l a a nu Midterm Review a Box and Pointer diagrams cont Modify the box and pointer diagram according to this code 2D Z2 Midterm Review 9 Box and Pointer diagrams l cont Moditv the box and pointer diagrarn according to this code Z1Z2r z I ll n an an Midterm Review in Coding Question Finish this method Given an IntList it will reverse it destructively and return the new list public IntList reverseIntList I Midterm Review 11 Coding Question Solution inttist ht public inttist reverse uilr i lritLiSt next l all white i i nuii next Halli itaii prev prev ii i next i return prev Hence we are done reversing an the pointers iwe need to set i s head to the new head Midterm Review 12 Bit Representation What is the bit representation for byte b 15 Answer 00001111 What is this value as a char 10110111 Answer 183 What about as a byte Answer 73 Midterm Review g Bit Representation Two s complement If the Most Significant Bit MSB is 0 then treat the remaining bits as normal as a positive number If the MSB is 1 flip the remaining bits add 1 and that is your negative value Remember two s complement only applies to signed values For an unsigned integer for instance treat it as normal Midterm Review g Modular Arithmetic For modular arithmetic Find out how many times your divisor can divide into your dividend Remember the remainder must be positive If the remainder is greater than the range of your values byte can have values btw 128 and 127 for instance then loop value around Midterm Review g Another Coding Question Finish these methods IntList pqueue removes the node with smallest value public int remove inserE the value into pqueue public void insertint m Midterm Review Another Coding Question Solution public int remove int X pqueuehead pqueue pqueuetai return X Midterm Review Another Coding Question I Solution cont public void inseam m 1 in eew ev tail new IntListllt temp elsel pqueue newnttis1llt pqueue prev emp temp e temp tail Midterm Review Algorithmic Analysis Definition of Big0h Ogn fn there exist positive constants c and no such that 0 lt fn lt cgn for all n gt no Definition of BigOmega Qgn fn there exist positive constants c and no such that 0 lt cgn lt fn for all n gt no Miamiquot Review 19 g Algorithmic Analysis One method takes Onz while another takes On gn The On gn method is always preferred True or false Miamiquot Review 2n go Algorithmic Analysis What are the running times BigOh Big Omega BigTheta for this code for int i k i lt 2 i for intj 0 lt zj some lg n code here Answer all are zkzlgn i term Review 21 Access rights If you override a method in a child class Java allows you to change the access rights to be less restrictive EX Parent s method is protected Child s method is public Refs to page 113 ll i Programmng ii ito Java for more details Miamiquot Review 22 Quickies What class has no superclass Why would you want to pick an array over a list Miamiquot Review 23