arrays ii robin burke it 130. outline homework #6 portfolio array review array examples array...

Download Arrays II Robin Burke IT 130. Outline Homework #6 Portfolio Array review Array examples Array algorithms Multi-dimensional arrays

Post on 29-Dec-2015




0 download

Embed Size (px)


  • Arrays IIRobin BurkeIT 130

  • OutlineHomework #6PortfolioArray reviewArray examplesArray algorithmsMulti-dimensional arrays

  • Homework #6Three component gradesKnowledgeReasoningCommunicationOverall very good papers!Many nice site designs

  • IssuesTarget marketingnot really possible for campaign web siteyou have to identify the audience that will use such a sitenot choose the audience and build site to suitNarrow contentsite has only policy positions and eventseasy to find these thingsreal site would have much moreDesign justificationreport should justify design choicesexample: information hierarchyeach page has foreground and backgroundwhat belongs in each categorywhat visual techniques distinguish

  • PortfolioMust includenew copies of each homeworkexceptionsif full credit, just copyhomework #6 report onlyMS Word .doc or PDF fileno "original" neededDo not includelabshomework #6 designs / notesDue dateMidnight, 11/22 (Monday before Thanksgiving)

  • PortfolioDoGet started earlyyou now have enough experience that early assignments should be easy (or at least easier)Aim for full credit on all assignmentssend me email if you don't understand the grading feedbackRead the original assignmentDon'tWait until the last minuteIgnore what the grader had to say

  • Portfolio siteit130hwk1hwk2...etc...portfolioindex.htmlpoints to old and new assignmentshwk1hwk2hwk3...etc..Example

  • ArrayArray is a list of values accessed by indexname[index]foo[5]Must create before usingfoo = new Array ();Zero-based indexinglength attributearr.length

  • Using for loop to access arrayFor loop piecesinitial counter value: 0exit test: value < array.lengthchange to counter: + 1Patternfor (i = 0; i < arr.length; i++){do something to arr[i] element}

  • Images arraytwodice page from last weekdocument.images[imgNo].src = "dice01.jpg";How to read thisfrom the document objectthe pageget the images arraya list of all the images on the pageget one item from this array using imgNo as indexsome particular imageset the src attribute of this image to the given value

  • Examplen dice

  • Array algorithmsCommon tasks with arraysfind an element with some propertycombine the elements of the arrayfill an array with valuessort the elements

  • Combination example: averagevar total = 0;for (i = 0; i < numbers.length; i++){ total = total + numbers[i];}ave = total / numbers.length;

  • Combination patternAssume array contains some valuesvar variable = empty value;for (i = 0; i < array.length; i++){variable = accumulate ( variable, array[i] );}

  • Examplebuild-sentence.htmlAssemble a sentence using the words in an arraywords = new Array ("welcome", "to", "arrays", "in", "JavaScript");function result = "welcome to arrays in JavaScript"

  • Selection exampleFind the first element in the array less than zerofor (i = 0; i < array.length; i++){if (array[i] < 0)return i;}return -1;

  • Selection pattern

    for (i = 0; i < array.length; i++){if (test (array[i]))return i; orreturn array[i];}return not found value;

  • Selection ExampleFind the smallest element of an arrayA bit different from patternWe have to look at every elementsave the best so far

  • Fill exampleFill an array with zerosfor (i = 0; i < count; i++){array[i] = 0;}

  • Fill patternfor (i = 0; i < size; i++){ array[i] = initial value;}

  • ExampleAlternate dice ideaFill array with image urlsPick from array instead of if statementUsually a good idea

  • Parallel arraysSometimes we have data that is pairedstate / # of electoral voteshomework / date dueWe can handle this with two arrayssame sizecorresponding indices mean corresponding data

  • Exampleduedate.html

  • ProblemEasy for arrays to get out of syncTwo things to keep track ofThe pairing is in the programmer's headnot represented in the structure of the data

  • Multi-dimensional arrayWe can change our data structureinstead of two arrays of elements, which are pairedwe can have one array of pairsExample

  • Homework #8Slide showAdd rewind, fast-forward, and back buttonsUse enable / disableWrite a function that controls the buttons so enable / disable logic is not repeated

  • MondayData representation


View more >