본문 바로가기

[자료구조론] - Data Structure

(18)
10. Graph cycle - starting vertex == ending vertex 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142#include using namespace std; typedef s..
Priority Queue 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110#define MAX_HEAP 100 typedef enum {false,true} bool;typedef char Data; typedef struct{ Data data; int priority;}HNode; typedef struct{ HNode items[MAX_HEAP + 1]; int num;}Heap;..
Infix to Postfix & make calculate tree 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677// 1. infix to postfixint getPriority(char op){ if(op == '*' || op == '/') return 2; else if(op =='+' || op == '-') return 1; else return 0;} bool Compriority(char op1, char op2){ int op1_pr = getPriority(op1); int op2_pr = getPriority(op2); if(op1_pr >..
InOrder - LCR 1. recursion 2. w/o recurion - using stack https://www.geeksforgeeks.org/inorder-tree-traversal-without-recursion/ Inorder Tree Traversal without Recursion - GeeksforGeeks A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. www.geeksforge..
preOrder - CLR 1. recursion 2. w/o recursion - using stack Iterative Preorder Traversal - GeeksforGeeks A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. www.geeksforgeeks.org
postOrder - LRC 1. recursion 2. w/o recursion using two stacks https://www.geeksforgeeks.org/iterative-postorder-traversal/ Iterative Postorder Traversal | Set 1 (Using Two Stacks) - GeeksforGeeks A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. www.g..
Tree 구현 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 typedef int BData; typedef struct _bTreeNode{ BData item; struct _bTreeNode *left_child; struct _bTreeNode *right_child; }BTreeNode; int main(){ BTreeNode *n1 = (BTreeNode*)malloc(sizeof(BTreeNode)); BTreeNode *n2 = (BTreeNode*)malloc(sizeof(BTreeNode)); BTreeNode *n3 = (BTreeNode*)malloc(sizeof(BTreeNode)); n1->item = 10..
Questions regarding Data Structures Q. What is advantage of implementing stack and queue by arrays? A. The advantage of using an array implementation for a stack is that it is more efficient in terms of time than a linked list implementation. This is because there is none of the work associated with claiming new store as the size of the stack increases and garbage collecting it as it reduces. Rather there is a fixed amount of stor..
Dynamic Queue (Using LinkedList) 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253typedef enum {false,true} bool;typedef int Data; typedef struct _Node{ Data item; struct _Node* next;}Node; typedef struct{ Node* front; Node* rear;}DQueue; void InitQueue(DQueue *pqueue){ pqueue->front = pqueue->rear = NULL;} bool IsEmpty(DQueue *pqueue){ return pqueue->front == NULL;} Data Peek(DQu..
Dynamic Stack (Using Linked List) 1234567891011121314151617181920212223242526272829303132333435363738394041typedef enum {false,true} bool;typedef int Data; typedef struct _Node{ Data item; struct _Node* next;}Node; typedef struct{ Node* top;}DStack; void InitStack(DStack *pstack){ pstack->top = NULL;} bool IsEmpty(DStack *pstack){ return (pstack->top == NULL);} Data Peek(DStack *pstack){ if(IsEmpty(pstack)) exit(1); return pstac..