Countering Identity Theft A Privacy Perspective

Countering Identity Theft A Privacy Perspective

Stacks - 2 Nour El-Kadri ITI 1121 Implementing 2 stacks in one array and we dont mean two stacks growing in the same direction: but two stacks growing in opposite

directions: 2 Implementing 2 stacks in one array How? One array but two distinct instance variables for the two tops: Why?

Memory management works like that. Such implementation may reduce the amount of memory that is wasted. 3 Primitive vs. reference 4 Earlier we said that pop consists of:

1. 2. 3. 4. saving the current top value, reset stack[top], decrement top, return the saved value. Is it necessary to set the top value to

null? 5 Since a reference from the stack to the object exists, this prevents the garbage collector from doing its job. 6 No reference to the

object, therefore gc() can do its job. 7 Note: error condition Pre- and post-conditions should be checked and the appropriate Exceptions should be thrown. if (! s.empty()) v = s.pop(); ...

if (! s.isFull()) s.push(v); 8 Properties of the arrays Arrays are accessed by index position, e.g. a[3] designates the fourth position of the array. Access to a position is very fast. We say that indexing is a random access operation in the case of the arrays, which means that the access to any element of an array always takes a

constant number of steps, we say the operation necessitates constant time, i.e. the time to access an element is independent of: The size of the array; The number of elements that are in the array; The position of the element that we wish to access (first, last, middle). 9 Access to any element of an array is fast because the elements of an array

are stored contiguously in memory. The array starts at some address of the memory, lets call this the base address, then the first element is stored at this address and the location of the next element depends on the size of an element. 10 All the elements of an array occupy the same amount of space and therefore the

address of any element is simply, base address+offset where the offset is index _ size of an element The first element (index = 0) is found at the base address, the second at the base address plus the size of one element, and so on. No search involved. 11

Fixed size arrays What if the size of an array is not known? Suppose, you were asked to read positive integers from the input until a special value is read (sentinel), say -9, and the values should be stored in a array. 12 How large should you declare this

array?*? Certain programming languages, such as Fortran and Pascal, require you to specify the size of the array at compile time. 13 Solution 1: make it large enough A possible solution would be to create

an array that would be suitable for even the largest application. What are the consequences of such actions? If the array is too large this wastes a lot memory. When the array is full the program may be forced to stop. 14 Solution 2: variable size

arrays Create an array of a reasonable default capacity. Increase or decrease its size according to the need. This means that the logical size of the array will not correspond to its physical size. Which means that its up to the programmer to maintain information about the logical size (the instance variable length of an array refers to its physical size).

Its the responsibility of the programmer to access elements that are below the logical size. 15 Qualify the behavior of the solution as the size of the array increases. All the elements of the array have to be copied. The more elements there are in the array the more copies are needed. Initially, there are only few elements to be copied, but the larger the array the more copies

are needed. Insertion and resizing are related to one another. Once the logical size of the array equals its physical size every subsequent insertion necessitates resizing the array, which has a cost that is proportional to the number of elements in the array. 16 A more practical solution consists of doubling

the size of the array whenever the logical size of the array equals its physical size. What have been achieved? Not all insertions require resizing the array, hence copying its elements. What has been lost? Memory efficiency. for some applications, the logical size of the array can also decrease, in which cases, the physical size of the array could also be decreased whenever the number of elements

is below a certain threshold. 17 1. is the array big enough? 2. where do we start coping the elements? implement remove(int pos) 18

Recently Viewed Presentations

  • GRACE EPISCOPAL CHURCH 2017 ANNUAL REPORT GRACE EPISCOPAL

    GRACE EPISCOPAL CHURCH 2017 ANNUAL REPORT GRACE EPISCOPAL

    General grounds maintenance to include cleanup of overgrown vegetation, grass cutting, weed eating, hedge trimming, leaf raking and mulch placement. Ongoing Parish Hall window restoration. Troubleshot and repair of various plumbing and electrical system failures, as well as repair furniture
  • PHASORS - Aventri

    PHASORS - Aventri

    Adding Phasors Graphically. In this example we want to verify the delta connection on a control transformer is safe to 'close' (verifying no phases are inadvertently reversed, which could cause a bolted fault). We are summing the induced voltages at...
  • The Nature of Science

    The Nature of Science

    Science as a way of knowing. Science refers to the system or process of acquiring knowledge about the natural world. To study the natural world, scientists use methods that are empirical, which means that they are grounded in observations and...
  • PRESENCE Bonus: Biblical Foundatons Part 3 Secular Objections

    PRESENCE Bonus: Biblical Foundatons Part 3 Secular Objections

    How do you understand the arc of the bible story from Genesis to Revelation as the story of the Eucharist? ... About six-in-ten (63%) of the most observant Catholics — those who attend Mass at least once a week —...
  • Data Mining 2012 with Microsoft Excel 2010 and PowerPivot

    Data Mining 2012 with Microsoft Excel 2010 and PowerPivot

    SQL Server Analysis Services provides enterprise-level data mining to Excel 2010 with PowerPivot. The Analyze and Data Mining Tabs have user-friendly functions for data mining Excel tables. The landing webpage includes many places to continue to learn
  • Diapositiva 1 - Neshaminy School District

    Diapositiva 1 - Neshaminy School District

    Consider the point in Quadrant I that corresponds to the angle 60 = ?3. Examine relationship between the angle measures for those in Quadrants II, III, and IV, where the angle is reflected across the y-axis, x-axis, and the origin....
  • 1 Chapter 4: Applets and Graphics Chapter 4

    1 Chapter 4: Applets and Graphics Chapter 4

    Chapter 4 Applets and Graphics Console and GUI applications Console application reads from keyboard writes text to terminal window easy to program Graphical User Interface application reads from keyboard, mouse uses UI components (buttons, text fields, sliders) can paint graphics...
  • Chapter 2 Numerical descriptors

    Chapter 2 Numerical descriptors

    Individual #25 has a survival of 7.9 years, which is 3.55 years above the third quartile. This is more than 1.5 IQR = 3.225 years. Individual #25 is a suspected outlier. Some software programs create "modified boxplots," in which suspected...