Pert3 Flashcards
(22 cards)
What is binary tree?
a data structure which is defined as a collection of elements called the nodes
Prefix notation dikenal juga?
Reverse polish notation
postfix notation dikenal juga?
polish notation
Depth first search?
sebuah algoritma untuk traversing atau searching dalam sebuah tree atau graph. Dimulai dari root dari sebuah tree dan melakukan explore sedalam mungkin pada setiap cabang sebelum ke cabang yang sebelahnya.
Depth first search (DFS) menggunakan data structure?
Stack
Breadth first search (BFS) menggunakan data structure?
Queue
Several applications using queue?
- Deques
- Priority Queue
- Breadth First Search
Deque?
dapat di delete / insert dari head atau tail
2 jenis Deque
- Input restricted deque
insertion can be done only at one of the dequeue, deletions both the end - Output restricted deque
deletions can be done only at one of the dequeue, insertions both the end
Priority Queue?
sebuah ADT dimana setiap element diberikan sebuah prioritas
Breadth First Search (BFS)
sebuah algoritma untuk traversing atau searching dalam sebuah tree. dimulai dari root dan melakukan explore ke semua node yang bersebelahan dari level per level sampai menemukan hasil yang diinginkan
Breadth First Search (BFS)
sebuah algoritma untuk traversing atau searching dalam sebuah tree. dimulai dari root dan melakukan explore ke semua node yang bersebelahan dari level per level sampai menemukan hasil yang diinginkan
3 arithmetic notations?
- Prefix, operator duluan sebelum operands
- Infix, operator diantara operands
- Postfix, operator setelah operands
if TOP = MAX - 1
stack is full
why do we need prefix/postfix notation?
- prefix and postfix notation don’t need brackets to prioritze operator precedence
- prefix and postfix is much easier for computer to evaluate
complexity dari infix expression?
O(N^2), N adalah panjang string
Complexity dari Postfix expression?
O(N)
algoritma postfix notation?
- jika operand push ke stack
2. jika operator, pop twice (store ke var A dan B) dan push(B operator A)
Prefix notation pake stack scan dari mana ke mana?
kanan ke kiri
algoritma convertion prefix ke postfix
- cari operator dengan precedence paling tinggi
- put operator behind the operand
- repeat until finish
conversion infix to postfix notation complexity?
O(N)
algoritma infix ke prefix
- cari operator dengan highest precedence
- put that operator before operand
- repeat until finish