CS- data structures

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/25

flashcard set

Earn XP

Description and Tags

data structures

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

26 Terms

1
New cards

what is an array?

a variable that contains more than one data item/ static/ only one data type

2
New cards

What is a record?

a collection of different fields which can be of different data types

3
New cards

What is a list?

a data structure that consists of a number of items where the items can occur more than once

4
New cards

What is a tuple?

an ordered set of values of any type

5
New cards

What is a linked list?

a linear data structure made up of nodes, where each node contains data and a pointer to the next node in the list

6
New cards

What is a dictionary?

an abstract data type made up of associated pairs

7
New cards

What is a hash table?

an associative array which is coupled with a  hash function

8
New cards

What is a stack?

a linear data structure that follows LIFO principle 

9
New cards

What is a queue?

a linear data structure/ enqueue + dequeue / items removed from top of queue

10
New cards

What is a graph?

a set of nodes that are connected by edges

11
New cards

ADV of adjacency matrix in graphs

  1. convenient to work with

  2. adding an edge is simple

12
New cards

DIS of adjacency matrix in graphs

  1. a sparse graph (not many connections) will leave most cells empty and this is not storage efficient

  2. uses O(n²) space

13
New cards

What is a tree?

  • A connected undirected form of a graph with nodes and pointers 

  • An abstract data type

14
New cards

how is a directed graph different to an undirected graph?

in directed graphs, edges can only go in one direction

in undirected graphs edges can go in both directions

15
New cards

ADV + DIS of declaring an array as a global variable?

ADV = can be accessed anywhere in the program

DIS = increases memory usage as it is used until full program execution is over

16
New cards

How to add an item to a linked list

create new node containing data

set the new nodes pointer to point to the next node

update the previous nodes pointer to point to the new node

17
New cards

How to REMOVE from a linked list

traverse the list to find the node to be removed

change the previous node’s pointer to skip the node

delete the removed node

18
New cards

How TRAVERSAL takes place in a linked list

start at head node

read the data stored in the current node

follow pointer to the next node

repeat until the pointer is null

19
New cards

How does a dictionary work

each key is passed through a hash function

the hash function generates a hash value

the value determines where the data is stored in memory

the value is retrieved using the same key

this gives fast access

20
New cards

ADV of dictionaries

very fast lookup

efficient for large data sets

21
New cards

DIS of dictionaries

uses more memory

collisions might occur which takes longer

data not stored in order

22
New cards

How does a hash table work

a key is passed into a hash function

the hash function produces an index

the value is stored at that index in the table

this allows fast access to data

23
New cards

ADV of hash table

very fast to access data

search time is O(1) on average

efficient for large data sets

24
New cards

DIS of hash tables

collisions can occur - could decrease performance

uses extra memory

data is unordered

25
New cards

Why hash tables are faster than arrays/lists

direct access using an index

no need to search sequentially

average look up time is constant O(1)

26
New cards

Describe how a stack works

items are added using push

items removed using pop

only the top item can be accessed

earlier items can’t be accessed directly