01 2024 档案

摘要:点击查看代码 //Binary tree traversal-- beadth-first and depth-first #include<iostream> #include<queue>//STL using namespace std; struct node { int data; nod 阅读全文
posted @ 2024-01-23 21:57 bituion 阅读(4) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Binary tree traversal-- level-order traversal using queue #include<iostream> #include<queue>//STL using namespace std; struct node { int data 阅读全文
posted @ 2024-01-23 20:36 bituion 阅读(5) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; struct Node { int data; Node *left, *right; }; Node* newNode(int x) { Node* temp = new Node; temp->data 阅读全文
posted @ 2024-01-23 19:16 bituion 阅读(8) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; struct Node { int data; Node *left, *right; }; Node* newNode(int x) { Node* temp = new Node; temp->data 阅读全文
posted @ 2024-01-23 18:41 bituion 阅读(5) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; struct Node { int data; Node *left, *right; }; Node* newNode(int x) { Node* temp = new Node; temp->data 阅读全文
posted @ 2024-01-23 17:39 bituion 阅读(2) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; struct Node { int data; Node *left, *right;//注意声明格式 }; Node* newNode(int x) { Node* temp = new Node; te 阅读全文
posted @ 2024-01-23 16:35 bituion 阅读(4) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include <iostream> using namespace std; struct Node { int data; Node* left; Node* right; }; Node* newNode(int x) { Node* temp = new Node; temp 阅读全文
posted @ 2024-01-23 16:06 bituion 阅读(5) 评论(0) 推荐(0) 编辑
摘要:尾递归(Tail Recursion)是一种特殊形式的递归,其特点是递归调用是函数的最后一个操作。在尾递归中,递归调用的返回值不需要进行额外的操作,而是直接返回给调用者。这种特殊的结构使得编译器有机会对递归调用进行优化,称为尾递归优化。 尾递归函数的特征是,在递归调用中,没有后续的计算步骤,直接将递 阅读全文
posted @ 2024-01-23 12:02 bituion 阅读(8) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Inplementation of Binary Search Tree #include<iostream> using namespace std; struct bstnode { int data; bstnode* left; bstnode* right; }; /*b 阅读全文
posted @ 2024-01-22 21:17 bituion 阅读(8) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Queue-Linked List Implementation #include<iostream> using namespace std; struct node { int data; node* next; }; node* front = NULL; node* rea 阅读全文
posted @ 2024-01-22 11:20 bituion 阅读(5) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Infix to postfix conversion using stack #include<iostream> #include<stack>//stack from standard template library(STL) #include<string> using 阅读全文
posted @ 2024-01-21 22:25 bituion 阅读(19) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Evaluation Of postfix Expression using stack #include<iostream> #include<stack>//stack from standard template library(STL) #include<string> u 阅读全文
posted @ 2024-01-21 15:50 bituion 阅读(7) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Check for balanced parentheses using stack #include<iostream> #include<stack>//stack from standard template library(STL) #include<string> usi 阅读全文
posted @ 2024-01-20 16:52 bituion 阅读(3) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Linked list reversal using stack #include<iostream> #include<stack>//stack from standard template library(STL) using namespace std; struct no 阅读全文
posted @ 2024-01-19 19:54 bituion 阅读(7) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //string reversal using stack #include<iostream> #include<stack>//stack from standard template library(STL) using namespace std; void reverse(c 阅读全文
posted @ 2024-01-19 19:18 bituion 阅读(3) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Prime factorization of a number #include<iostream> #include<cmath> using namespace std; void primefactorization(int n) { for (int i = 2; i <= 阅读全文
posted @ 2024-01-19 17:14 bituion 阅读(7) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Find all factors of a number #include<iostream> #include<cmath> using namespace std; void Factors(int n) { int* factors = new int[n+1](); for 阅读全文
posted @ 2024-01-19 16:09 bituion 阅读(2) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Find all prime number upto n-Sieve of Eratosthenes #include<iostream> #include<cmath> using namespace std; void findprimes(int n) { int* prim 阅读全文
posted @ 2024-01-19 15:23 bituion 阅读(4) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Verify a prime number-Trial division mothod #include<iostream> #include<cmath> using namespace std; int main() { int n; cin >> n; for (int i 阅读全文
posted @ 2024-01-19 13:32 bituion 阅读(2) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Convert a number from decimal to binary #include<iostream> using namespace std; struct node { int data; node* next; }; node* A; void insert(i 阅读全文
posted @ 2024-01-19 13:09 bituion 阅读(7) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Quick sort #include<iostream> using namespace std; int partition(int A[],int start,int end) { int pivot = A[end];//默认选取末尾为主元 int pIndex = sta 阅读全文
posted @ 2024-01-19 11:52 bituion 阅读(4) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Stack-link list implementation #include<iostream> using namespace std; struct node { int data; node* next; }; node* top; void push(int x) { n 阅读全文
posted @ 2024-01-19 07:51 bituion 阅读(3) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Merge sort #include<iostream> using namespace std; void merge(int L[], int R[], int A[], int nL, int nR) {//将两个已排序数组合并填入 int i = 0, j = 0, k 阅读全文
posted @ 2024-01-18 17:46 bituion 阅读(5) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Insertion sort #include<iostream> using namespace std; void insertionsort(int A[], int n) { int value, hole;//value表示插入值,hole表示插入位置 for (int 阅读全文
posted @ 2024-01-18 10:56 bituion 阅读(4) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Bubble sort #include<iostream> using namespace std; void bubblesort(int A[], int n) { for (int k = 1; k < n; k++) {//遍历n-1次,使索引1至索引n-1完成排序,索引 阅读全文
posted @ 2024-01-18 08:29 bituion 阅读(12) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Selection sort #include<iostream> using namespace std; void selectionsort(int A[], int n) { for (int i = 0; i < n - 1; i++) {//从索引0开始排序至索引n-2 阅读全文
posted @ 2024-01-18 07:38 bituion 阅读(4) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Stack-array based implementation #include<iostream> using namespace std; #define MAX_SIZE 101 int A[MAX_SIZE];//globle int top = -1;//globle 阅读全文
posted @ 2024-01-17 21:05 bituion 阅读(8) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Doubly linked list #include<iostream> using namespace std; struct node { int data; node* next; node* prev; };//定义双向链表结构体 node* A; node* getne 阅读全文
posted @ 2024-01-17 19:52 bituion 阅读(5) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Reverse a linked list using recursion #include<iostream> using namespace std; struct node { int data; node* next; }; node* A;//思考局部头指针如何递归 vo 阅读全文
posted @ 2024-01-17 17:26 bituion 阅读(3) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Print linked list using recursion #include<iostream> using namespace std; struct node { int data; node* next; }; void print(node* p) { if (p 阅读全文
posted @ 2024-01-17 16:18 bituion 阅读(3) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Reversse a linked list #include<iostream> using namespace std; struct node { int data; node* next; }; node* A; void reverse() { node* next;// 阅读全文
posted @ 2024-01-17 15:43 bituion 阅读(3) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Delete d node at nth position #include<iostream> using namespace std; struct node { int data; node* next; }; node* A; void insert(int x) { no 阅读全文
posted @ 2024-01-17 12:08 bituion 阅读(5) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //Inserting a node at nth position #include<iostream> using namespace std; struct node { int data; node* next; }; node* A;//全局头指针 void insert(i 阅读全文
posted @ 2024-01-17 10:53 bituion 阅读(3) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //inserting a node at beginning,局部变量头指针版本2 #include<iostream> using namespace std; struct node { int data; node* next; }; void insert(int x, no 阅读全文
posted @ 2024-01-17 09:26 bituion 阅读(5) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //inserting a node at beginning,局部变量头指针版本1 #include<iostream> using namespace std; struct node { int data; node* next; }; node* insert(int x,no 阅读全文
posted @ 2024-01-17 09:24 bituion 阅读(5) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //inserting a node at beginning,全局变量头指针 #include<iostream> using namespace std; struct node { int data; node* next; }; node* A; void insert(int 阅读全文
posted @ 2024-01-17 09:23 bituion 阅读(3) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 //遍历链表,将节点接到末端 #include<iostream> using namespace std; struct node { int data;//数据 node* next;//尾巴 };//定义节点结构体 node* A;//头指针固定,global variable, 阅读全文
posted @ 2024-01-17 09:17 bituion 阅读(4) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示