Donate to Grow My Website (1 $ please)

  • You may choose specified posts to show it as featured posts with automatic sliding effects and keep visitors engaged for long time on your sites.
  • Dec 20, 2018

    Data Structure - Full Explaination In Detail With Example - Learnengineeringforu

    Data Structure Full Explaination



    Lets learn data structure with this article, so lets start with array.

    Following are the basic topic which we cover in this article. 

    1. ANALYSIS OF ALGORITHMS | PART 2 (WORST, AVERAGE AND BEST CASES
    2. ANALYSIS OF ALGORITHMS | PART 3 (ASYMPTOTIC NOTATIONS)
    3. ANALYSIS OF ALGORITHMS | LITTLE O AND LITTLE OMEGA NOTATIONS
    4. ANALYSIS OF ALGORITHMS | PART 4 (ANALYSIS OF LOOPS)
    5. ANALYSIS OF ALGORITHM | SET 4 (SOLVING RECURRENCES)
    6. ANALYSIS OF ALGORITHM | PART 5 (AMORTIZED ANALYSIS INTRODUCTION)
    7. What does ‘Space Complexity’ mean?
    8. ANALYSIS OF ALGORITHMS | SET 1 (ASYMPTOTIC ANALYSIS)
    9. PSEUDO-POLYNOMIAL ALGORITHMS
    10. BIT ALGORITHM - LEARNENGINEERINGFORU
    11. PATTERN SEARCHING ALGORITHMS - LEARNENGINEERING
    12. MATHEMATICAL ALGORITHMS - FULL EXPLANATION - LEARNENGINEERINGFORU
    13. RANDOMIZED ALGORITHMS IN COMPUTER SCIENCE - FULL EXPLANATION - LEARNENGINEERINGFORU
    14. GEOMETRIC ALGORITHM IN COMPUTER SCIENCE - LEARNENGINEERINGFORU
    15. DATA STRUCTURE DYNAMIC ALGORITHM WITH EXAMPLES - LEARNENGINEERINGFORU
    16. DATA STRUCTURE DIVIDE AND CONQUER WITH EXAMPLES - LEARNENGINEERINGFORU
    17. INTRODUCTION TO BACKTRACKING ALGORITHM - LEARNENGINEERINGFORU
    18. BRANCH AND BOUND ALGORITHM EXPLAINATION - LEARNENGINEERINGFORU
    19. EXPLAINATION OF GREDDY ALGORITHM WITH EXAMPLE - LEARNENGINEERINGFORU
    20. C PROGRAMMING ARRAY - EXPLAINATION IN DETAIL - LEARNENGINEERINGFORU
    21. SINGLY LINKED LISTS - DATA STRUCTURE - LEARNENGINEERINGFORU
    22. DOUBLY LINKED LISTS - DATA STRUCTURE - LEARNENGINEERINGFORU
    23. CIRCULAR LINKED LISTS - DATA STRUCTURE - LEARNENGINEERINGFORU
    24. DATA STRUCTURE LINKED LISTS - SINGLY,DOUBLY AND CIRCULAR LINKED LISTS -LEARNENGINEERINGFORU
    25. TYPES OF ARRAY IN DATA STRUCTURE - LEARNENGINEERINGFORU
    26. DECLARATION OF ARRAY IN DATA STRUCTURE - LEARNENGINEERINGFORU
    27. DIFFERENT METHODS OF INITIALIZING 1-D ARRAY - LEARNENGINEERINGFORU
    28. MULTIDIMENSIONAL ARRAY IN DATA STRUCTURE - LEARNENGINEERINGFORU
    29. 2D ARRAY INITIALIZATION IN DATA STRUCTURE - LEARNENGINEERINGFORU
    30. DATA STRUCTURE AND ALGORITHM STACK - LEARNENGINEERINGFORU
    31. QUEUE PRAGRAM IN C LANGUAGE - LEARNENGINEERINGFORU
    32. BINARY TREES IN DATA STRUCTURE | ALGORITHM | LEARNENGINEERINGFORU
    33. DATA STRUCTURE AND ALGORITHM BINARY SEARCH TREES | LEARNENGINEERINGFORU
    34. DATA STRUCTURE AND ALGORITHM HEAP TREE - LEARNENGINEERINGFORU
    35. DATA STRUCTURE AND ALGORITHM HASHING - LEARNENGINEERINGFORU
    36. DATA STRUCTURE - GRAPH DATA STRUCTURE - LEARNENGINEERINGFORU
    37. DATA STRUCTURE - WHAT IS A MATRIX? EXPLAIN ITS USES WITH AN EXAMPLE - LEARNENGINEERINGFORU
    38. STRING DATA STRUCTURE - LEARNENGINEERINGFORU



    Dec 19, 2018

    String Data Structure - Learnengineeringforu


     String Data Structure


    Strings are defined as an array of characters. The difference between a character array and a string is the string is terminated with a special character ‘\0’.
    Declaring a string is as simple as declaring a one dimensional array. Below is the basic syntax for declaring a string in C programming language.
    char str_name[size];
    


    Function to copy string (Iterative and Recursive)

    Given two strings, copy one string to other using recursion. We basically need to write our own recursive version of strcpy in C/C++
    Examples:
    Input : s1 = "hello"
            s2 = "Learnengineeringforu"
    Output : s2 = "hello"
    
    Input :  s1 = "Learnengineeringforu"
             s2 = ""
    Output : s2 = "Learnengineeringforu"
    

    Iterative

    Copy every character from s1 to s2 starting from index = 0 and in each call increase the index by 1 until s1 doesn’t reach to end;
    // Iterative CPP Program to copy one String  
    // to another.
    #include <bits/stdc++.h>
    using namespace std;
      
    // Function to copy one string to other
    // assuming that other string has enough
    // space.
    void myCopy(char s1[], char s2[])
    {
        int i = 0;
        for (i=0; s1[i] != '\0'; i++)
           s2[i] = s1[i];
        s2[i] = '\0';
    }
      
    // Driver function
    int main()
    {
        char s1[100] = "Learnengineeringforu";
        char s2[100] = "";
        myCopy(s1, s2);
        cout << s2;
        return 0;
    }
    Output:

    Learnengineeringforu
    Recursive : 
    Copy every character from s1 to s2 starting from index = 0 and in each call increase the index by 1 until s1 doesn’t reach to end;
    // CPP Program to copy one String to 
    // another using Recursion
    #include <bits/stdc++.h>
    using namespace std;
      
    // Function to copy one string in to other
    // using recursion
    void myCopy(char s1[], char s2[], int index = 0)
    {
        // copying each character from s1 to s2
        s2[index] = s1[index]; 
      
        // if string reach to end then stop 
        if (s1[index] == '\0')  
            return;
      
        // increase character index by one
        myCopy(s1, s2, index + 1); 
    }
      
    // Driver function
    int main()
    {
        char s1[100] = "Learnengineeringforu";
        char s2[100] = "";
        myCopy(s1, s2);
        cout << s2;
        return 0;
    }
    Output:
    Learnengineeringforu