Data Structures

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/33

Last updated 7:22 AM on 5/18/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

34 Terms

1
New cards

What is pre-order traversal.

Starting from the root node of a binary tree traversing the left then the right subtree, draw the points on the left

2
New cards

What is in-order traversal?

Traverses the left subtree, root node and then the right subtree. The point is below.

3
New cards

What is post-order traversal?

Traverses left-subtree, right-subtree and then the root node

4
New cards

State two uses of pre-order traversal?

  • Copies the tree

  • Generates a prefix expression of the tree(Polish Notation)

5
New cards

State three uses of in-order traversal.

  • Puts data in alphabetical/numerical ascending order

  • Retrieve all items in a sorted list

  • (Generates an infix expression of the tree)

6
New cards

State two uses of post-order traversal

  • Generates a postfix expression of the tree (Reverse Polish Notation)

  • Delete data from a tree

7
New cards

Why are their different datatypes?

To enable related data to be efficiently organised in a variety of formats depending on the application and memory requirements for a certain task

8
New cards

Define all primitive data types

  • Integer = Stores whole numbers (+ve or -ve)

  • Real = Stores numbers that contain decimal places (and integers)

  • Character = stores a single character which can be a letter, number or symbol

  • String = Stores alphanumeric combinations and text, a sequence of characters

  • Boolean = Stores True or False (1/0)

9
New cards

Define static structure

A static structure is where the size of the structure does not change while the program is running

10
New cards

Define Dynamic structure

A dynamic structure is where the size of the structure can change while the program is running

11
New cards

Define Record

  • A record is a set of data items all related to a single entity

  • They can contain multiple data types and be accessed through a common name

  • One example of a record is a row in a database

12
New cards

Describe arrays

  • They are a static data structure used to store multiple items of the same data type under a single identifier

  • To add data, you search the array for an empty index to insert the data into

  • To delete data, you search the array for the requirement element, setting the index to null

  • Can be multi-dimensional

  • Is a random access data structure

13
New cards

How do you reference a data item in A 2D array

You give the row index, then the column index (down, then across)

14
New cards

Define random access data structure

Every element can be accessed as quickly as another

15
New cards

State the disadvantage of 3D arrays

It is complex to program

16
New cards

State how stacks and queues are represented

Using a circular array.

  • For stacks, there is a top pointer, inidicating the index of the last item added (where items should be pushed to and popped from)

  • For queues, there is a front pointer, = where to read/removed from and a rear pointer = where to write to

17
New cards

Describe Stacks

  • It is a data structure built on the concept of an array

  • They are Last in First Out (LIFO) data structures

  • It is only possible to push or pop an item from the top of the stack

  • A top pointer indicate the top of the stack

  • Static data structure

  • Sequential access data structure

  • A linear data structure which can be defined recursively

18
New cards

State when underflow and overflow occur for stacks

  • Underflow occurs when an attempt is made to pop an empty stack

  • Overflow occurs when an attempt is made to push to a full stack

19
New cards

Define recursive data structure

When the data structure can be broken down into smaller versions of the same data structure

20
New cards

Give the algorithm pseudo code for a stack

DECLARE stackArray as TYPE array of string
DECLARE stackpointer, maxLength as TYPE integer
DECLARE dataItem as Type stringh

FUNCTION push(dataItem):
	IF stackPointer < maxLenth then:
		stackPointer = stackPointer + 1
	ELSE output "Stack is full, data not saved"
	END IF
END FUNCTION

FUNCTION pop():
	IF stackPointer > 0 then:
		stackPointer = stackPointer + 1
	ELSE:
		output "Stack is empty, no data removed"
	END IF
END FUNCTION

21
New cards

State some uses for stacks

  • Store register values during subroutine execution

  • Reverse lists

  • Check syntax during compilation

  • Used for backtracking the users visited webpages (when back button pressed)

22
New cards

Describe queues

  • A First In First Out (FIFO) data structure

  • Items are added to the end of the queue (at the back pointer)

  • Items are removed/read at the front of the queue (front pointer)

  • Linear data structure

23
New cards

State how an item is removed from a queue and stack

  • Queue = Front pointer incremented by 1

  • Stack = Pointer decremented by 1

24
New cards

Describe linked lists

  • Dynamic data structure

  • The items are not necessarily held in contiguous (next to each other) data/memory locations

  • Sequential access data structure = A node cannot be directly accessed, each node must be traversed until correct node accessed

  • Each node contains a data field and the next address field (link/pointer field)

  • First node is called the head node

  • Pointer field in last item has Null value (-1)

  • Recursive data structure

25
New cards

Explain a disadvantage of linked lists

It uses more memory than an array because it needs to store the address for the next node, on top of the data

26
New cards

Describe binary trees

  • Dynamic data structure

  • 0 or more nodes in hierarchal order

  • Each parent has a maximum of 2 children

  • Can be traversed in pre-order, in-order and post-order traversal

27
New cards

State the advantages and disadvantages of binary trees

Advantages

  • Faster to add a value

  • Faster to search for a value

Disadvantages

  • More complex to program/process

  • Processing + traversing may be slow if unbalanced

28
New cards

When are binary trees used

  • When there is a large number of items to be stored, which need to be accessed quickly, or when sequenced lists are needed

  • Representing arithmetic expressions

29
New cards

State the different parts of a binary tree

  • Left+Right subtrees

  • Root node = Has no parent

  • Parent node = Has at least one child

  • Branches connect nodes

  • Leaf nodes = Have no children

30
New cards

State the rules for a binary tree

  • Each parent has 2 children maximum

  • If the element is <= current node,the element is the left child node

  • If the element > current node, the element is the right child node

31
New cards

Describe Hash Tables

  • Static data structure and the fastest data storage method

  • Ideally will always match the data you are storing (uniformly distributed, minimal collisions, efficient)

  1. The file memory location will be determined by passing the index/key value through an algorithm

  2. If there is a collision, file stored in overflow area (serial file/linked list)

32
New cards

State a problems with hash files overflow area and the solution

  • Searching the overflow area is slow, and the more files the slower the program becomes → Larger hash file created + new hashing algorithm

33
New cards

Define masking

The process of setting each bit in a byte to either on/off using bitwise operators

34
New cards

Which bitwise operator is used for encryption

XOR