Uploaded by kmendoza

csci 201 - Google Docs

advertisement
‭10/31/23:‬
‭-‬ ‭Selection runtime (n^2)‬
‭-‬ ‭Insertion sort best case‬
‭-‬ ‭o(n)‬
‭-‬ ‭Worst case o(n^2)‬
‭-‬ ‭Average o(n^2)‬
‭-‬ ‭Merge sort‬
‭-‬ ‭n(logn)‬
‭-‬ ‭Quick sort‬
‭-‬
‭Lab 5: Oct. 9‬
‭Tape to the left:‬
‭-‬ ‭Add current to right arrayList‬
‭-‬ ‭Set current to rightmost value in left arraylift‬
‭-‬ ‭Remove that value from the left arraylist‬
‭-‬ ‭Set it up because the 0 index is at the top and the end is by the count head center‬
‭Array operations:‬
‭-‬ ‭Add( if not stated it will add to the end)‬
‭-‬ ‭remove( defaults to last variable at the end)‬
I‭ f (exp)‬
‭Return x‬
‭Else return y‬
‭Return (exp) ? x : y‬
‭ genda:‬
A
‭Text coxswain‬
‭Text juntos about ddlm‬
-‭ ‬ ‭void : no return, static : not an instance variable‬
‭-‬ ‭(string argos) type‬
‭Loop over a range of numbers:‬
‭Python vs java‬
‭ ython:‬
P
‭Def lopp (N):‬
‭For i in range (n):‬
‭Print (i) “prints n-1 numbers”‬
J‭ ava: as an instant method‬
‭Public class lopping {‬
‭Public void loop (int n) {‬
‭Int i ;‬
‭For (i = 0; i < n ; i ++ ) {‬
‭system.out.println( i ) ;‬
‭}‬
‭}‬
‭Psvm (string [] argos) {‬
‭Looping obj = new looping ();‬
‭Obj.loop (6) ;‬
‭}‬
‭ 9/14/23‬
0
‭- code to be used must be put in a public class, and then to run we must make a main‬
‭- primitive type: short‬‭, int,‬‭long‬
‭- float,‬‭double‬
‭- arrays start their index and 0‬
‭strings indexed at 0‬
‭-‬ ‭Message.length: length of method‬
‭-‬ ‭message.charAt()‬
‭-‬ ‭Substring‬
‭-‬ ‭equals‬
‭Converting:‬
‭-‬ ‭Char [] letters = message.toCharArray();‬
‭-‬ ‭String originalMessage = new string(letters);‬
‭-‬ ‭When it is an array to find the length no () are needed however it is needed for strings‬
‭Input from user:‬
‭-‬ ‭Scanner scnr= new Scanner( System.i);‬
‭-‬ ‭Dynamic methods: create a object usings only data and arguments; called on instance, instance‬
‭method‬
‭-‬ ‭Static: are called on the class; not an isntace‬
‭Helper for hw:‬
‭Public boolean isInside(int x, int y, int cx, int cy, int r) {‬
‭public static void main (main‬
‭}‬
‭Sept. 19‬
‭-‬ ‭Class names must match file names‬
‭-‬ ‭One public class for each file‬
‭Oct. 3‬
‭-‬ ‭For longer indexes we cant keep an array for it→ hash table ;‬
‭-‬ ‭Simple uniform hashing‬
‭-‬ ‭Deterministic h(x) equals same value‬
‭-‬ ‭Low cost we should be fast if it is log n then we will use another structure‬
‭-‬ ‭A good hash table minamalizes number of collisions‬
‭-‬ ‭In a hash table if a collision occurs we have a list in the index of a hash table‬
‭Chaning:‬
‭-‬ ‭Linked list to a hash table‬
‭-‬ ‭To add a list to a key we use key‬
‭-‬ ‭Return ( x == 0)? A : b‬
‭-‬ ‭If x ==0 then return a else return b‬
‭Diff ex‬
‭Y = (x==0) ? a : b‬
‭If x == 0 set y =a set y = b‬
‭Remove key‬
‭-‬ ‭Finding the key in the table‬
‭-‬ ‭Size of table n/m = a‬
‭Linear probing:‬
‭I = 0; i = 1; if collusion occurs we go to the next slot‬
‭Sets:‬
‭-‬
‭-‬
s‭ et.contains()‬
‭Hashsets are important because they can be used to count unique words‬
‭Clothes tmmr: supplies, beauty,‬
‭-‬ ‭Blue jeans/ black jeans‬
‭-‬ ‭Brown jacket‬
‭-‬ ‭shirt , sock, bra,‬
‭Racing:‬
‭-‬ ‭Thermal shirt‬
‭-‬ ‭Black leggings‬
‭-‬ ‭Blue sweats,‬
‭-‬ ‭Rain jacket‬
‭Extra: yellow backpack‬
‭-‬ ‭Pink sweats,‬
‭-‬ ‭Middlebury sweater‬
‭-‬ ‭Middlebury hat pink‬
-‭ ‬
‭-‬
‭ lasses‬
G
‭2 pair of socks‬
‭Friday:‬
‭-‬ ‭Wake up late‬
‭-‬ ‭Ship out package‬
Download