Postingan

5 - Tree and Binary Tree - 2101702130 - Andrean

Gambar
Pertemuan ke - 5 27-03-2018 Binary Tree Concept is a rooted tree data structure in which each node has at most two children. •Those two children usually distinguished as left child and right child. •Node which doesn’t have any child is called leaf.  Type of Binary Tree • PERFECT binary tree  is a binary tree in which every level are at the same depth. A perfect binary tree is a complete binary tree. • COMPLETE binary tree  is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.  • SKEWED binary tree  is a binary tree in which each node has at most one child. • BALANCED binary tree  is a binary tree in which no leaf is much farther away from the root than any other leaf (different balancing scheme allows different definitions of “much farther”). Property of Binary Tree ...

4 - Introduction to Tree, Binary Tree and Expression Tree - 2101702130 - Andrean

Gambar
Pertemuan ke - 4 20-03-2018 Tree & Binary Tree Tree Concept DEGREE of TREE = 3 DEGREE of C = 2 HEIGHT = 3 PARENT of C = A CHILDREN of  A = B, C, D SIBILING of F = G ANCESTOR of F = A, C DESCENDANT of C = F, G Node at the top is called as root . . Nodes that do not have children are called leaf . Nodes that have the same parent are called sibling . Degree of node is the total sub tree of the node. Height/Depth is the maximum degree of nodes in a tree. If there is a line that connects p to q, then p is called the ancestor of q, and q is a descendant of p. Binary Tree Concept is a rooted tree data structure in which each node has at most two children. •Those two children usually distinguished as left child and right child. •Node which doesn’t have any child is called leaf.  Type of Binary Tree • PERFECT binary tree is a binary tree in which every level are at the same depth. A perfect binary tre...

3 - Linked List Implementation II - 2101702130 - Andrean

Gambar
Pertemuan ke - 3 13-03-2018 Stack is an important data structure which stores its elements in an ordered manner. Simplest logic is Last In First Out (LIFO) way.  The elements in a stack are added and removed  only from one end, which is called the top. In a linked stack, every node has two parts: – One that stores data – One that stores the address of the next node Stack Operations push(x)  : add an item x to the top of the stack. pop()  : remove an item from the top of the stack. top()  : reveal/return the top item from the stack. //top is also known as peek Infix, Postfix , and  Prefix Notation Prefix Infix Postfix * 4 10 4 * 10 4 10 * + 5 * 3 4 5 + 3 * 4 5 3 4 * + + 4 / * 6 – 5 2 3 4 + 6 * (5 – 2) / 3 4 6 5 2 – * 3 /  + Prefix: Operator, Left Operand , Right Operand (OLR) Infix : Left Operand , Opera...

2 - Linked List Implementation I - 2101702130 - Andrean

Gambar
Pertemuan ke - 2 27-02-2018 Linked List: - Single Linked List Simplest linked list.  Define a node structure : struct tnode {   int value;   struct tnode *next; }*head=NULL,*tail=NULL,*curr; head is the pointer for the first element in our linked list. tail is the pointer for the last element in our linked list. Insert Head: struct tnode *node =  (struct tnode*) malloc(sizeof(struct tnode)); //make a new node node->value = x; node->next  = head; head = node; Tail: struct tnode *node =  (struct tnode*) malloc(sizeof(struct tnode)); //make a new node node->value = x; node->next  = NULL; tail->next = node; tail = node; Delete // if x is in head node if ( head->value == x ) {   head = head->next;   free(curr); } // if x is in tail node else if(tail->value == x){   while(curr->next!=tail) curr = curr->next; ...