🗽
🗽
🗽
🗽
C/Cpp and OS
Search…
Guide
Templates and methods
Linked List with C
Linked List with C++
Stacks with C
Queues with C
Graphs with C/C++
Trees with C/C++
DS with C
Reverse Linked List
Implement Queue with LL
Find mid of LL without traverse
Delete a Node from LL
Create a Binary search tree
String and Array
Reverse string
implement strcmp in C
Maximum Subarray
CTCI
Ch 01 - Arrays and Strings
Ch 02 - Linked List
Algorithm
Bubble Sort
Insertion Sort
Merge Sort
Count Prime
Basic Concept in C
Understand about pointer
Pre/Post Increment Operator
string and constant charaters
buffer overflow
Short-circuit evaluation
Allocate memory for 2D array dynamically
OS review
For beginner
Reference
Question Collecting:
References
Template on Linux
Powered By
GitBook
Linked List with C
Basic template and methods
Structure
1
struct Node {
2
struct Node* next;
3
int val;
4
};
Copied!
NewNode
1
struct Node* newNode(int value){
2
struct Node* new_node = (struct Node*) malloc (sizeof(struct Node));
3
new_node->val = value;
4
new_node->next = NULL;
5
return new_node;
6
}
Copied!
AddToTail
1
void addToTail(struct Node **root, int value){
2
struct Node* new_node = (struct Node*) malloc (sizeof(struct Node));
3
new_node->val = value;
4
new_node->next = *root;
5
*root = new_node;
6
}
Copied!
Traverse
1
void traverse(struct Node* ref){
2
struct Node* tmp = ref;
3
while(tmp!= NULL){
4
printf("%d\n", tmp->val);
5
tmp = tmp->next;
6
}
7
}
Copied!
Previous
Guide
Next - Templates and methods
Linked List with C++
Last modified
4mo ago
Copy link
Contents
Structure
NewNode
AddToTail
Traverse