4.3 Fundamentals of algorithms

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

1/11

flashcard set

Earn XP

Description and Tags

Not all -> just some

Last updated 8:41 AM on 5/19/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

12 Terms

1
New cards

What are the 3 ways of traversing a binary tree?

In-order

Pre-order

Post-order

2
New cards

What are the acronyms for each of the tree traversals?

In-order : LNR

Pre-order : NLR

Post-order : LRN

3
New cards

True or False: You restart the LNR/NLR/LRN at each node ?

True!

4
New cards

What are the uses of In-order traversal?

Outputting an ordered list of contents from a binary tree,

Searching in a Binary Search Tree

5
New cards

What are the uses of Pre-order traversal?

Copying a Tree

6
New cards

What are the uses of Post-order traversal?

Emptying / Deleting a Tree

7
New cards

What are the steps for evaluating RPN ?

1) Start on the LHS of the expression

2) Push numbers onto a stack

3) If operator, pop previous two numbers, evaluate first num added to stack (operator) second num added to stack

4) Push result back onto stack

5) Repeat until a single number (the result) remains on the stack

8
New cards

Give the steps to convert Infix to RPN

1) Push open bracket onto stack

2) Numbers go to output list immediately

3) If operator -with higher precedence than operator on stack already- push onto stack

4) If operator has lower or equal precedence to operator on stack already, pop operator from stack then push new operator

5) Closing bracket pops all operators from stack until open bracket found

6) Expression is converted once stack is empty (so make sure to pop all operators at the end)

9
New cards

Which has higher precedence * or +

*

10
New cards

What is actually meant by an operator having “higher precedence” ?

An operator with higher precedence must be evaluated, regardless of where it is, before one of a lower precedence

11
New cards

When converting infix to RPN, if the stack currently contains a +, what happens when we try to push another + onto the stack?

The first + (of equal precedence) is popped, then the new + is pushed onto the stack

12
New cards

Give the steps for converting RPN to infix

1) Push numbers onto stack

2) If operator, pop previous two numbers, and create a string with brackets : (first number onto stack operator second number onto stack)

3) Push result onto stack

4) Repeat until one item remains on the stack