Code Monkey home page Code Monkey logo

itsanshulverma / du-cs-undergrad-course Goto Github PK

View Code? Open in Web Editor NEW
20.0 2.0 11.0 168.32 MB

Companion repo to store codes, assignments for B.Sc. (Hons) Computer Science Course (2019-2022) by University of Delhi

C++ 7.49% Java 1.94% Assembly 0.25% C 12.46% Lex 0.16% Yacc 0.01% HTML 62.81% JavaScript 0.03% Jupyter Notebook 13.95% Python 0.58% Prolog 0.32%
undergraduate-course computer-science cpp java du html-css-javascript lex yacc python android

du-cs-undergrad-course's Introduction

Computer Science (Hons.)

This is a companion repo to store codes, assignments, practicals for B.Sc. (Hons) Computer Science Course (2019-2022) offered by University of Delhi.

Structure of Repository :

  • Semester
    • Subject/Paper Name
      • Practicals
      • Assignments
      • Others

Author

Anshul Verma

du-cs-undergrad-course's People

Contributors

imgbotapp avatar itsanshulverma avatar

Stargazers

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

Watchers

 avatar  avatar

du-cs-undergrad-course's Issues

permute

#include

using namespace std;

void swap(int& a, int& b) {
int temp = a;
a = b;
b = temp;
}

void generatePermutations(int* nums, bool* used, int* perm, int size, int index, bool allowRepetition) {
if (index == size) {
for (int i = 0; i < size; i++) {
cout << perm[i] << " ";
}
cout << endl;
return;
}

for (int i = 0; i < size; i++) {
    if (!allowRepetition && i > 0 && nums[i] == nums[i - 1] && !used[i - 1])
        continue;

    if (!used[i]) {
        used[i] = true;
        perm[index] = nums[i];
        generatePermutations(nums, used, perm, size, index + 1, allowRepetition);
        used[i] = false;
    }
}

}

void permute(int* nums, int size, bool allowRepetition) {
bool* used = new bool[size];
int* perm = new int[size];

for (int i = 0; i < size; i++)
    used[i] = false;

generatePermutations(nums, used, perm, size, 0, allowRepetition);

delete[] used;
delete[] perm;

}

int main() {
int size;
cout << "Enter the number of elements: ";
cin >> size;

int* nums = new int[size];
cout << "Enter the elements: ";
for (int i = 0; i < size; i++) {
    cin >> nums[i];
}

bool allowRepetition;
cout << "Allow repetition? (1 for yes, 0 for no): ";
cin >> allowRepetition;

permute(nums, size, allowRepetition);

delete[] nums;

    return 0;
}

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.