Hi,
I was learning recursion and Data Structure when I came across this problem in Trees. How to check if a given tree is a Binary Search Tree or not?
The code is
#include <iostream>...
Type: Posts; User: thebenman
Hi,
I was learning recursion and Data Structure when I came across this problem in Trees. How to check if a given tree is a Binary Search Tree or not?
The code is
#include <iostream>...
Hi, I wanted to write a C++ code that visits a particular URL and then enters a pre-defined value in it and presses "Enter" so that it can navigate to the next page and then get the data present in...
The reason for placing count++ after the recursive call is because only when the base case returns 0 is when the count starts to get incremented. Otherwise I'd be incrementing before the function...
Hey I was trying to write a function that gets you the data present in the node, by providing it the position starting from the end.
Suppose the list were like 1->2->3->4->NULL
and I call
...
Okay, I think I get it. temp is just a local variable whose actual values do not get modified. So, I'd have to pass the address of the exact location of the node in the heap. Right?
I know it is better to use iterative method, but I wanted to try it with recursion too. Just to learn :)
Thanks.
Sorry, for assuming. I am attaching the smallest possible executable code :)
#include <stdio.h>
#include <stdlib.h>
typedef struct Node
{
int data;
Node *next;
Hi,
I am trying to reverse a Linked list using recursion but whenever I try to print it after reversal it prints only the last element of the list.
void reverseRecursive(Node **root, Node...
Hi,
I was trying to reverse a list by swapping the previous and the next address of the current list. The logic seems to be right, but i cannot point as to where exactly the segmentation fault...
Thanks for the reply :) Really helped me !!
I have just one more question !!
Suppose we use the printList function like this
void printList(Node** root)
{
Node *temp = (*root);
Hey,
Thanks for the help, it works fine now.
Anyways I could not understand what happens when you use assignment operator on struct. Say,
Node *temp = (*root);
Thanks for the reply !
I did implement the changes that you had mentioned. Yet, now it returns a segment fault !!
The modified code is here.
#include <stdlib.h>
#include <stdio.h>...
Hi,
I was trying to implement a linked list in C, when I tried out the code written so far only for insert function I found out that the last element was only inserted.
Here's the code.
...
Hi,
A part of the problem I am trying to solve includes constructing a binary search tree from a sorted array. When ever I try to implement the same, it results in a segmentation fault.
...
I use ubuntu and then compile it using gcc. Could you suggest how to use the debugger with that? So that i can find out where the segmentation fault occours?
The sample test cases for which it...
I was trying to solve this problem when my code would pass for most of the test cases but throw segmentation error for the rest.
Animesh has N empty candy jars, numbered from 1 to N, with infinite...
Hey,
I was trying to solve a problem that required to add one hundred 50 digit numbers. Since there is no way to hold such a huge number. I read that storing them in strings is the way to go....
Hey,
I wanted to find all the prime until a specified limit in C. I use the Sieve of Eratosthenes. But when I define the limit to anything more than a 7 digit number the program terminates.
...
Yes, I shall look into better sorting algorithms. Btw, I updated the sortList() function to this
void sortList(struct node **head_ref) {
struct node *curr = *head_ref;
struct node *next;...
Hey,
I was trying to implement sorting in a linked list. However, when i run the sortList() function the program abruptly terminates.
Here's the complete code
/*
* {
*...
Hey,
I was trying to learn the implementation of SLL in C, while i encountered this problem.
When ever I try and print the list it does not return any elements. Initially, i did not use the...
Thanks for the help. It worked fine now. I'll keep those points in mind as I code :)
Anyways, the code took some time 0.16s to run and 3.8M Memory. I was wondering if i could improve the execution...
I made the following change in accepting the values for the structure.
However this doesn't seem to work as well, when i try to print the values of the structure I had entered.
struct values...
DO you mean the dynamic allocation made here?
ptr[i] = (struct values *)malloc(sizeof(struct values));
Is the qsort() function call correct? The program crashes when the input is anything...
I have added a structure to hold the values of C[] and T[].
#include<stdio.h>
#include<stdlib.h>
#define min(a,b) a<b?a:b
struct values
{
unsigned long long int C;
unsigned long...