GithubHelp home page GithubHelp logo

anuj-kumar-sharma / ds-algo Goto Github PK

View Code? Open in Web Editor NEW
511.0 511.0 405.0 44 KB

Implementation of Data structures and Algorithms at Apni Kaksha Java Placement Course

License: Apache License 2.0

Java 100.00%

ds-algo's People

Contributors

anuj-kumar-sharma avatar basudevbharatbhushan avatar iamrajiv avatar mukulbaid63 avatar rajutk7 avatar rdevkumar avatar shaikh-nabeel avatar tanmay80 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ds-algo's Issues

problem in print all subsequence of a string question

I have copied this code from GeeksForGeeks and couldn't understand how this works.
please @Anuj-Kumar-Sharma bhaiya explain this code in your next video I think many of us will get help from this algorithm.

//java code
public class Subsequence {

    // str : storse input string
    // n : length of str
    // curr : stores current permutation
    // index : index in current(curr) permutation

    static void printSubSeqRec(String str, int n, int index, String curr) {

        System.out.println(curr);
        for (int i = index + 1; i < n; i++) {
            curr += str.charAt(i);
            printSubSeqRec(str, n, i, curr);

            // backtracking
            curr = curr.substring(0, curr.length() - 1);
        }
    }

    // Generates power set in lexicographic order

    static void printSubSeq(String str) {
        int index = -1;
        String curr = "";
        printSubSeqRec(str, str.length(), index, curr);
    }

    public static void main(String[] args) {
        String str = "cab";
       printSubSeq(str);  
    }
}

output of this code comes to be

c
ca
cab
cb
a
ab
b

I recommend you to run the below code as well for clarity where I have given different print statements.

public class SubsequenceRecursion {

    // str : storse input string
    // n : length of str
    // curr : stores current permutation
    // index : index in current(curr) permutation

    static void printSubSeqRec(String str, int n, int index, String curr) {

        System.out.println(curr+"\n");
        for (int i = index + 1; i < n; i++) {
            curr += str.charAt(i);
            System.out.println("inside loop i is " + i);
            System.out.println("inside loop index is " + index);
            printSubSeqRec(str, n, i, curr);
            System.out.println("Before backtracking " + curr);
            System.out.println("i is " + i);
            System.out.println("index is " + index);

            // backtracking
            curr = curr.substring(0, curr.length() - 1);
            System.out.println("After backtracking " + curr);
        }
    }

    // Generates power set in lexicographic order

    static void printSubSeq(String str) {
        int index = -1;
        String curr = "";
        printSubSeqRec(str, str.length(), index, curr);
    }

    public static void main(String[] args) {
        String str = "cab";
        printSubSeq(str);
    }
}

make node class static

class Node {

this exception is thrown by java compiler:
No enclosing instance of type Tree is accessible. Must qualify the allocation with an enclosing instance of type Tree (e.g. x.new A() where x is an instance of Tree).

Looking to contribute at Apni Kaksha

Hi Anuj, is there anything I can contribute in your repository? I would to like to help you in your mission to educate students and prepare them for placements. Please view my GitHub profile, and if you find me eligible, let me know how I can contribute to this repository.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.