Search:

Type: Posts; User: thebenman

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    29
    Views
    1,822

    Minor Code Review

    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>...
  2. Replies
    32
    Views
    7,907

    Web Automation using C++.

    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...
  3. Replies
    6
    Views
    1,113

    The reason for placing count++ after the...

    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...
  4. Replies
    6
    Views
    1,113

    Recursive printing of Linked List.

    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
    ...
  5. Okay, I think I get it. temp is just a local...

    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?
  6. I know it is better to use iterative method, but...

    I know it is better to use iterative method, but I wanted to try it with recursion too. Just to learn :)

    Thanks.
  7. Sorry, for assuming. I am attaching the smallest...

    Sorry, for assuming. I am attaching the smallest possible executable code :)



    #include <stdio.h>
    #include <stdlib.h>
    typedef struct Node
    {
    int data;
    Node *next;
  8. Reversal of Doubly Linked List using Recursion !!

    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...
  9. Replies
    1
    Views
    690

    Reversal of a Doubly Linked List !

    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...
  10. Replies
    9
    Views
    1,081

    Thanks for the reply :) Really helped me !! I...

    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);
  11. Replies
    9
    Views
    1,081

    Hey, Thanks for the help, it works fine now. ...

    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);
  12. Replies
    9
    Views
    1,081

    Thanks for the reply ! I did implement the...

    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>...
  13. Replies
    9
    Views
    1,081

    Help with SLL !!

    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.

    ...
  14. Replies
    1
    Views
    682

    Seg fault while implementing BST.

    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.
    ...
  15. Replies
    8
    Views
    1,259

    I use ubuntu and then compile it using gcc. Could...

    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...
  16. Replies
    8
    Views
    1,259

    Segementation fault help needed.

    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...
  17. Help with adding two numbers taken as Strings !!

    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....
  18. Replies
    1
    Views
    10,442

    Storing a 10 digit number in C

    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.

    ...
  19. Replies
    3
    Views
    633

    Yes, I shall look into better sorting algorithms....

    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;...
  20. Replies
    3
    Views
    633

    Help with sorting a Linked List !!

    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


    /*
    * {
    *...
  21. Replies
    1
    Views
    611

    Help with displaying a list in C !!

    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...
  22. Replies
    9
    Views
    1,999

    Thanks for the help. It worked fine now. I'll...

    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...
  23. Replies
    9
    Views
    1,999

    I made the following change in accepting the...

    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...
  24. Replies
    9
    Views
    1,999

    DO you mean the dynamic allocation made here? ...

    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...
  25. Replies
    9
    Views
    1,999

    I have added a structure to hold the values of...

    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...
Results 1 to 25 of 51
Page 1 of 3 1 2 3