fundamentals of data structures Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

data structure

A

the arrangment of data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

one dimensional array

A

stores data in one direction

useful way of representing a vector

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

two dimensional array

A

stores data horizontally and vertically

useful way of representing a matrix

example:

triplets = [[a,b,c], [d,e,f], [g,h,i]]

triples[2,1] = h

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

binary files

A

formatted so only one a program can read them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

text files

A

contain characters structured as lines of text

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

why files must be closed

A

closing free up resources, preventing corruption and ‘flushes’ the buffer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

record

A

usually for a single entity

heterogenous

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

subprogram

A

an ‘out of line’ block that performs a specific task

(can be ither user written or pre existing)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

how can subprogram be used

A

by calling their name in a statement causing them to be executed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

how can data be passed in to a sub routine

A

through parameters (variables used for the input to the subroutine)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

two types of subprograms

A

procedure (doesn’t return a value)
functions (returns a value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

structured programming

A

improves the quality and clarity of code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

pros for structured programming

A

code is more readable and easier to understand

easier to test

modules can be reused

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

steps in adding a record to a hash table

A
  1. apply hash function to calculate the hash value for the key .
  2. use the hash value to find the index in the hash table so that the new record could be stored.
  3. check if there is a record at the index. if yes, use a collision resolution technique.
  4. insert the new record at the index in the hash table and update the number of records in the hash table.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

two components of a stack frame

A

local variables and parameters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

operation of a stack frame and test whether if empty or full

A
  1. initialize an empty stack
  2. push values onto a stack from left hand side.
  3. for each number in the expression; push it onto a stack. for each operator; pop the top two numbers off the stack.
  4. after both have been processed, the stack should contain only one value, which is the result of the expression.
  5. check if empty by comparing the stack pointer to the initial address of the stack
  6. check if full by comparing the stack pointer to the max address of the stack
17
Q

Describe the method that would need to be followed to attempt to remove an item from a queue

A
  1. check if the queue is empty by comparing the front and rear pointer. if equal, the queue is empty and no item can be removed.
  2. if not empty, remove the front item from the front of the queue.
  3. update the front pointer to the next item in the queue. if the front pointer exceeds the size of the array, reset it to 0.
  4. reduce the count of items in the queue by 1
18
Q

Describe the method that would need to be followed to attempt to add an item to a queue

A
  1. Check if the number of elements in the queue is equal to the maximum capacity. If it is, the queue is full.
  2. If it is not full, increment the count of elements in the queue.
    Insert the item at the next available position in the queue.
  3. Check if the number of elements in the queue is equal to the maximum capacity. If it is, the queue is full. If it is not full, return false or display an appropriate message.
19
Q

three differences between dynamic and static data structures

A

static data structures memory are allocated at compile time/dynamic data structure memory are allocated at run time.

static data structure size is fixed and cannot change during runtime/ dynamic data structure size can be changed during runtime

static data structure memory is managed by compiler/ dynamic data structure memory is managed by the programmer

20
Q

explain how a single stack can be used to reverse the order of the items in a queue

A
  1. deque all the items from the queue and push them onto the stack
  2. pop them off one by one and enqueue them back into the original queue
  3. the order of the items in the queue will be reversed
21
Q

when does collision occur

A

when two key values compute the same hash.

22
Q

dictionary

A

A collection of key-value pairs in which the value is accessed via the associated key.

23
Q

application of dictionaries

A

information retrieval

24
Q

what does vector addition and multiplication achieve

A

addition achieves translation and multiplication achieves scaling.

25
Q

applications of dot product

A

Finding the angle between two vectors.

26
Q

graph

A

data structure used to represent more complex relationships.

27
Q

use of adjacency list instead of an adjacency matrix

A

when there are few edges between vertices
when edges are rarely changed

28
Q

weighted graph

A

a graph where each edge has a weight

29
Q

how do you know if a graph isnt a tree

A

if it contains a cycle

30
Q

tuple

A

an ordered list of elements

31
Q

tree

A

a connected, undirected graph with no cycles

does not have a root

32
Q

binary tree

A

rooted tree in which each node has at most two children.

33
Q

concept and use of a queue

A

linear data structure that follows the First-In-First-Out (FIFO) principle

used for tasks such as managing processes or handling requests in a sequential and ordered manner.

34
Q

concept and use of stack

A

follows the Last-In-First-Out (LIFO) principle

used for function calls, recursion, and managing program execution.

35
Q

peek or top

A

return the value of the top element without removing it

36
Q

use of rooted tree

A

to represent family trees or file
systems on a computer’s hard drive

37
Q

how are collision handled using rehashing

A

finding an available
position by moving to the next position until an available one is found.