lists, etc

Cards (61)

  • Computer systems process data, to store one piece of data a variable is efficient however with larger amounts lists, etc are very efficient
  • In linear data structures the data items can be arranged in a linear sequence, this is found with arrays as data is all of the same type
  • Non-linear data structures have data items not in sequence
  • 2 examples of a non-linear data structures are?
    tree
    graph
  • Homogenous is where all elements are of the same data type, such as an array
  • Non-homogenous is where elements can be of many types, such as most data structures
  • Static data structures have a constant size and structure-associated memory locations which are fixed when the program is compiled
  • An example of a static data structures are arrays
  • Dynamic structures shrink or expand ad-hoc. Their associated memory locations may also change.
  • An example of a dynamic data structure is linked lists
  • Label :D
    A) Array names
    B) Data elements
    C) Index
  • Syntax to declare a basic array assuming array is imported and it will hold the values 0 to 5 in 5 indexes? (its called Arrayname)
    Arrayname = array.array('i', range(6))
  • What is a quick way to make an array with the string values apple and orange, and red and orange (two-dimensional), assume name is array_name and array is already imported?
    array_name = [[ 'apple', 'orange' ], [ 'red', 'orange' ]]
  • How would you access apple if it is in a two dimensional array named array_name, and is in the first array in the second slot?
    array_name [0][1]
  • When should the array module be used?
    When a function needs to be used while making the array such as a range
  • If you use the len() function on a two dimensional array it will return the number of rows
  • To get the len() function to return number of columns you must specify the row of the array
  • To ensure a variable is recognized as a tuple you must place a comma after it
  • Syntax to create a tuple with one element the integer 1?
    tuple = (1,)
  • An index value of -1 returns the last item in a tuple
  • The 'in' operator allows you to check whether an item is in a tuple
  • syntax to check if the string 'one' is in the tuple 'tuple1' and print true if it is or false if not?
    print ('one' in tuple1)
  • A record is declared, what psuedocode synyax is used to declare one called employee with an id as an integer named id and a name which is a string of name?
    employee = record
    integer id
    string name
    end record
  • Can you make a record in python?
    no
  • What is the syntax of assigning a constant in python?
    You can't
  • Mutable means you can change a value inside of it or add/remove values
  • Stacks are first in last out data structures
  • Queues are first in first out data structures
  • Are queues and stacks mutable?
    no they can be mutable or immutable
  • What are used to make queues and stacks?
    Arrays and linked lists
  • Array representations of linear queues or stacks needs variables that point to the front and rear.
  • A stack or queue is required to have a variable that holds the length of it
  • Name an operation exclusive to stacks?
    push(element)
  • First in first out item choosing is used for queues
  • What is the equivalent of append and the equivalent for pop in Linear queues?
    enQueue()
    deQueue()
  • Elements in a queue are placed in the/at the?
    back
  • Elements in a queue are retrivied from the?
    front
  • Processors process tasks that are taken from queues
  • Queues can use priority to move them to certain points within a queue
  • Elements in a stack are added to the ?
    Front