| Computer Science Contents............... | Data Structures | Electronics...... | Networks.... | MICRO Processors | Operating Systems |
|---|
| Data Strucutres | Linked Lists | Binary Trees | Expression Converstion's | Infix To Postfix | Infix To Prefix | Postfix To Prefix | Postfix To Infix | Postfix Expression Evaluation |
|---|
| Home............ | Linked List | Binary Trees | Arrays | Stacks | Queues | Graphs | Searching Methods | Sorting Methods |
|---|
| Linked list problems............................................ |
|---|
| Reversing a linked list. Solutions... |
| Sorted Insertion of a node into linked list. Solution... |
| Deletion of node from linked list. Solution... |
| Finding Nth element in a Linked List. Solution... |
| Binary search method. Solution... |
| Generate mirror image tree of given tree. Solution... |
finding Nth Node in linked list..
int GetNth(struct node* head, int index) {
struct node* current = head;
int count = 0; // the index of the node we're currently looking at
while (current != NULL) {
if (count == index) return(current->data);
count++;
current = current->next;
}
assert(0); // if we get to this line, the caller was asking
// for a non-existent element so we assert fail.
}